단어 줄 바꿈 및 가운데 맞춤 텍스트를 사용하여 열 너비 설정

단어 줄 바꿈 및 가운데 맞춤 텍스트를 사용하여 열 너비 설정

내 목표는 Word에서 만든 다음 테이블에 대한 라텍스 코드를 작성하는 것이었습니다. 여기에 이미지 설명을 입력하세요

그러나 첫 번째 열의 형식을 지정할 수 없습니다. 열 너비에 대한 특정 측정값을 정의하고 이 명령에 대해 너비가 너무 작은 경우 자동 줄 바꿈을 생성하고 또한 텍스트가 병합된 두 셀 사이의 중앙에 오도록 하고 싶습니다.

\begin{table}[H]
\centering
\begin{tabular}{p{3cm}cccccc}
\hline
  Variável                                                         & Período & Média    & Desvio Padrão & \begin{tabular}[c]{@{}c@{}}Coeficiente \\ de variação\end{tabular} & \begin{tabular}[c]{@{}c@{}}Valor\\ Mínimo\end{tabular} & \begin{tabular}[c]{@{}c@{}}Valor\\ Máximo\end{tabular} \\ \hline
    \multirow{2}{*}{Leitos de UTI}                                   & 2016    & 1.867    & 2.505         & 134,17\%                                                           & 73                                                     & 11.039                                                 \\
    & 2019    & 2.016    & 2.738         & 135,81\%                                                           & 82                                                     & 12.515                                                 \\ \hline
    \multirow{2}{=}{Doadores Efetivos}                               & 2016    & 141      & 193           & 136,88\%                                                           & 5                                                      & 842                                                    \\
    & 2019    & 178      & 249           & 139,89\%                                                           & 4                                                      & 1.080                                                  \\ \hline
    \multirow{2}{*}{CIHDOTT’s}                                       & 2016    & 31       & 56            & 180,65\%                                                           & 1                                                      & 255                                                    \\
    & 2019    & 25       & 29            & 116,00\%                                                           & 1                                                      & 106                                                    \\ \hline
    \multirow{2}{*}{Equipes de Transplantes Renais}                  & 2016    & 6        & 8             & 133,33\%                                                           & 1                                                      & 35                                                     \\
    & 2019    & 7        & 8             & 114,29\%                                                           & 1                                                      & 31                                                     \\ \hline
    \multirow{2}{*}{Respiradores de emergência}                      & 2016    & 2.594    & 3.697         & 142,52\%                                                           & 121                                                    & 16.692                                                 \\
    & 2019    & 2.981    & 4.115         & 138,04\%                                                           & 152                                                    & 18.807                                                 \\ \hline
    \multirow{2}{*}{Serviços de Neurocirurgia}                       & 2016    & 20       & 26            & 130,00\%                                                           & 3                                                      & 118                                                    \\
    & 2019    & 22       & 28            & 127,27\%                                                           & 4                                                      & 127                                                    \\ \hline
    \multirow{2}{*}{Valores totais pagos com Serviços Hospitalares}  & 2016    & 6.871,29 & 11.235,63     & 163,52\%                                                           & 41,79                                                  & 49.342,72                                              \\
    & 2019    & 8.071,96 & 12.114,82     & 150,08\%                                                           & 85,20                                                  & 54.430,50                                              \\ \hline
    \multirow{2}{*}{Valores totais pagos com Serviços Profissionais} & 2016    & 2.606,59 & 4.332,99      & 166,23\%                                                           & 16,72                                                  & 19.179,92                                              \\
    & 2019    & 3.074,86 & 4.657,82      & 151,48\%                                                           & 35,65                                                  & 20.285,42                                              \\ \hline
    \multirow{2}{*}{Recusa Familiar}                                 & 2016    & 120      & 140           & 116,67\%                                                           & 12                                                     & 656                                                    \\
    & 2019    & 123      & 143           & 116,26\%                                                           & 14                                                     & 678                                                    \\ \hline
    \multirow{2}{*}{Autorização de Internações Hospitalares}         & 2016    & 229      & 363           & 158,51\%                                                           & 2                                                      & 1.605                                                  \\
    & 2019    & 261      & 377           & 144,44\%                                                           & 4                                                      & 1.639                                                  \\ \hline
\end{tabular}\end{table}

여기에 이미지 설명을 입력하세요

댓글에서 언급했듯이 \multirow{2}{=}{...} 명령을 사용하여 문제를 해결하려고 했습니다.

그러나 이로 인해 아래 그림에서 볼 수 있듯이 선이 일부 겹치게 되었습니다.

여기에 이미지 설명을 입력하세요

답변1

*가 작동하지 않는 이유는 확실하지 않지만 너비를 추가하면 작동합니다(제 매뉴얼에는 =가 옵션으로 나열되지 않습니다). 또 다른 문제는 3cm가 열의 너비로는 충분하지 않지만 이미 페이지의 표에 맞추기에는 너무 넓다는 것입니다.

\documentclass{article}
\usepackage{multirow}

\begin{document}

\begin{table}[ht]% friends don't let friends use H
\centering
\setlength{\tabcolsep}{1pt}
\begin{tabular}{p{4cm}cccccc}
\hline
  Variável                                                         & Período & Média    & Desvio Padrão & \begin{tabular}[c]{@{}c@{}}Coeficiente \\ de variação\end{tabular} & \begin{tabular}[c]{@{}c@{}}Valor\\ Mínimo\end{tabular} & \begin{tabular}[c]{@{}c@{}}Valor\\ Máximo\end{tabular} \\ \hline
    \multirow{2}{4cm}{Leitos de UTI}                                   & 2016    & 1.867    & 2.505         & 134,17\%                                                           & 73                                                     & 11.039                                                 \\
    & 2019    & 2.016    & 2.738         & 135,81\%                                                           & 82                                                     & 12.515                                                 \\ \hline
    \multirow{2}{4cm}{Doadores Efetivos}                               & 2016    & 141      & 193           & 136,88\%                                                           & 5                                                      & 842                                                    \\
    & 2019    & 178      & 249           & 139,89\%                                                           & 4                                                      & 1.080                                                  \\ \hline
    \multirow{2}{4cm}{CIHDOTT’s}                                       & 2016    & 31       & 56            & 180,65\%                                                           & 1                                                      & 255                                                    \\
    & 2019    & 25       & 29            & 116,00\%                                                           & 1                                                      & 106                                                    \\ \hline
    \multirow{2}{4cm}{Equipes de Transplantes Renais}                  & 2016    & 6        & 8             & 133,33\%                                                           & 1                                                      & 35                                                     \\
    & 2019    & 7        & 8             & 114,29\%                                                           & 1                                                      & 31                                                     \\ \hline
    \multirow{2}{4cm}{Respiradores de emergência}                      & 2016    & 2.594    & 3.697         & 142,52\%                                                           & 121                                                    & 16.692                                                 \\
    & 2019    & 2.981    & 4.115         & 138,04\%                                                           & 152                                                    & 18.807                                                 \\\hline
    \multirow{2}{4cm}{Serviços de Neurocirurgia}                       & 2016    & 20       & 26            & 130,00\%                                                           & 3                                                      & 118                                                    \\
    & 2019    & 22       & 28            & 127,27\%                                                           & 4                                                      & 127                                                    \\ \hline
    \multirow{2}{4cm}{Valores totais pagos com Serviços Hospitalares}  & 2016    & 6.871,29 & 11.235,63     & 163,52\%                                                           & 41,79                                                  & 49.342,72                                              \\
    & 2019    & 8.071,96 & 12.114,82     & 150,08\%                                                           & 85,20                                                  & 54.430,50                                              \\ \hline
    \multirow{2}{4cm}{Valores totais pagos com Serviços Profissionais} & 2016    & 2.606,59 & 4.332,99      & 166,23\%                                                           & 16,72                                                  & 19.179,92                                              \\
    & 2019    & 3.074,86 & 4.657,82      & 151,48\%                                                           & 35,65                                                  & 20.285,42                                              \\ \hline
    \multirow{2}{4cm}{Recusa Familiar}                                 & 2016    & 120      & 140           & 116,67\%                                                           & 12                                                     & 656                                                    \\
    & 2019    & 123      & 143           & 116,26\%                                                           & 14                                                     & 678                                                    \\ \hline
    \multirow{2}{4cm}{Autorização de Internações Hospitalares}         & 2016    & 229      & 363           & 158,51\%                                                           & 2                                                      & 1.605                                                  \\
    & 2019    & 261      & 377           & 144,44\%                                                           & 4                                                      & 1.639                                                  \\ \hline
\end{tabular}\end{table}
\end{document}

데모

답변2

다음 솔루션은 사용하지 않습니다어느 \multirow지시문. 명시적 또는 암시적 소수 표시에 데이터 열의 숫자를 추가로 정렬합니다. 마지막으로, 훨씬 적지만 간격이 넉넉한 수평선을 사용하여 테이블에 더욱 개방적이고 매력적인 "모양"을 제공합니다.

여기에 이미지 설명을 입력하세요

\documentclass{article}
\usepackage[a4paper,margin=3cm]{geometry} % set page parameters as needed

\usepackage[T1]{fontenc}
\usepackage[portuguese]{babel} % or 'brazilian'?
\usepackage{lmodern}

\usepackage{amsmath,tabularx,booktabs}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcommand\mc[1]{\multicolumn{1}{@{}c@{}}{#1}} % handy shortcut macro
\newcommand\mytab[1]{%
   \begin{tabular}[t]{@{} c @{}} #1 \end{tabular}}
\newcommand\mytabx[1]{\smash[b]{%
   \begin{tabular}[t]{@{} L @{}} #1 \end{tabular}}}

\usepackage{dcolumn} % align numbers on decimal markers
\newcolumntype{d}[1]{D{,}{,}{#1}}

\begin{document}

\begin{table}[ht]

\begin{tabularx}{\textwidth}{@{} % target width: \textwidth
    L l d{4.2} d{5.2} c d{3.2} d{5.2} @{}}
\toprule
  Variável & 
  Período  & 
  \mc{\mytab{Média}} & 
  \mc{\mytab{Desvio\\Padrão}} &   
  \mytab{Coeficiente \\ de variação} & 
  \mc{\mytab{Valor\\ Mínimo}} & 
  \mc{\mytab{Valor\\ Máximo}} \\ 
\midrule
Leitos de UTI     
      & 2016    & 1.867    & 2.505 & 134,17\% & 73 & 11.039 \\
      & 2019    & 2.016    & 2.738 & 135,81\% & 82 & 12.515 \\ 
\addlinespace
Doadores Efetivos 
      & 2016    & 141      & 193   & 136,88\% & 5  & 842    \\
      & 2019    & 178      & 249   & 139,89\% & 4  & 1.080  \\ 
\addlinespace
CIHDOTT’s         
      & 2016    & 31       & 56    & 180,65\% & 1  & 255    \\
      & 2019    & 25       & 29    & 116,00\% & 1  & 106    \\ 
\addlinespace
\mytabx{Equipes de Transplantes Renais} 
      & 2016    & 6        & 8     & 133,33\% & 1  & 35     \\
      & 2019    & 7        & 8     & 114,29\% & 1  & 31     \\ 
\addlinespace
\mytabx{Respiradores de emergência} 
      & 2016    & 2.594    & 3.697 & 142,52\% & 121 & 16.692\\
      & 2019    & 2.981    & 4.115 & 138,04\% & 152 & 18.807\\ 
\addlinespace
\mytabx{Serviços de Neurocirurgia}
      & 2016    & 20       & 26    & 130,00\% & 3   & 118   \\
      & 2019    & 22       & 28    & 127,27\% & 4   & 127   \\ 
\addlinespace
\mytabx{Valores totais pagos com Serviços Hospitalares} 
      & 2016    & 6.871,29 & 11.235,63 & 163,52\% & 41,79 & 49.342,72  \\
      & 2019    & 8.071,96 & 12.114,82 & 150,08\% & 85,20 & 54.430,50  \\ 
\addlinespace
\mytabx{Valores totais pagos com Serviços Profissionais} 
      & 2016    & 2.606,59 & 4.332,99 & 166,23\% & 16,72 & 19.179,92 \\
      & 2019    & 3.074,86 & 4.657,82 & 151,48\% & 35,65 & 20.285,42 \\ 
\addlinespace
Recusa Familiar   
      & 2016    & 120      & 140      & 116,67\% & 12    & 656   \\
      & 2019    & 123      & 143      & 116,26\% & 14    & 678   \\ 
\addlinespace
\mytabx{Autorização de Internações Hospitalares} 
      & 2016    & 229      & 363      & 158,51\% & 2     & 1.605 \\
      & 2019    & 261      & 377      & 144,44\% & 4     & 1.639 \\ 
\bottomrule
\end{tabularx}

\end{table}

\end{document}

관련 정보