格式化表格中的 pbox 以使文本分布整齐

格式化表格中的 pbox 以使文本分布整齐

为了写一篇论文,我有一些非常大的表格。我无法将数字放入方框内,因此我使用了 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}

相关内容