为了写一篇论文,我有一些非常大的表格。我无法将数字放入方框内,因此我使用了 pbox。问题是,现在方框内的数字分布不均匀,并且行与行之间有太多的可用空间。有没有仍然使用 pbox 的解决方案?
\usepackage{multirow}
\usepackage{pbox}
\usepackage{caption}
\begin{table}[h]
\begin{tabular}{|l|l|l|l|l|}
\hline
\multicolumn{2}{|l|}{SOME TEXT HERE} & \multicolumn{3}{l|}{Big title that takes the whole page} \\ \hline
\multicolumn{2}{|l|}{MORE TEXT} & number & number & number \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number & number & number \\ \hline
some title here & value &\pbox{25cm}{12341 538768 \\ 23423 22}& \pbox{25cm}{12341 538768 \\ 23423 22} & \pbox{25cm}{12341 538768 \\ 23423 22} \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number & number & number \\ \hline
some title here & value & \pbox{25cm}{12341 538768 \\ 23423 228}& \pbox{25cm}{12341 538768 \\ 23423 22} & \pbox{25cm}{12341 538768 \\ 23423 22} \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number & number & number \\ \hline
some title here & value l & \pbox{25cm}{12341 538768 \\ 23423 22}& \pbox{25cm}{12341 538768 \\ 23423 22} & \pbox{25cm}{12341 538768 \\ 23423 22} \\ \hline
\end{tabular}
\captionof{table}{There should be proper caption.}
\end{table}
下面我附上了一张显示当前结果的图片:
答案1
您可以使用该makecell
包来实现此目的:它允许在某些单元格中使用换行符和常见格式,使用\makecell
和\thead
命令:
\documentclass[a4paper]{article}
\usepackage{array}
\usepackage{makecell}
\renewcommand\cellalign{lc}
\setcellgapes{3pt}
\makegapedcells
\begin{document}
\begin{table}[htp]
\begin{tabular}{|*{5}{l|}}
\hline
\multicolumn{2}{|l|}{SOME TEXT HERE} & \multicolumn{3}{l|}{Big title that takes the whole page} \\ \hline
\multicolumn{2}{|l|}{MORE TEXT} & number & number & number \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number & number & number \\ \hline
some title here & value &\makecell{12341 538768 \\ 23423 22}& \makecell{12341 538768 \\ 23423 22} & \makecell{12341 538768 \\ 23423 22} \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number & number & number \\ \hline
some title here & value & \makecell{12341 538768 \\ 23423 228}& \makecell{12341 538768 \\ 23423 22} & \makecell{12341 538768 \\ 23423 22} \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number & number & number \\ \hline
some title here & value l & \makecell{12341 538768 \\ 23423 22}& \makecell{12341 538768 \\ 23423 22} & \makecell{12341 538768 \\ 23423 22} \\ \hline
\end{tabular}
\caption{There should be proper caption.}
\end{table}
\end{document}
答案2
pbox
似乎对你没什么帮助,我只会使用tabular
\documentclass[a4paper]{article}
\usepackage{array}
\setlength\extrarowheight{2pt}
\begin{document}
\newcommand\pb[1]{%
\begin{tabular}{@{}l@{}}#1\end{tabular}}
\begin{table}[htp]
\begin{tabular}{|l|l|l|l|l|}
\hline
\multicolumn{2}{|l|}{SOME TEXT HERE} & \multicolumn{3}{l|}{Big title that takes the whole page} \\ \hline
\multicolumn{2}{|l|}{MORE TEXT} & number & number & number \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number & number & number \\ \hline
some title here & value &\pb{12341 538768 \\ 23423 22}& \pb{12341 538768 \\ 23423 22} & \pb{12341 538768 \\ 23423 22} \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number & number & number \\ \hline
some title here & value & \pb{12341 538768 \\ 23423 228}& \pb{12341 538768 \\ 23423 22} & \pb{12341 538768 \\ 23423 22} \\ \hline
\multicolumn{2}{|l|}{ANOTHER TEXT} & number & number & number \\ \hline
some title here & value l & \pb{12341 538768 \\ 23423 22}& \pb{12341 538768 \\ 23423 22} & \pb{12341 538768 \\ 23423 22} \\ \hline
\end{tabular}
\caption{There should be proper caption.}
\end{table}
\end{document}