使表格比文本列更宽

Zeq*_*quj 38 latex center

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

god*_*byk 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}
Run Code Online (Sandbox Code Playgroud)

chngpage包的文档位于chngpage.sty文件的底部.我已经拿出了adjustwidth环境文档:

在调整宽度环境中,可以调整左右边距.环境采用一个可选参数和两个必需长度参数:

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

A positive length value will increase the relevant margin
Run Code Online (Sandbox Code Playgroud)

(缩短文本行),而负长度值将减少边距(延长文本行).空长度参数表示不会更改边距.在环境结束时,边距恢复到原始值.

例如,要将文本扩展到右边距:

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

任何可选参数的出现(即使只是[])都会导致边距值在奇数页和偶数页之间切换.

如果正在设置文档,那么将任何更宽的文本扩展到外边距可能是有利的.这可以通过可选参数来完成,如:

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

要使调整后的文本相对于任何周围文本水平居中,应平均调整边距:

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

  • 很好的答案.一个警告:你最好使用更新的"changepage"包,它几乎相同,但使用与回忆录类相同的界面.全部由同一作者. (2认同)

小智 16

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


use*_*611 16

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}
Run Code Online (Sandbox Code Playgroud)

  • 在Stack Overflow中可以看到包含对文档记录源的外部引用,但重要的是在答案中包含来自外部源的最重要/相关的片段,并提供如何回答问题的上下文,因为如果该链接已经死亡(服务器停机等),那么你的答案就变得毫无用处. (2认同)

jua*_*cks 5

在图中,图形环境必须包含adjustwidthenv.。此外,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}
Run Code Online (Sandbox Code Playgroud)


dmc*_*kee 1

您使用的是多列文档吗?我所以,考虑一下table*不同的环境。

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

  • 增加textwidth。但选择默认边距是出于良好的人体工程学原因,因此除了最小的调整之外,不鼓励这样做。
  • 减小表格中的文本大小(即\small甚至环境\footnotesize内部tabular)。同样,这也不是最佳的。
  • 按照Stephan202 给出的链接中的建议使用该rotating。我在论文中使用了几个非常大的表格(只有定位选项),结果非常好。p