
Mein Ziel war, Latex-Code für die folgende in Word erstellte Tabelle zu schreiben.
Allerdings gelingt es mir nicht, die erste Spalte zu formatieren. Ich möchte ein bestimmtes Maß für die Spaltenbreite festlegen und mit diesem Befehl einen automatischen Zeilenumbruch erzeugen lassen, wenn die Breite zu gering ist. Außerdem möchte ich, dass der Text zwischen den beiden zusammengeführten Zellen zentriert wird.
\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}
Wie in den Kommentaren erwähnt, habe ich versucht, das Problem mit dem Befehl \multirow{2}{=}{...} zu lösen.
Dies führte jedoch zu einer gewissen Überlappung der Linien, wie Sie in der Abbildung unten sehen können.
Antwort1
Ich bin mir nicht sicher, warum * nicht funktioniert, aber das Hinzufügen der Breite funktioniert (in meinem Handbuch ist = nicht als Option aufgeführt). Das andere Problem ist, dass 3 cm für die Spalte nicht breit genug sind, aber bereits zu breit, um die Tabelle auf die Seite zu bringen.
\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}
Antwort2
Die folgende Lösung verwendet nichtbeliebig \multirow
Anweisungen. Außerdem werden die Zahlen in den Datenspalten an ihren expliziten oder impliziten Dezimaltrennzeichen ausgerichtet. Schließlich verleiht es der Tabelle ein offeneres und einladenderes „Aussehen“, indem weitaus weniger, aber dafür gut verteilte horizontale Linien verwendet werden.
\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}