我已经花了两天时间尝试为我的 Latex 表格中的某些单元格(包含更多文本的单元格)添加顶部和底部边距。我找不到解决方案。这是我拥有的代码。
\documentclass{article}
\usepackage[landscape,margin=2cm]{geometry}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{tabu}
\newcommand\xrowht[2][0]{\addstackgap[.5\dimexpr#2\relax]{\vphantom{#1}}}
\begin{document}
\begin{table}
\centering
\begin{tabu}{|X[2]|X[10]|X[2]|X[7]|X|
X|X|X|X|X|X|X|X|X|X|X|X|X|X|X|}
\hline
\rotatebox{90}{Id. number 1} &
number 1 &
\rotatebox{90}{Id. n2} &
number 2&
\rotatebox{90}{Esfuerzo p-d} &
\rotatebox{90}{Día 1} &
\rotatebox{90}{Día 2} &
\rotatebox{90}{Día 3} &
\rotatebox{90}{Día 4} &
\rotatebox{90}{Día 5} &
\rotatebox{90}{Día 6} &
\rotatebox{90}{Día 7} &
\rotatebox{90}{Día 8} &
\rotatebox{90}{Día 9} &
\rotatebox{90}{Día 10} &
\rotatebox{90}{Día 11} &
\rotatebox{90}{Día 12} &
\rotatebox{90}{Día 13} &
\rotatebox{90}{Día 14} &
\rotatebox{90}{Día 15}\\
\hline
\multirow[c]{6}{=}{COM-HU01} &
\multirow[c]{6}{=}{This is a cell with a lot of information that have to be in a paragraph style in the table} &
01-01 & Do some things also in a semi-pharagraph style &
2 & & & 2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ \cline{3-20}
& & 01-02 & Some other things
& 2 & & 1 & & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \cline{3-20}
& & 01-03 & To do number three
& 3 & & & & & & & & 1 & 2 & 0 & 0 & 0 & 0 & 0 & 0 \\ \cline{3-20}
& & 01-04 & To do number four
& 1 & & & & & & & & & & & & & & & \\ \cline{3-20}
& & 01-05 & To do number five
& 2 & & & & & & & & & & & & & & & \\ \cline{3-20}
& & 01-06 & Another semi pharagraph style cell
& 3 & & & & & & & & 1 & & & & & & & \\ \hline
\end{tabu}
\end{table}
\end{document}
提前谢谢您。PD:如果有任何方法可以让所有单元格垂直居中,我也会很感激
答案1
这是我tabularx
针对X
类型列、makecell
旋转列标题、cellspace
文本和水平线之间的额外空白、\newcolumntype{L}{>{\raggedright\arraybackslash}X}
左对齐新定义的L
类型列的内容以及\renewcommand\tabularxcolumn[1]{m{#1}}
垂直居中内容提出的建议:
\documentclass{article}
\usepackage[landscape,margin=2cm]{geometry}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{cellspace}
\addparagraphcolumntypes{X}
\setlength\cellspacetoplimit{10pt}
\setlength\cellspacebottomlimit{\cellspacetoplimit}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\renewcommand\tabularxcolumn[1]{m{#1}}
\begin{document}
\begin{table}
\settowidth\rotheadsize{\theadfont Id. number 1}
\renewcommand\cellrotangle{90}
\begin{tabularx}{\textwidth}{|S{c}|S{L}|S{c}|L|*{16}{S{c}|}}
\hline
\rothead{Id. number 1} &
number 1 &
\rothead{Id. n2} &
number 2&
\rothead{Esfuerzo p-d} &
\rothead{Día 1} &
\rothead{Día 2} &
\rothead{Día 3} &
\rothead{Día 4} &
\rothead{Día 5} &
\rothead{Día 6} &
\rothead{Día 7} &
\rothead{Día 8} &
\rothead{Día 9} &
\rothead{Día 10} &
\rothead{Día 11} &
\rothead{Día 12} &
\rothead{Día 13} &
\rothead{Día 14} &
\rothead{Día 15}\\
\hline
\multirow[c]{12.5}{*}{\makecell{COM-\\HU01}} &
\multirow[c]{12.5}{=}{This is a cell with a lot of information that have to be in a paragraph style in the table} &
01-01 & Do some things also in a semi-pharagraph style &
2 & & & 2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ \cline{3-20}
& & 01-02 & Some other things
& 2 & & 1 & & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \cline{3-20}
& & 01-03 & To do number three
& 3 & & & & & & & & 1 & 2 & 0 & 0 & 0 & 0 & 0 & 0 \\ \cline{3-20}
& & 01-04 & To do number four
& 1 & & & & & & & & & & & & & & & \\ \cline{3-20}
& & 01-05 & To do number five
& 2 & & & & & & & & & & & & & & & \\ \cline{3-20}
& & 01-06 & Another semi pharagraph style cell
& 3 & & & & & & & & 1 & & & & & & & \\ \hline
\end{tabularx}
\end{table}
\end{document}