2009-04-06 11 views
29

私はLaTeXドキュメントにテーブルを含めていますが、その上のテキスト列よりもテーブルが広くない場合はセンタリングがうまく動作しますが、テーブルが広い場合は左側テーブルの幅がテキストの左側に張り付いていて、テーブルの幅がページの右側にある場合、どのようにテーブルを中央に置くことができますか?テキスト列よりも幅の広いテーブルのセンタリング

答えて

1

複数の列のドキュメントを使用していますか?私はtable*変種環境を考えています。

に実行し、あなたのオプションは、単一の列環境で

  • textwidthを増やします。しかし、人間工学上の理由からデフォルトマージンが選定されていたので、これは最小限の微調整を超えて推奨されません。
  • テーブル内のテキストサイズを小さくしてください(環境内の\small、さらには\footnotesize)。再び、これは最適ではありません。
  • rotating packageは、the link Stephan202 gaveで提案されているとおりに使用してください。私は私の論文の中で非常に大きなテーブルのいくつかにこれを使用しました(pポジショニングオプションのみ)、それは非常にきれいに出てきました。
31

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.styファイルの一番下に位置していますchngpageパッケージのドキュメント。左右の余白が を調整することができますadjustwidth環境 内

:私はadjustwidth環境のためにドキュメントを引き抜いてきました。 負の長さの値は、(テキスト行を長く) マージンを減少する一方

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

A positive length value will increase the relevant margin 

(テキスト行を短くする):環境は、1つの オプションの引数と2つの必要な 長さの引数を取ります。 空の長さの引数は、 が余白に変更されないことを意味します。 の最後に、余白は に元の値に戻ります。右余白にテキスト を延長する例えば

、:

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

オプション 引数(だけでも、[])のいずれも外観はマージンの 値の間 を切り替えることになります奇数ページと偶数ページ。

文書が に設定されている場合、 には、余白の外側にある に広がる任意の幅広いテキストがあると便利です。このとして、 を介してオプションの引数を行うことができる:

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

が水平 任意の周囲のテキストに対して中心調整テキスト を有するように、マージン が等しく調整されるべきである:

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

+2

偉大な答えです。 1つの注意点:代わりに新しい "changepage"パッケージを使用する方が良いでしょう。これはほぼ同じですが、回想師クラスと同じインターフェースを使用しています。すべて同じ著者による。 –

+0

それは本当です。しかし、 'changepage'パッケージは新しいものなので、LaTeXのすべてのディストリビューションが付属しているので、ここで' chngpage'パッケージを使用しました。 Zequjに対して、 'adjustwidth'環境の構文は' chngpage'と 'changepage'パッケージの間で少し異なります。 – godbyk

+1

これは長いテーブルでも有効でしょうか? – Johnus

13

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

2

の図に、figure環境がadjustwidth ENVが含まれている必要があり、追加することが重要では...さらに、captionは、図の全体の幅に合わせて、この環境の外に残されるべきである。

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

6

ラテックス:テキスト幅より大きなセンタリングテーブル

通常、\ 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} 
+2

十分に文書化されたソースへの外部参照を含めることはStack Overflowで評価されますが、外部ソースからの最も重要な/関連するスニペットを回答に含めることが重要です。死んでしまう(サーバーがダウンするなど)、あなたの答えは役に立たなくなる。 – mbinette

関連する問題