我正在尝试创建一个独立的文件,但是内容不适合它。
我认为\minipage{\textwidth}
这是导致问题的原因。我知道我可以设置例如,\minipage{21cm}
但我想保持这种动态,因为表格是从R 脚本。我也尝试过,\minipage{\linewidth}
但也没有解决问题。
无论如何,我都必须调整脚本以添加附加项和尚未自动创建的\begin{tabular}
附加项。现在这是一个相当大的施工现场。因此,如果有一个解决方案不会对代码进行太多更改,我也会很感激。\toprule
这是我的代码:
\documentclass[12pt]{standalone}
\usepackage{caption,booktabs,array}
\UseRawInputEncoding
\begin{document}
\minipage{\textwidth}
\begin{tabular}{@{\extracolsep{4pt}}>{\hangindent=1.5em\hangafter=1}p{2in}rrrrrrr}
\toprule
{} & \multicolumn{3}{c}{Treatment A} & \multicolumn{3}{c}{Treatment B} & {}\\
\cmidrule{2-4}
\cmidrule{5-7}
& Lorem & ipsum & dolor & sit & amets & consetetur & sadipscing \\
\hline
luptatum blandit invidunt takimata & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
sanctus eirmod sea labore & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
erats sea eirmod blandit & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
sea iriure illum eum & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
zzril consetetur ipsum takimata & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
dolore hendrerit justo sit & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
sit augue et Lorem & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
labore amets et dolores & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
ipsum justo autem vel & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
aliquyam velit luptatum Lorem & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
\hline
\end{tabular}
\captionof{table}{My caption}
\endminipage
\end{document}
答案1
\documentclass[12pt]{standalone}
\usepackage{caption,booktabs,array}
\UseRawInputEncoding
\begin{document}
\sbox0{%
\begin{tabular}{@{\extracolsep{4pt}}>{\hangindent=1.5em\hangafter=1}p{2in}rrrrrrr}
\toprule
{} & \multicolumn{3}{c}{Treatment A} & \multicolumn{3}{c}{Treatment B} & {}\\
\cmidrule{2-4}
\cmidrule{5-7}
& Lorem & ipsum & dolor & sit & amets & consetetur & sadipscing \\
\hline
luptatum blandit invidunt takimata & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
sanctus eirmod sea labore & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
erats sea eirmod blandit & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
sea iriure illum eum & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
zzril consetetur ipsum takimata & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
dolore hendrerit justo sit & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
sit augue et Lorem & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
labore amets et dolores & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
ipsum justo autem vel & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
aliquyam velit luptatum Lorem & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 & 9.99 \\
\hline
\end{tabular}}
\begin{minipage}{\wd0}
\usebox0
\captionof{table}{My caption}
\end{minipage}
\end{document}