
我的目標是為 Word 中建立的下表編寫 Latex 程式碼。
但是,我無法格式化第一列。我想為列寬定義一定的測量值,如果寬度太小,此命令會產生自動換行,此外,我希望文字在合併的兩個單元格之間居中。
\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}