列幅をポイントに設定する

列幅をポイントに設定する

現在、4 つの列を持つテーブルがありますtabularx。環境を次のように初期化します。

\begin{tabularx}{\linewidth}{l p{0.4\linewidth} | l X l X}

p{0.4\linewidth}2 番目の列 ( ) がページの中央を超えないようにするには、どうすればよいでしょうか。

答え1

連続する2つのテーブルですか?

\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 のおかげで、回答を再考できました。上記の例は、2 列目のセルに 1 行しかない場合にのみ機能します。それらのセルに長いテキストがある場合、テーブル内にテーブルを配置することが解決策となります。

\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}

ここに画像の説明を入力してください

正直に言うと、もう確信が持てません。2 番目のシルが常にページ (テキスト) の中央で終了するのが好きなら、そうすべきです。

関連情報