web-dev-qa-db-ja.com

テキスト列よりも幅の広いテーブルの中央揃え

LaTeXドキュメントにテーブルを含めていますが、テーブルがその上のテキスト列よりも広くない場合、センタリングはうまく機能しますが、テーブルが広い場合、テーブルの左側がテキストの左側に固定されます列、およびテーブルの追加幅がページの右側にある場合、どのようにテーブルを中央に配置できますか?

37
Zequj

chngpage パッケージを試すことをお勧めします。

\documentclass{article}

% allows for temporary adjustment of side margins
\usepackage{chngpage}

% provides filler text
\usepackage{lipsum}

% just makes the table prettier (see \toprule, \bottomrule, etc. commands below)
\usepackage{booktabs}

\begin{document}

\lipsum[1]% just a paragraph of filler text

\medskip% adds some space before the table
\begin{adjustwidth}{-1in}{-1in}% adjust the L and R margins by 1 inch
  \begin{tabular}{ll}
    \toprule
    Sequence & Wide column \\
    \midrule
    First & Vestibulum porta ultricies felis. In nec mi. \\
    Second & Nam vestibulum auctor nibh. In eleifend, 
    lacus id tristique ullamcorper, mauris urna convallis elit. \\
    Third & Ut luctus nisi quam lobortis magna. Aenean sit amet odio 
   et sapien rutrum lobortis. \\ 
    Fourth & Integer dictum accumsan purus. Nullam erat ligula,
    dictum sed, feugiat nec, faucibus id, ipsum. \\
    \bottomrule
  \end{tabular}
\end{adjustwidth}
\medskip% adds some space after the table

\noindent\lipsum[2]% just a paragraph of filler text

\end{document}

chngpageパッケージのドキュメントは、chngpage.styファイルの下部にあります。 adjustwidth環境のドキュメントを引き出しました:

Adjustwidth環境内で、左右のマージンを調整できます。環境は、1つのオプションの引数と2つの必須の長さ引数を取ります。

\begin{adjustwidth}[]{leftmargin}{rightmargin}

A positive length value will increase the relevant margin

(テキスト行を短くする)、負の長さの値はマージンを減らす(テキスト行を長くする)。長さの引数が空の場合、マージンは変更されません。環境の最後で、マージンは元の値に戻ります。

たとえば、テキストを右マージンに拡張するには:

\begin{adjustwidth}{}{-8em}

オプションの引数が現れると([]だけでも)、余白の値が奇数ページと偶数ページの間で切り替わります。

文書を両面に設定する場合、幅の広いテキストを外側の余白まで広げると有利な場合があります。これは、次のようにオプションの引数を介して実行できます。

\begin{adjustwidth}[]{}{-8em}

調整されたテキストを周囲のテキストに対して水平方向に中央揃えするには、余白を均等に調整する必要があります。

\begin{adjustwidth}{-4em}{-4em}

33
godbyk

\ table floatを使用している場合、\ begin {adjustwidth} ...\end {adjustwidth}をその中に含める必要があります。

16
db.

ラテックス:textwidthより大きいセンタリングテーブル

通常、テーブルは\ centerで中央揃えできます。ただし、テーブルが\ textwidthより長い場合、左側の余白に揃えられます。テキスト幅を一時的に調整できます。

% allows for temporary adjustment of side margins
\usepackage{chngpage}

\begin{table}
    \begin{adjustwidth}{-.5in}{-.5in}  
        \begin{center}
        \begin{tabular}{|c|}
            \hline
And here comes a very long line. And here comes a very long line. And here comes a very long line.  \\
            \hline
        \end{tabular} 

        \caption{This Table is longer than the text width. And its caption is really long, too. This Table is longer than the text width. And its caption is really long, too. This Table is longer than the text width. And its caption is really long, too. This Table is longer than the text width. }
        \label{myTable}
        \end{center}
    \end{adjustwidth}
\end{table}
16
user835611

図では、図環境にadjustwidth env。が含まれている必要があります。さらに、captionはこの図の外側に残して、図全体の幅に合わせる必要があります。

\begin{figure}[h]
  \begin{adjustwidth}{-1in}{-1in}% adjust the L and R margins by 1 inch
    \centering
    \includegraphics[scale=0.44]{res/sth.png}
  \end{adjustwidth}
  \caption{sth}
  \label{fig:sth}
\end{figure}
3
juanmirocks

複数列のドキュメントを使用していますか?だから、table*バリアント環境。

単一列環境では、オプションは次のように実行されます。

  • textwidthを増やします。ただし、デフォルトのマージンは、人間工学的な理由から選択されているため、最小限の調整以外にはお勧めできません。
  • テーブル内のテキストサイズを小さくします(つまり、\small あるいは \footnotesizetabular環境内)。繰り返しますが、これは最適ではありません。
  • Stephan202が提供したリンク で提案されているように rotating package を使用します。私は論文のいくつかの非常に大きなテーブル(p位置決めオプションのみ)にこれを使用し、非常にうまくいきました。
1
dmckee