使表格比文本列更宽

时间:2009-04-06 18:27:10

标签: latex center

我在我的LaTeX文档中包含一个表格,如果表格不比上面的文本列宽,则居中工作正常,但是当表格较宽时,表格的左侧贴在左侧对于文本列,表的附加宽度位于页面的右侧,如何使表格居中?

5 个答案:

答案 0 :(得分:33)

我建议您尝试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环境中   左右边距可以   调整。环境需要一个   可选参数和两个必需   长度参数:

     

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

A positive length value will increase the relevant margin
     

(缩短文本行)而a   负长度值将减少   边距(加长文字线)。   空长度参数表示否   改为保证金。在......的最后   边际所回归的环境   他们的原始价值。

     

例如,扩展文本   进入右边缘:

     

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

     

可选的任何外观   参数(即使只是[])将导致   要切换的边距值   在奇数页和偶数页之间。

     

如果正在设置文档   它可能是有利的   有更广泛的文字延伸到   外边距。这可以通过   可选参数,如:

     

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

     

要调整文本   相对于水平居中   任何周围的文字,边距   应该平等调整:

     

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

答案 1 :(得分:16)

如果您使用\ table float,则必须在其中包含\ begin {adjustwidth} ... \ end {adjustwidth}。

答案 2 :(得分:13)

胶乳:居中表大于文字宽度

通常,您可以使用\ 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}

答案 3 :(得分:3)

在图中,图形环境必须包含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}

答案 4 :(得分:1)

您使用的是多列文档吗?我是这样,考虑table*变体环境。

在单列环境中,您的选项将运行到:

  • 增加textwidth。但是出于良好的人体工程学原因选择了默认保证金,因此不鼓励超出最小限度的调整。
  • 缩小表格中的文字大小(即\small环境中的\footnotesize甚至tabular。同样,这不是最佳的。
  • 根据rotating package中的建议使用the link Stephan202 gave。我在论文中使用了几个非常大的表(只有p定位选项)并且它非常好。