除了指定长表中每列的宽度(见下文)之外,有没有办法让它自动调整其大小以匹配文本宽度,但不会进入边距?
\floatsetup[longtable]{LTcapwidth=\textwidth}
\scriptsize
\begin{longtable}[c]
{p{0.045\textwidth}p{0.045\textwidth}p{0.045\textwidth}p{0.045\textwidth}p{0.045\textwidth}p{0.05\textwidth}p{0.045\textwidth}p{0.045\textwidth}p{0.045\textwidth}p{0.045\textwidth} p{0.045\textwidth} p{0.045\textwidth} p{0.045\textwidth}}
\caption{Insert caption here}
\hline \multicolumn{13}{c} %Removed code for 13 column multiple page table%
\end{longtable}
答案1
这使用与 Zarko 和 Skillmon 相同的方法,但使用长度寄存器来避免重复计算 13 次。
\documentclass{article}
\usepackage{longtable}
\usepackage{showframe}
\newlength{\mycolwidth}
\begin{document}
\scriptsize
\setlength{\mycolwidth}{\dimexpr \textwidth/13 - 2\tabcolsep}%
\begin{longtable}[c]{*{13}{p{\mycolwidth}}}
\caption{Insert caption here}
\endfirsthead
\hline
\multicolumn{13}{c}{Removed code for 13 column multiple page table}\\
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13
\end{longtable}
\end{document}
\tabcolsep
边缘处有自动间隙,这样就可以将其去除。
\documentclass{article}
\usepackage{longtable}
\usepackage{showframe}
\newlength{\mycolwidth}
\begin{document}
\scriptsize
\setlength{\mycolwidth}{\dimexpr \textwidth - 24\tabcolsep}%
\divide \mycolwidth by 13
\begin{longtable}[c]{@{}*{13}{p{\mycolwidth}}@{}}
\caption{Insert caption here}
\endfirsthead
\hline
\multicolumn{13}{c}{Removed code for 13 column multiple page table}\\
1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13
\end{longtable}
\end{document}