我正在尝试在乳胶中复制该表。
但是,我无法正确排版它。
结果如下:
所有月份都混乱了,我似乎无法使它们全部大小相同。
这是我目前拥有的代码:
\documentclass[11pt,a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}
\usepackage[left=3.00cm, right=3.00cm, top=2.50cm, bottom=2.50cm]{geometry}
\usepackage{booktabs,multirow,array,ragged2e,float,graphicx}
\begin{document}
\begin{table}[H]
\centering
\label{tab:501}%
\resizebox{\textwidth}{!}{%
\def\arraystretch{1.3}
\begin{tabular}{@{}p{1,5cm}|p{1,5cm}|p{1,5cm}|p{1,5cm}|p{1,5cm}|p{1,5cm}|p{1,5cm}|p{1,5cm}|p{1,5cm}|p{1,5cm}|p{1,5cm}|p{1,5cm}|p{1,5cm}|@{}}
\cmidrule(l){2-13}
& \textbf{Jan} & \textbf{Fev} & \textbf{Mar} & \textbf{Abr} & \textbf{Mai} & \textbf{Jun} & \textbf{Jul} & \textbf{Ago} & \textbf{Set} & \textbf{Out} & \textbf{Nov} & \textbf{Dez} \\ \midrule
\multicolumn{1}{|c|}{\textbf{2013}} & \multicolumn{12}{c|}{\begin{tabular}[c]{@{}c@{}}Medicina Interna\\ HSM\end{tabular}} \\ \midrule
\multicolumn{1}{|c|}{\textbf{2014}} & \multicolumn{12}{c|}{\begin{tabular}[c]{@{}c@{}}Endocrinologia, Diabetes, Metabolismo e Nutrição\\ HSM\end{tabular}} \\ \midrule
\multicolumn{1}{|c|}{\textbf{2015}} & \multicolumn{2}{c|}{\begin{tabular}[c]{@{}c@{}}Laboratório de Endocrinologia\\ HSM\end{tabular}} & \multicolumn{2}{c|}{\begin{tabular}[c]{@{}c@{}}Endocrinologia Pediátrica\\ HSM\end{tabular}} & \multicolumn{8}{c|}{\begin{tabular}[c]{@{}c@{}}Endocrinologia, Diabetes, Metabolismo e Nutrição\\ HSM\end{tabular}} \\ \midrule
\multicolumn{1}{|c|}{\textbf{2016}} & \multicolumn{4}{c|}{\begin{tabular}[c]{@{}c@{}}Endocrinologia, Diabetes, Metabolismo e Nutrição\\ HSM\end{tabular}} & \multicolumn{3}{c|}{\begin{tabular}[c]{@{}c@{}}Medicina Nuclear Oncologia Tiroideia\\ IPOLFG\end{tabular}} & \multicolumn{2}{c|}{\begin{tabular}[c]{@{}c@{}}Imagiologia\\ HSM\end{tabular}} & \multicolumn{3}{c|}{Endocrinologia da Reprodução HSM} \\ \midrule
\multicolumn{1}{|c|}{\textbf{2017}} & \multicolumn{5}{c|}{Endocrinologia, Diabetes, Metabolismo e Nutrição HSM} & \multicolumn{2}{c|}{Endocrinologia Diabetes e Metabolismo EMC} & \multicolumn{5}{c|}{Endocrinologia, Diabetes, Metabolismo e NutriçãoHSM} \\ \bottomrule
\end{tabular}}
\end{table}
\end{document}
我尝试过使用其他软件包,但最终结果通常与上面的类似。是否有任何神奇的软件包可以完成此类任务?
提前致谢。
答案1
您需要相当大的文本宽度才能制作出像样的表格。
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[brazil]{babel}
\usepackage[margin=1cm]{geometry}
\usepackage{array}
\newlength{\monthwidth}
\newlength{\yearwidth}
\AtBeginDocument{% after fonts have been set
\settowidth{\yearwidth}{\textbf{0000}}%
\setlength{\monthwidth}{\dimexpr(\textwidth-\yearwidth-26\tabcolsep-14\arrayrulewidth)/12\relax}%
}
\newcommand{\multicell}[2]{% #1 = cols to span, #2 = contents
\multicolumn{#1}{c|}{%
\parbox{\dimexpr#1\monthwidth+\numexpr2*(#1-2)\relax\tabcolsep+\numexpr#1-1\relax\arrayrulewidth\relax}{%
\centering\vspace*{3pt}\hspace{0pt}#2\par\vspace*{3pt}%
}%
}%
}
\begin{document}
\begin{center}
\footnotesize
\begin{tabular}{ |p{\yearwidth}| *{12}{>{\centering\arraybackslash}p{\monthwidth}|} }
\cline{2-13}
\multicolumn{1}{c|}{}
& \textbf{Jan} & \textbf{Fev} & \textbf{Mar} & \textbf{Abr} & \textbf{Mai} & \textbf{Jun}
& \textbf{Jul} & \textbf{Ago} & \textbf{Set} & \textbf{Out} & \textbf{Nov} & \textbf{Dez} \\
\hline
\textbf{2013} & \multicell{12}{Medicina Interna\\ HSM} \\
\hline
\textbf{2014} & \multicell{12}{Endocrinologia, Diabetes, Metabolismo e Nutrição \\ HSM} \\
\hline
\textbf{2015} & \multicell{2}{Laboratório de Endocrinologia \\ HSM}
& \multicell{2}{Endocrinologia Pediátrica \\ HSM}
& \multicell{8}{Endocrinologia, Diabetes, Metabolismo e Nutrição \\ HSM} \\
\hline
\textbf{2016} & \multicell{4}{Endocrinologia, Diabetes, Metabolismo e Nutrição \\ HSM}
& \multicell{3}{Medicina Nuclear Oncologia Tiroideia \\ IPOLFG}
& \multicell{2}{Imagiologia \\ HSM}
& \multicell{3}{Endocrinologia da Reprodução \\ HSM} \\
\hline
\textbf{2017} & \multicell{5}{Endocrinologia, Diabetes, Metabolismo e Nutrição \\ HSM}
& \multicell{2}{Endocrinologia Diabetes e Metabolismo \\ EMC}
& \multicell{5}{Endocrinologia, Diabetes, Metabolismo e Nutrição \\ HSM} \\
\hline
\end{tabular}
\end{center}
\end{document}