
我希望右欄中的文字片段更接近左欄中的文字片段。同時,我希望表格能夠像現在一樣很好地容納長文本。實現此結果的一種方法是限制左列的寬度,增加右列的寬度,並將右列的左邊距向左移動。但我不知道該怎麼做。
\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}