任何表格都可以用\begin{表格}{p{\文本宽度}......}超出边距。示例表如下
\documentclass[12pt,a4paper]{report}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{makecell}
\begin{document}
\begin{longtable}{p{.4\textwidth}p{.6\textwidth}}
\hline
example letter & abc... \\ \hline
\end{longtable}
\end{document}
我正在写我的论文,这是一份包含多个章节的大型文档。文档的序言如下所示。
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath,amssymb,amsfonts} % for mathematical operations
\allowdisplaybreaks %allow align to break in pages
\usepackage[top=2.54cm, bottom=2.54cm, left=3.56cm, right=2.54cm]{geometry} % margin
\usepackage{graphicx, epstopdf} % insert images
\graphicspath{{figures/}} % image path
\usepackage[section]{placeins} % figure placement
\usepackage[framed, numbered]{matlab-prettifier} % to insert matlab code
\usepackage[labelfont=bf, labelsep=space]{caption} % caption formatting
\usepackage{subcaption} % subcaption for subfigure
\usepackage{lipsum}
\usepackage{booktabs} % for book tabs type table, \toprule...
\usepackage{tabularx}
\usepackage{longtable}
\usepackage{makecell} %break cell in table
\usepackage[T1] {fontenc} % better pdf output
\usepackage{textcomp}
\usepackage{enumitem} % for controlling item sepaeration
\usepackage{IEEEtrantools} % for using IEEEtran tools in this document
\usepackage{setspace} % different spacing and stretch
\usepackage{xcolor} % for using colors
\usepackage{times} % times new roman font for the whole document
\usepackage{anyfontsize} % any font size can be used with instead built in \large type
\usepackage{nameref}
\usepackage{float} % uses [H] for figures and tables alignment
\usepackage{url} % for using url in the references
\setlength\parindent{0pt} % no indent
答案1
(评论太长,因此作为答案发布)
您指定
\begin{longtable}{p{.4\textwidth}p{.6\textwidth}}
这可用的整体宽度为1.0\textwidth
。但是,由于两列两侧都有填充(量为\tabcolsep
),全部的整体宽度为。在许多文档类别(包括 )中1.0\textwidth+4\tabcolsep
的默认值为6pt。 因此,的总宽度超出24pt,或大约三分之一英寸(或者如果您愿意,大约 8.5mm)。\tabcolsep
report
longtable
\textwidth
要解决这个问题,你应该写
\begin{longtable}{p{\dimexpr.4\textwidth-2\tabcolsep\relax}
p{\dimexpr.6\textwidth-2\tabcolsep\relax}}
或者,如果你不需要左边缘和右边缘的填充,
\begin{longtable}{@{}p{\dimexpr.4\textwidth-\tabcolsep\relax}
p{\dimexpr.4\textwidth-\tabcolsep\relax} @{}}
答案2
为什么不使用 ?它结合了和xltabular
的特点。为了使 X 列按一定比例排列,我们使用语法,其中系数按所需比例排列,系数之和为 X 列的总数。longtable
tabularx
>{\hsize=xxx\hsize}
\documentclass[12pt, a4paper]{report}
\usepackage{booktabs}
\usepackage{xltabular}
\usepackage{longtable}
\usepackage{makecell}
\usepackage{lipsum}
\begin{document}
\lipsum[11]
\begin{xltabular}{\linewidth}{>{\hsize=0.8\hsize\centering}X|>{\hsize=1.2\hsize\centering\arraybackslash}X}
\toprule
example letter & abc... \\ \midrule
\end{xltabular}
\end{document}