我正在为我的论文格式化一个表格。研究生院要求边距为每边 1.25 英寸,距离文本顶部/底部 1 英寸。因此,下面的表格太大,无法放在一页上。我想使用长表功能,但不确定如何执行此操作,因为 (1) 我需要重复每页的第一行,并且 (2) 我有一个多列表。我希望表格在回收与存储结果(即子列 VI)后中断。大量的包是研究生院模板的要求。如果您有任何建议,请告诉我!
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\usepackage{longtable}
\usepackage{siunitx,booktabs,threeparttable,caption}
% Additional packages here
\usepackage{amsmath}
\usepackage{bigstrut}
\usepackage{url}
\usepackage{lscape}
\usepackage{booktabs}
\usepackage{float}
\usepackage{wasysym}
\usepackage{amsmath}
\usepackage{bigstrut}
\usepackage{url}
\usepackage{natbib,epstopdf}
\usepackage{multirow}
\usepackage{pdflscape}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{tablefootnote}
\usepackage{bm}
\usepackage{wrapfig}
\usepackage[demo]{graphicx}
\begin{document}
% Table generated by Excel2LaTeX from sheet 'Sheet5'
\begin{landscape}
\begin{table}[h]\centering
\caption{MNL Model with Grouped Disposal as DV}
\footnotesize{
\begin{tabular}{lccccccccccc}
\cmidrule{2-12} & \multicolumn{3}{c}{\textbf{Recycle vs. Trash }} & & \multicolumn{3}{c}{\textbf{Recycle vs. Store }} & & \multicolumn{3}{c}{\textbf{Store vs Trash }} \\
\cmidrule{2-12} & \multicolumn{1}{c}{I} & \multicolumn{1}{c}{II} & \multicolumn{1}{c}{III} & & \multicolumn{1}{c}{IV} & \multicolumn{1}{c}{V} & \multicolumn{1}{c}{VI} & & \multicolumn{1}{c}{VII} & \multicolumn{1}{c}{VIII} & \multicolumn{1}{c}{IX} \\
& \multicolumn{1}{c}{Coef.} & \multicolumn{1}{c}{Std. Error} & \multicolumn{1}{c}{Odds ratio} & & \multicolumn{1}{c}{Coef.} & \multicolumn{1}{c}{Std. Error} & \multicolumn{1}{c}{Odds ratio} & & \multicolumn{1}{c}{Coef.} & \multicolumn{1}{c}{Std. Error} & \multicolumn{1}{c}{Odds ratio} \\
\cmidrule{2-12} 1. EPR: Yes & $0.44^{*}$ & 0.21 & 1.55 & & 0.06 & 0.18 & 1.06 & & 0.38 & 0.24 & 1.46 \\
1. LEGALAWARENESS: Yes & 0.07 & 0.22 & 1.07 & & -$0.34^{*}$ & 0.16 & 0.71 & & 0.41 & 0.25 & 1.50 \\
1. LOCTAWARENESS: Maybe & $1.37^{***}$ & 0.23 & 3.92 & & 1.17 & 0.19 & 3.92 & & 0.20 & 0.28 & 1.22 \\
2. LOCTAWARENESS: Yes & $1.67^{***}$ & 0.26 & 5.30 & & $1.48^{***}$ & 0.20 & 4.41 & & 0.18 & 0.30 & 1.20 \\
2. IMPORTANCE: Not very & -0.08 & 0.66 & 0.95 & & -0.65 & 0.95 & 0.52 & & 0.56 & 0.88 & 1.76 \\
3. IMPORTANCE: Neutral & $1.03^{\hat{}}$ & 0.58 & 2.80 & & 0.25 & 0.87 & 1.28 & & 0.78 & 0.82 & 2.18 \\
4. IMPORTANCE: Somewhat Important & $1.95^{**}$ & 0.57 & 7.06 & & -0.32 & 0.84 & 0.73 & & $2.28^{**}$ & 0.80 & 9.74 \\
5. IMPORTANCE: Very Important & $2.34^{***}$ & 0.57 & 10.41 & & 0.02 & 0.85 & 10.41 & & $2.32^{**}$ & 0.81 & 10.17 \\
1. INFOSOURCE: General & 0.41 & 0.34 & 1.51 & & $1.19^{***}$ & 0.31 & 3.30 & & -$0.78^{*}$ & 0.40 & 0.46 \\
2. INFOSOURCE: Government & $0.76^{*}$ & 0.36 & 2.14 & & $1.08^{***}$ & 0.30 & 2.94 & & -0.32 & 0.40 & 0.73 \\
3. INFOSOURCE: Retailer Manufacturer & 0.55 & 0.39 & 1.74 & & $0.77^{**}$ & 0.34 & 2.66 & & -0.42 & 0.46 & 0.65 \\
4. INFOSOURCE: Non Profit & $0.77^{*}$ & 0.38 & 2.16 & & $1.09^{***}$ & 0.32 & 2.98 & & -0.32 & 0.44 & 0.73 \\
1. PREVENT: Too Expensive & -1.19 & 0.77 & 0.31 & & -0.60 & 0.47 & 0.55 & & -0.59 & 0.89 & 0.55 \\
2. PREVENT: Inconvenient Location & -$1.73^{*}$ & 0.74 & 0.18 & & -$1.06^{*}$ & 0.45 & 0.35 & & -0.67 & 0.86 & 0.51 \\
3. PREVENT: Unable to Transport & -1.13 & 0.75 & 0.32 & & -0.22 & 0.47 & 0.81 & & -0.91 & 0.88 & 0.40 \\
4. PREVENT: Unaware of Location & -$1.57^{*}$ & 0.73 & 0.21 & & -$0.87^{*}$ & 0.46 & 0.42 & & -0.70 & 0.86 & 0.50 \\
1. RURAL: Yes & -0.23 & 0.19 & 0.78 & & -$0.37^{**}$ & 0.15 & 0.69 & & 0.14 & 0.22 & 1.16 \\
2. AGE: 36-45 & 0.35 & 0.29 & 1.43 & & 0.05 & 0.20 & 2.95 & & 0.31 & 0.32 & 0.58 \\
3. AGE: 46-55 & 0.00 & 0.25 & 0.98 & & $0.94^{***}$ & 0.23 & 2.55 & & -$0.94^{**}$ & 0.31 & 0.39 \\
4. AGE: 56-65 & 0.44 & 0.28 & 1.49 & & $1.09^{***}$ & 0.24 & 2.95 & & -$0.65^{*}$ & 0.33 & 0.52 \\
5. AGE: 66+ & $0.60^{\hat{}}$ & 0.34 & 1.82 & & $1.14^{***}$ & 0.29 & 3.13 & & -0.54 & 0.41 & 0.58 \\
2. DISTANCE: 1-5 miles & $0.61^{**}$ & 0.23 & 1.83 & & 0.45 & 0.28 & 1.57 & & -$0.47^{**}$ & 0.41 & 0.62 \\
3. DISTANCE: 6-10 miles & 0.38 & 0.25 & 1.46 & & 0.33 & 0.27 & 1.39 & & 0.25 & 0.40 & 1.29 \\
4. DISTANCE: 11-20 miles & $0.02^{\hat{}}$ & 0.34 & 1.02 & & 0.54 & 0.29 & 1.42 & & -0.19 & 0.42 & 0.83 \\
\bottomrule
\midrule
\textit{***p $<$ .001, ** p $<$.01, *p$<$.05, $^\wedge$ p$<$.1} & & & & & & & & & \\
\end{tabular}}
\label{tab:results}%
\end{table}%
\end{landscape}
答案1
- 第一步:清理你的 MWE:
MWE(不考虑完整的提供表格,因为工作量太大,您可以按照与前八行所示相同的方式完成它:
\documentclass[english]{article}
\usepackage{booktabs, makecell}
\renewcommand\theadfont{\small\bfseries}
\usepackage{siunitx}
\usepackage{caption}
% Additional packages here
\usepackage{amsmath}
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
\begin{table}
\centering
\setlength\tabcolsep{2pt}
\caption{MNL Model with Grouped Disposal as DV}
\begin{tabular*}{\linewidth}
{@{\extracolsep{\fill}}
l
*{3}{S[table-format=-1.2,
table-space-text-post={***}]
S[table-format=1.2]
S[table-format=2.2]}
}
\cmidrule{2-10}
& \multicolumn{3}{c}{\thead{Recycle vs. Trash }}
& \multicolumn{3}{c}{\thead{Recycle vs. Store }}
& \multicolumn{3}{c}{\thead{Store vs Trash }} \\
\cmidrule(lr){2-4}
\cmidrule(lr){5-7}
\cmidrule(lr){8-10}
& {I} & {II} & {III} & {IV} & {V} & {VI} & {VII} & {VIII} & {IX} \\
& {Coef.}
& {\makecell[b]{Std.\\ Error}}
& {\makecell[b]{Odds\\ ratio}}
& {Coef.}
& {\makecell[b]{Std.\\ Error}}
& {\makecell[b]{Odds\\ ratio}}
& {Coef.}
& {\makecell[b]{Std.\\ Error}}
& {\makecell[b]{Odds\\ ratio}} \\
\midrule
1. EPR: Yes
& 0.44* & 0.21 & 1.55 & 0.06 & 0.18 & 1.06 & 0.38 & 0.24 & 1.46 \\
1. LEGALAWARENESS: Yes
& 0.07 & 0.22 & 1.07 & -0.34 & 0.16 & 0.71 & 0.41 & 0.25 & 1.50 \\
1. LOCTAWARENESS: Maybe
& 1.37*** & 0.23 & 3.92 & 1.17 & 0.19 & 3.92 & 0.20 & 0.28 & 1.22 \\
2. LOCTAWARENESS: Yes
& 1.67*** & 0.26 & 5.30 & 1.48*** & 0.20 & 4.41 & 0.18 & 0.30 & 1.20 \\
2. IMPORTANCE: Not very
& -0.08 & 0.66 & 0.95 & -0.65 & 0.95 & 0.52 & 0.56 & 0.88 & 1.76 \\
3. IMPORTANCE: Neutral
& 1.03 & 0.58 & 2.80 & 0.25 & 0.87 & 1.28 & 0.78 & 0.82 & 2.18 \\
4. IMPORTANCE: Somewhat Important
& 1.95** & 0.57 & 7.06 & -0.32 & 0.84 & 0.73 & 2.28** & 0.80 & 9.74 \\
5. IMPORTANCE: Very Important
& 2.34 & 0.57 & 10.41 & 0.02 & 0.85 & 10.41 & 2.32{**} & 0.81 & 10.17 \\
\midrule[\heavyrulewidth]
\multicolumn{10}{l}{
\textit{***p $<$ .001, ** p $<$.01, *p$<$.05, $^\wedge$ p$<$.1}
}
\end{tabular*}
\label{tab:results}%
\end{table}%
\end{landscape}
\end{document}
- 第二步:将表格转换为长表格。由于
longtable
无法规定表格宽度,但标准表格的经验表明,只要设置相同,表格宽度即可适应可用文本宽度\tabcolsep
。
\documentclass[english]{article}
\usepackage{booktabs, makecell, longtable}
\renewcommand\theadfont{\small\bfseries}
\usepackage{siunitx}
\usepackage{caption}
% Additional packages here
\usepackage{amsmath}
\usepackage{pdflscape}
%\usepackage[table]{xcolor}
\begin{document}
% Table generated by Excel2LaTeX from sheet 'Sheet5'
\begin{landscape}
\setlength\tabcolsep{3pt}
\begin{longtable}{
l
*{3}{S[table-format=-1.2,
table-space-text-post={***}]
S[table-format=1.2]
S[table-format=2.2]}
}
\caption{MNL Model with Grouped Disposal as DV}
\label{tab:results} \\%
\cmidrule{2-10}
& \multicolumn{3}{c}{\thead{Recycle vs. Trash }}
& \multicolumn{3}{c}{\thead{Recycle vs. Store }}
& \multicolumn{3}{c}{\thead{Store vs Trash }} \\
\cmidrule(lr){2-4}
\cmidrule(lr){5-7}
\cmidrule(lr){8-10}
& {I} & {II} & {III} & {IV} & {V} & {VI} & {VII} & {VIII} & {IX} \\
& {Coef.}
& {\makecell[b]{Std.\\ Error}}
& {\makecell[b]{Odds\\ ratio}}
& {Coef.}
& {\makecell[b]{Std.\\ Error}}
& {\makecell[b]{Odds\\ ratio}}
& {Coef.}
& {\makecell[b]{Std.\\ Error}}
& {\makecell[b]{Odds\\ ratio}} \\
\midrule
\endfirsthead
%%%%
\caption{MNL Model with Grouped Disposal as DV (Cont.)} \\
\cmidrule{2-10}
& \multicolumn{3}{c}{\thead{Recycle vs. Trash }}
& \multicolumn{3}{c}{\thead{Recycle vs. Store }}
& \multicolumn{3}{c}{\thead{Store vs Trash }} \\
\cmidrule(lr){2-4}
\cmidrule(lr){5-7}
\cmidrule(lr){8-10}
& {I} & {II} & {III} & {IV} & {V} & {VI} & {VII} & {VIII} & {IX} \\
& {Coef.}
& {\makecell[b]{Std.\\ Error}}
& {\makecell[b]{Odds\\ ratio}}
& {Coef.}
& {\makecell[b]{Std.\\ Error}}
& {\makecell[b]{Odds\\ ratio}}
& {Coef.}
& {\makecell[b]{Std.\\ Error}}
& {\makecell[b]{Odds\\ ratio}} \\
\midrule
\endhead
%%%%
%\midrule
\multicolumn{10}{r}{\footnotesize\itshape
Continue on the next page}
\endfoot
\midrule[\heavyrulewidth]
\multicolumn{10}{l}{
\textit{***p $<$ .001, ** p $<$.01, *p$<$.05, $^\wedge$ p$<$.1}
}
\endlastfoot
%%%% table content
1. EPR: Yes
& 0.44* & 0.21 & 1.55 & 0.06 & 0.18 & 1.06 & 0.38 & 0.24 & 1.46 \\
1. LEGALAWARENESS: Yes
& 0.07 & 0.22 & 1.07 & -0.34 & 0.16 & 0.71 & 0.41 & 0.25 & 1.50 \\
1. LOCTAWARENESS: Maybe
& 1.37*** & 0.23 & 3.92 & 1.17 & 0.19 & 3.92 & 0.20 & 0.28 & 1.22 \\
2. LOCTAWARENESS: Yes
& 1.67*** & 0.26 & 5.30 & 1.48*** & 0.20 & 4.41 & 0.18 & 0.30 & 1.20 \\
2. IMPORTANCE: Not very
& -0.08 & 0.66 & 0.95 & -0.65 & 0.95 & 0.52 & 0.56 & 0.88 & 1.76 \\
3. IMPORTANCE: Neutral
& 1.03 & 0.58 & 2.80 & 0.25 & 0.87 & 1.28 & 0.78 & 0.82 & 2.18 \\
4. IMPORTANCE: Somewhat Important
& 1.95** & 0.57 & 7.06 & -0.32 & 0.84 & 0.73 & 2.28** & 0.80 & 9.74 \\
5. IMPORTANCE: Very Important
& 2.34 & 0.57 & 10.41 & 0.02 & 0.85 & 10.41 & 2.32{**} & 0.81 & 10.17 \\
\end{longtable}%
\end{landscape}
\end{document}
表格的布局与以前非常相似:
- 页面布局:我没有考虑,直接通过 package 来决定就可以了
geometry
。例如:
\documentclass[english]{article}
\usepackage[hmargin=1.25in, vmargin=1in]{geometry}
- 第三步:序言。每个包只需加载一次就足够了 :)。请删除所有重复项并根据其用途对其进行分组(用于表格、单元、标题等)
答案2
landscape
这是使用 模式的解决方案ltablex
,它提供了tabularx
跨页分页的可能性(与 的语法相同longtable
),并且threeparttablex
它扩展threeparttable
(对于表格注释)到跨页分页的表格,但语法略有不同。
除了评论:最好加载[utf8]
输入编码,因为所有现代编辑器都utf8
默认理解并使用它(也许 TeXshop 除外):
\documentclass[english]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{geometry}
\usepackage{lscape}
\usepackage[table, svgnames]{xcolor}
\usepackage{ltablex, caption, makecell, hhline, booktabs, threeparttablex}
\usepackage{siunitx}
\newcommand*\tss[1]{\,\textsuperscript{#1}}
\keepXColumns
\begin{document}
\begin{landscape}
\footnotesize\setlength\tabcolsep{3pt}
\setlength\extrarowheight{2pt}
\sisetup{table-number-alignment=center, range-phrase=--}
\begin{ThreePartTable}
\begin{TableNotes}[para]
\item[***]$ p < .001 $,
\item[**] $ p <.01 $,
\item[*] $ p<.05 $,
\item[$ ^ ∧ $] $ p<.1 $.
\end{TableNotes}
\begin{tabularx}{\linewidth}{@{}X@{}*{3}{S[table-format=-1.2, table-space-text-post=\tss{***}] S[table-format=1.2] S[table-format=2.2]}@{}}
\caption{MNL Model with Grouped Disposal as DV} \\
\cmidrule[\heavyrulewidth]{2-10} & \multicolumn{3}{c}{\textbf{Recycle vs. Trash }} & \multicolumn{3}{c}{\textbf{Recycle vs. Store }} & \multicolumn{3}{c}{\textbf{Store vs Trash }} \\
\cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(l){8-10} %
& { \makecell{I \\Coef.}} & {\makecell{II\\Std. Error}} & {\makecell{III\\Odds ratio}} & {\makecell{IV\\Coef.}} & {\makecell{V\\Std. Error}} & {\makecell{VI\\Odds ratio}} & {\makecell{VII\\Coef.}} & {\makecell{VIII\\Std. Error}} & {\makecell{IX\\Odds ratio}} \\%
\cmidrule[\lightrulewidth](l){2-10} \\
\endfirsthead
\multicolumn{10}{c}{Table \thetable}{}(continued)\\
\cmidrule[\heavyrulewidth]{2-10} & \multicolumn{3}{c}{\textbf{Recycle vs. Trash }} & \multicolumn{3}{c}{\textbf{Recycle vs. Store }} & \multicolumn{3}{c}{\textbf{Store vs Trash }} \\
\cmidrule(lr){2-4}\cmidrule(lr){5-7}\cmidrule(l){8-10} %
& { \makecell{I \\Coef.}} & {\makecell{II\\Std. Error}} & {\makecell{III\\Odds ratio}} & {\makecell{IV\\Coef.}} & {\makecell{V\\Std. Error}} & {\makecell{VI\\Odds ratio}} & {\makecell{VII\\Coef.}} & {\makecell{VIII\\Std. Error}} & {\makecell{IX\\Odds ratio}} \\%
\cmidrule[\lightrulewidth](l){2-10} \\
\endhead
\\\multicolumn{10}{r}{To be continued}
\endfoot
\\
\bottomrule
\midrule
\insertTableNotes
\endlastfoot
1. EPR: Yes & 0.44$ \tnote{*} $ & 0.21 & 1.55 & 0.06 & 0.18 & 1.06 & 0.38 & 0.24 & 1.46 \\
1. LEGALAWARENESS: Yes & 0.07 & 0.22 & 1.07 & -0.34\tnote{*} & 0.16 & 0.71 & 0.41 & 0.25 & 1.50 \\
1. LOCTAWARENESS: Maybe & 1.37\tnote{***} & 0.23 & 3.92 & 1.17 & 0.19 & 3.92 & 0.20 & 0.28 & 1.22 \\
2. LOCTAWARENESS: Yes & 1.67\tnote{***} & 0.26 & 5.30 & 1.48\tnote{***} & 0.20 & 4.41 & 0.18 & 0.30 & 1.20 \\
2. IMPORTANCE: Not very & -0.08 & 0.66 & 0.95 & -0.65 & 0.95 & 0.52 & 0.56 & 0.88 & 1.76 \\
3. IMPORTANCE: Neutral & 1.03\tnote{$ ∧ $} & 0.58 & 2.80 & 0.25 & 0.87 & 1.28 & 0.78 & 0.82 & 2.18 \\
4. IMPORTANCE: Somewhat Important & 1.95\tnote{**} & 0.57 & 7.06 & -0.32 & 0.84 & 0.73 & 2.28\tnote{**} & 0.80 & 9.74 \\
5. IMPORTANCE: Very Important & 2.34\tnote{***} & 0.57 & 10.41 & 0.02 & 0.85 & 10.41 & 2.32\tnote{**} & 0.81 & 10.17 \\
1. INFOSOURCE: General & 0.41 & 0.34 & 1.51 & 1.19\tnote{***} & 0.31 & 3.30 & -0.78\tnote{*} & 0.40 & 0.46 \\
2. INFOSOURCE: Government & 0.76\tnote{*} & 0.36 & 2.14 & 1.08\tnote{***} & 0.30 & 2.94 & -0.32 & 0.40 & 0.73 \\
3. INFOSOURCE: Retailer Manufacturer & 0.55 & 0.39 & 1.74 & 0.77\tnote{**} & 0.34 & 2.66 & -0.42 & 0.46 & 0.65 \\
4. INFOSOURCE: Non Profit & 0.77\tnote{*} & 0.38 & 2.16 & 1.09\tnote{***} & 0.32 & 2.98 & -0.32 & 0.44 & 0.73 \\
1. PREVENT: Too Expensive & -1.19 & 0.77 & 0.31 & -0.60 & 0.47 & 0.55 & -0.59 & 0.89 & 0.55 \\
2. PREVENT: Inconvenient Location & -1.73\tnote{*} & 0.74 & 0.18 & -1.06\tnote{*} & 0.45 & 0.35 & -0.67 & 0.86 & 0.51 \\
3. PREVENT: Unable to Transport & -1.13 & 0.75 & 0.32 & -0.22 & 0.47 & 0.81 & -0.91 & 0.88 & 0.40 \\
4. PREVENT: Unaware of Location & -1.57\tnote{*} & 0.73 & 0.21 & -0.87\tnote{*} & 0.46 & 0.42 & -0.70 & 0.86 & 0.50 \\
1. RURAL: Yes & -0.23 & 0.19 & 0.78 & -0.37\tnote{**} & 0.15 & 0.69 & 0.14 & 0.22 & 1.16 \\
2. AGE: \numrange{36}{45} & 0.35 & 0.29 & 1.43 & 0.05 & 0.20 & 2.95 & 0.31 & 0.32 & 0.58 \\
3. AGE: \numrange{46}{55} & 0.00 & 0.25 & 0.98 & 0.94\tnote{***} & 0.23 & 2.55 & -0.94\tnote{**} & 0.31 & 0.39 \\
4. AGE: \numrange{56}{65} & 0.44 & 0.28 & 1.49 & 1.09\tnote{***} & 0.24 & 2.95 & -0.65\tnote{*} & 0.33 & 0.52 \\
5. AGE: 66\,+ & 0.60\tnote{$ ∧ $} & 0.34 & 1.82 & 1.14\tnote{***} & 0.29 & 3.13 & -0.54 & 0.41 & 0.58 \\
2. DISTANCE: \numrange{1}{5} miles & 0.61\tnote{**} & 0.23 & 1.83 & 0.45 & 0.28 & 1.57 & -0.47\tnote{**} & 0.41 & 0.62 \\
3. DISTANCE: \numrange{6}{10} miles & 0.38 & 0.25 & 1.46 & 0.33 & 0.27 & 1.39 & 0.25 & 0.40 & 1.29 \\
4. DISTANCE: \numrange{11}{20} miles & 0.02\tnote{$ ∧ $} & 0.34 & 1.02 & 0.54 & 0.29 & 1.42 & -0.19 & 0.42 & 0.83
\end{tabularx}%}%}
\label{tab:results}%
\end{ThreePartTable}
\end{landscape}
\end{document}