控制表格环境中列的宽度

控制表格环境中列的宽度

我希望右列中的文本片段更接近左列中的文本片段。同时,我希望表格能够很好地容纳长文本片段,就像现在这样。实现此结果的一种方法是限制左列的宽度,增加右列的宽度,并将右列的左边距向左移动。但我不知道该怎么做。

以下是我目前所得到的 MWE桌子

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}

\begin{document}

\begin{table}
 \centering
 \begin{tabular}{*{2}{p{.425\linewidth}}}
  \toprule
  first &  second second second second second second second second second second\\
  \midrule
  third & fourth fourth fourth fourth fourth fourth fourth fourth fourth fourth \\
  \bottomrule
 \end{tabular}
\end{table}

\end{document}

感谢您的帮助。

答案1

据我理解这个问题,我会尝试

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}

\begin{document}
\begin{table}
 \centering
 \begin{tabular}{l p{0.5\linewidth}}
  \toprule
  first &  second second second second second second second second second second\\
  \midrule
  third & fourth fourth fourth fourth fourth fourth fourth fourth fourth fourth \\
  \bottomrule
 \end{tabular}
\end{table}
\end{document}

获得

在此处输入图片描述

答案2

正如 @Werner 在评论中指出的那样,对于您的格式化目标,一个很好的候选解决方案是加载包tabularx并使用tabularx环境(将整体宽度设置为\textwidth)而不是tabular。然后,将第一列规范从更改为p{...}l并将第二列规范从更改p{...}X

在此处输入图片描述

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs}
\usepackage{tabularx} % for "tabularx" env. and "X" column type

\begin{document}

\begin{table}
\begin{tabularx}{\textwidth}{@{} l X @{}}
  \toprule
  first & second second second second second second second 
          second second second second second second second second \\
  \midrule
  third & fourth fourth fourth fourth fourth fourth fourth fourth 
          fourth fourth fourth fourth \\
  \bottomrule
\end{tabularx}
\end{table}

\end{document} 

相关内容