将列宽设置为点

将列宽设置为点

我目前有一个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}

在此处输入图片描述

编辑: 感谢 Mico,我重新考虑了我的答案。上述示例仅在第二列单元格中只有一行时才有效。如果这些单元格中的文本较长,则可能的解决方案是将表格放在表格中:

\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 总是在页面(文本)的中间完成。

相关内容