49

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

4

5 に答える 5

39

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}

于 2009-04-06T20:01:09.913 に答える
23

Latex: 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}
于 2011-07-08T15:09:23.240 に答える
17

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

于 2009-11-04T12:58:11.227 に答える
5

Figure では、Figure 環境にadjustwidthenv. が含まれている必要があります。さらに、captionFigure 全体の幅に合わせて、この環境の外に残す必要があります。

\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}
于 2011-02-15T17:41:41.603 に答える
1

複数列のドキュメントを使用していますか? table*では、バリアント環境を考えてみましょう。

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

  • を増やしますtextwidth。しかし、デフォルトのマージンは人間工学的な理由から選択されたものであるため、最小限の調整を超えてこれをやめさせることはお勧めしません。
  • テーブル内のテキスト サイズを小さくします (つまり、環境内で\smallも)。繰り返しますが、これは最適とは言えません。\footnotesizetabular
  • Stephan202が提供したリンクで提案されているrotatingパッケージを使用してください。私はこれを私の学位論文のいくつかの非常に大きなテーブル (配置オプションのみ) に使用しましたが、非常にうまくいきました。p
于 2009-04-06T20:00:33.830 に答える