
我目前有一個tabularx
有四列的表格。我這樣初始化環境:
\begin{tabularx}{\linewidth}{l p{0.4\linewidth} | l X l X}
我該如何更改此設置,以便第二列 ( p{0.4\linewidth}
) 延伸到頁面中心,但不超過頁面中心?
答案1
有兩個連續的表?
\documentclass{article}
\usepackage{tikz}
%---------------------------------------------------------------%
\usepackage{booktabs,tabularx,calc}
\usepackage[active,floats,tightpage]{preview}
\setlength\PreviewBorder{1em}
\begin{document}
\begin{table}
\begin{tabularx}{0.5\linewidth}{lX@{}} %%% first table
\hline
1. column & 2. column \\
1. column & 2. column \\
\hline
\end{tabularx}%
\begin{tabularx}{0.5\linewidth}{|lXX} %%% second table
\hline
3. column & 4. column & 5.column \\
3. column & 4. column & 5.column \\
\hline
\end{tabularx}
\end{table}
\end{document}
編輯: 感謝米科,我重新考慮了我的答案。只有當第二列單元格中只有一行時,上述範例才有效。如果這些儲存格中的文字較長,可能的解決方案是將表格放入表格中:
\documentclass{article}
%---------------------------------------------------------------%
\usepackage{booktabs,tabularx,calc}
\usepackage[active,floats,tightpage]{preview}
\setlength\PreviewBorder{1em}
\begin{document}
\begin{table}
\begin{tabularx}{\linewidth}{@{}l|lXX}
\hline
{\begin{tabularx}{0.5\linewidth}{lX} %%% first table in table
1. & 2. column, but this doesn't work,
if the content of this cell is very long,
i.e. spread over more line
\end{tabularx}}
& 3. & 4. column & 5. column \\
\hline
{\begin{tabularx}{0.5\linewidth}{lX} %%% second table in table
1. & 2. column, with short text
\end{tabularx}}%
& 3. & 4. column & this column also can has
longer text span over more lines\\
\hline
\end{tabularx}
\end{table}
\end{document}
現在我必須承認,我不再確定,如果你喜歡第二個 cill 總是在頁面中間完成(文字)。