亲爱的 TeX Stackexchange
我在创建表格时遇到了一个问题。如下图所示,三条黑线没有向右延伸,而是停在了 (10) 下方:
我的文字如下所示:
\documentclass[a4paper,11pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{layout}
\usepackage[protrusion=true,expansion=true]{microtype}
% Different usepackages
\usepackage[T1]{fontenc}
\usepackage[lf]{MinionPro} %% MinionPro
\usepackage{icomma}
\usepackage{setspace}
\setstretch{1.10}
\usepackage{siunitx,booktabs}
\usepackage{graphicx}
% Page margins
\usepackage[left=3.5cm,right=3.5cm,top=3.4cm,bottom=3.4cm]{geometry}
% Tabular
\usepackage{threeparttable}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\includepdfset{pagecommand=\thispagestyle{plain}}
\renewcommand{\TPTnoteSettings}{\footnotesize}
\renewcommand{\TPTnoteLabel}[1]{#1}
\usepackage{float}
% Rotate
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
\begin{table}[H]
\begin{threeparttable}
\renewcommand\arraystretch{1.1}
\medskip
\renewcommand\tabcolsep{1pt} % Set this to some very small value ...
\begin{tabular*}{\textwidth}{ @{} p{2.4cm}
@{\extracolsep{\fill}} % and let LaTeX provide the necessary "fill" amount
*{12}{S[table-format=2.3]} @{}}
\toprule
\emph{?}
& \multicolumn{4}{c}{Room1}
& \multicolumn{4}{c}{Room2}
& \multicolumn{4}{c}{Room3}
\\
\cmidrule(lr){2-5} \cmidrule(lr){6-9} \cmidrule(lr){10-13}
& {(1)} & {(2)} & {(3)} & {(4)}
& {(5)} & {(6)} & {(7)} & {(8)}
& {(9)} & {(10)} & {(11)} & {(12)} \\
\emph{Dep.\ var.}
& {Elec} & {Elec} & {Elec} & {Elec}
& {Elec} & {Elec} & {Elec} & {Elec}
& {Elec} & {Elec} & {Elec} & {Elec} \\
\midrule
\emph{Undep.\ var.}\\
Electricity
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
\\
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
\\
Ohm
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
& \multicolumn{1}{c}{0,00\sym{***}}
\\
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
& \multicolumn{1}{c}{(0,00)}
\\
\cmidrule{1-1}
R\textsuperscript{2}
& \multicolumn{1}{c}{0,00}
& \multicolumn{1}{c}{0,00}
& \multicolumn{1}{c}{0,00}
& \multicolumn{1}{c}{0,00}
& \multicolumn{1}{c}{0,00}
& \multicolumn{1}{c}{0,00}
& \multicolumn{1}{c}{0,00}
& \multicolumn{1}{c}{0,00}
& \multicolumn{1}{c}{0,00}
& \multicolumn{1}{c}{0,00}
& \multicolumn{1}{c}{0,00}
& \multicolumn{1}{c}{0,00}
\\
N
& \multicolumn{1}{c}{000}
& \multicolumn{1}{c}{000}
& \multicolumn{1}{c}{000}
& \multicolumn{1}{c}{000}
& \multicolumn{1}{c}{000}
& \multicolumn{1}{c}{000}
& \multicolumn{1}{c}{000}
& \multicolumn{1}{c}{000}
& \multicolumn{1}{c}{000}
& \multicolumn{1}{c}{000}
& \multicolumn{1}{c}{000}
& \multicolumn{1}{c}{000}
\\
\bottomrule
\end{tabular*}
\end{threeparttable}
\end{table}
\end{landscape}
\end{document}
我不知道我做错了什么。如果你能发现我做错了什么或者帮我修复它——我会非常感激你的帮助!
编辑:新表
\begin{table}[H]
\centering
\begin{threeparttable}
\renewcommand\arraystretch{1.1}
\medskip
\begin{tabular*}{0.82\textwidth}{
@{\extracolsep{\fill}}
l
c
S[table-format=3.0]
S[table-format=3.0]
}
\toprule
& {Randomized$^{\pm}$} & {Electricity$^{\mp}$}
\\
\midrule
Power & & & \\
\ \ \ \ \ \ \ \ One & 16,4 pct.\sym{**} & 19,5 pct. \\
\ \ \ \ \ \ \ \ Two & 16,8 pct.\sym{***} & 15,0 pct. \\
\ \ \ \ \ \ \ \ Three & 19,2 pct. & 17,8 pct. \\
\ \ \ \ \ \ \ \ Four & 16,6 pct. & 16,7 pct. \\
\ \ \ \ \ \ \ \ Five & 16,4 pct. & 15,3 pct. \\
\ \ \ \ \ \ \ \ Six & 14,7 pct. & 15,7 pct. \\
\bottomrule
\end{tabular*}
\end{threeparttable}
\end{table}
答案1
您必须将其替换\textwidth
为\linewidth
: \textwidth 是全局文本宽度(在纵向模式下),而 \linewidth 是线宽current
– 这意味着\textheight
当您处于横向环境中时。我借此机会简化了您的代码,删除了所有这些过多的\multicolumn
s。
\documentclass[a4paper,11pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{layout}
\usepackage[protrusion=true,expansion=true]{microtype}
% Different usepackages
\usepackage[T1]{fontenc}
\usepackage[lf]{MinionPro} %% MinionPro
\usepackage{icomma}
\usepackage{setspace}
\setstretch{1.10}
\usepackage{siunitx,booktabs}
\usepackage{graphicx}
% Page margins
\usepackage[hmargin=3.5cm, vmargin=3.4cm]{geometry}%
% Tabular
\usepackage{threeparttable}
\newcommand\sym[1]{\textsuperscript{\rlap{\,#1}}}
% \includepdfset{pagecommand=\thispagestyle{plain}}
\renewcommand{\TPTnoteSettings}{\footnotesize}
\renewcommand{\TPTnoteLabel}[1]{#1}
\usepackage{float}
% Rotate
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
\mbox{}\vfill
\begin{table}[H]
\begin{threeparttable}
\renewcommand\arraystretch{1.1}
\medskip
\renewcommand\tabcolsep{1pt} % Set this to some very small value ...
\begin{tabular*}{\linewidth}{ @{}l
@{\extracolsep{\fill}} % and let LaTeX provide the necessary "fill" amount
*{12}{S[table-format=1.2, table-space-text-pre=(, table-space-text-post=)]} @{\hphantom{\textsuperscript{***}}}}
\toprule
\emph{?} & \multicolumn{4}{c}{Room1} & \multicolumn{4}{c}{Room2} & \multicolumn{4}{c}{Room3} \\
\cmidrule(lr){2-5} \cmidrule(lr){6-9} \cmidrule(lr){10-13}
& {(1)} & {(2)} & {(3)} & {(4)} & {(5)} & {(6)} & {(7)} & {(8)} & {(9)} & {(10)} & {(11)} & {(12)} \\
\emph{Dep.\ var.} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} & {Elec} \\
\midrule
\emph{Undep.\ var.}\\
Electricity & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} \\
& {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} \\
Ohm & 0,00{\sym{***}} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} & 0,00\sym{***} \\
& {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} & {(}0,00{)} \\
\cmidrule{1-1}
R\textsuperscript{2} & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 & 0,00 \\
N & {000} & {000} & {000} & {000} & {000} & {000} & {000} & {000} & {000} & {000} & {000} & {000} \\
\bottomrule
\end{tabular*}
\end{threeparttable}
\end{table}
\vfill\newpage
\end{landscape}
\end{document}
添加第二个表的新代码:我重新定义了sym
命令 sio,使其不会改变单元格的对齐方式,并且我简化了代码(只有三列):
\documentclass[a4paper,11pt,twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{layout}
\usepackage[protrusion=true,expansion=true]{microtype}
% Different usepackages
\usepackage[T1]{fontenc}
\usepackage[lf]{MinionPro} %% MinionPro
\usepackage{icomma}
\usepackage{setspace}
\setstretch{1.10}
\usepackage{siunitx,booktabs}
\usepackage{graphicx}
% Page margins
\usepackage[hmargin=3.5cm, vmargin=3.4cm]{geometry}%
% Tabular
\usepackage{threeparttable}
\newcommand\sym[1]{\textsuperscript{\rlap{\,#1}}}
% \includepdfset{pagecommand=\thispagestyle{plain}}
\renewcommand{\TPTnoteSettings}{\footnotesize}
\renewcommand{\TPTnoteLabel}[1]{#1}
\usepackage{float}
\begin{document}
\begin{table}[H]
\centering
\begin{threeparttable}
\renewcommand\arraystretch{1.1}
\medskip
\begin{tabular*}{0.82\textwidth}{
@{\extracolsep{\fill}}
>{\hphantom{Power}}l
S[table-format=2.1]
S[table-format=2.1]
}
\toprule
& {Randomized$^{\pm}$} & {Electricity$^{\mp}$}
\\
\midrule
\llap{Power} & {pct.}& {pct.}\\
One & 16,4 & 19,5 \sym{***} \\
Two & 16,8 & 15,0 \\
Three & 19,2 & 17,8\sym{**} \\
Four & 16,6 & 16,7 \\
Five & 16,4 & 15,3 \\
Six & 14,7 & 15,7 \\
\bottomrule
\end{tabular*}
\end{threeparttable}
\end{table}
\end{document}