gpt4 book ai didi

latex - 将比文本列更宽的表格居中

转载 作者:行者123 更新时间:2023-12-02 01:37:58 25 4
gpt4 key购买 nike

我在 LaTeX 文档中包含一个表格,如果表格不比其上方的文本列宽,则居中效果很好,但当表格更宽时,表格的左侧会粘在左侧文本列的宽度,表格的附加宽度位于页面右侧,如何使表格居中?

最佳答案

我建议尝试 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 环境的文档:

Within an adjustwidth environment the left and right margins can be adjusted. The environment takes one optional argument and two required length arguments:

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

A positive length value will increase the relevant margin

(shortening the text lines) while a negative length value will decrease the margin (lengthening text lines). An empty length argument means no change to the margin. At the end of the environment the margins revert to their original values.

For example, to extend the text into the right margin:

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

Any appearance of the optional argument (even just []) will cause the values of the margins to switch between odd and even pages.

If the document is being set twosided it might be advantageous to have any wider text extending into the outside margin. This could be done via the optional argument, as:

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

To have the adjusted text horizontally centered with respect to any surrounding text, the margins should be adjusted equally:

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

关于latex - 将比文本列更宽的表格居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/722613/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com