我如何确保表格与章节标题位于同一页?我尝试将 [h!] 添加到 \begin{table},但没有任何效果。请注意,表格处于横向模式。
桌子:
\begin{table}
\centering
\resizebox{\linewidth}{!}{
\fontsize{9}{11}\selectfont
\begin{tabular}[t]{lcccccccccccc}
\toprule
& emp & emp\_incq1 & emp\_incq2 & emp\_incq3 & emp\_incq4 & emp\_incmiddle & emp\_incbelowmed & emp\_incabovemed & emp\_ss40 & emp\_ss60 & emp\_ss65 & emp\_ss70\\
\midrule
Treat x After & \num{-0.007} & \num{0.006} & \num{-0.003} & \num{-0.004} & \num{-0.018}+ & \num{0.002} & \num{-0.003} & \num{-0.006} & \num{0.017} & \num{-0.004} & \num{-0.008} & \num{-0.038}+\\
& (\num{0.012}) & (\num{0.018}) & (\num{0.015}) & (\num{0.010}) & (\num{0.011}) & (\num{0.013}) & (\num{0.015}) & (\num{0.011}) & (\num{0.018}) & (\num{0.011}) & (\num{0.009}) & (\num{0.020})\\
Konstant & \num{-0.083}*** & \num{-0.190}*** & \num{-0.031}*** & \num{-0.059}*** & \num{-0.008}+ & \num{-0.048}*** & \num{-0.137}*** & \num{-0.017}*** & \num{-0.126}*** & \num{-0.137}*** & \num{-0.108}*** & \num{-0.167}***\\
& (\num{0.006}) & (\num{0.010}) & (\num{0.008}) & (\num{0.005}) & (\num{0.004}) & (\num{0.006}) & (\num{0.008}) & (\num{0.005}) & (\num{0.009}) & (\num{0.005}) & (\num{0.008}) & (\num{0.013})\\
\midrule
Num.Obs. & \num{570} & \num{528} & \num{498} & \num{525} & \num{420} & \num{513} & \num{570} & \num{510} & \num{540} & \num{480} & \num{510} & \num{540}\\
R2 & \num{0.863} & \num{0.813} & \num{0.882} & \num{0.903} & \num{0.941} & \num{0.904} & \num{0.808} & \num{0.904} & \num{0.726} & \num{0.873} & \num{0.805} & \num{0.797}\\
R2 Adj. & \num{0.849} & \num{0.793} & \num{0.869} & \num{0.893} & \num{0.934} & \num{0.894} & \num{0.789} & \num{0.894} & \num{0.698} & \num{0.859} & \num{0.785} & \num{0.776}\\
R2 Within & & & & & & & & & & & & \\
R2 Pseudo & & & & & & & & & & & & \\
AIC & \num{-2623.7} & \num{-1828.7} & \num{-2054.8} & \num{-2417.0} & \num{-2337.2} & \num{-2306.4} & \num{-2350.7} & \num{-2414.6} & \num{-2013.0} & \num{-2159.1} & \num{-2125.1} & \num{-1679.2}\\
BIC & \num{-2393.4} & \num{-1606.7} & \num{-1844.3} & \num{-2203.8} & \num{-2163.4} & \num{-2090.1} & \num{-2120.4} & \num{-2207.1} & \num{-1794.2} & \num{-1962.9} & \num{-1917.6} & \num{-1460.3}\\
Log.Lik. & \num{1364.856} & \num{966.334} & \num{1077.391} & \num{1258.501} & \num{1211.581} & \num{1204.196} & \num{1228.360} & \num{1256.318} & \num{1057.525} & \num{1126.532} & \num{1111.542} & \num{890.587}\\
Std.Errors & by: Delstat & by: Delstat & by: Delstat & by: Delstat & by: Delstat & by: Delstat & by: Delstat & by: Delstat & by: Delstat & by: Delstat & by: Delstat & by: Delstat\\
\bottomrule
\multicolumn{13}{l}{\rule{0pt}{1em}\textsuperscript{1} TODO: Fotnot till denna tabell}\\
\multicolumn{13}{l}{\rule{0pt}{1em}+ p $<$ 0.1, * p $<$ 0.05, ** p $<$ 0.01, *** p $<$ 0.001}\\
\end{tabular}}
\end{table}
答案1
由于您没有提供有关文档类别、纸张大小、字体和字体大小以及 LaTeX 文档所用边距宽度的信息,因此以下设置主要基于猜测。无论如何,我的主要建议是使用命令\rotatebox
(由graphicx
软件包提供)以横向模式渲染tabular
材料。
还请尽可能尝试缩小某些列的宽度,方法是缩小标题单元格的宽度(请参阅下文以了解此想法的具体应用),或者将重复但较宽的内容(例如“by: Delstat”)移到脚注中。综合起来,这些调整将让您能够使用\small
(字体大小线性减少 10%)而不是\scriptsize
(字体大小减少 30%)。我非常肯定您的读者会欣赏您的这一举动。
顺便问一下,为什么表中的每个数字都被包含在\num
宏中?
\documentclass{article} % or some other suitable document class
\usepackage[T1]{fontenc}
\usepackage[a4paper,margin=2.5cm,showframe]{geometry} % set page parameters suitably
\usepackage{sectsty} % just for this example
\sectionfont{\mdseries\scshape}
\usepackage{graphicx, % for \rotatebox macro
siunitx, % for \num macro
booktabs} % for \toprule, \midrule, etc macros
\begin{document}
\setcounter{section}{4} % just for this example
\section{Appendix}
%\begin{table}
%\centering
%%%\resizebox{\linewidth}{!}{ % do not, under any circumstance, use \resizebox
%\fontsize{9}{11}\selectfont
\begingroup % localize scope of the next instruction
\centering
\rotatebox{90}{%
\setlength\tabcolsep{4pt} % default value: 6pt
\small % 10% linear reduction in font size
\begin{tabular}{@{} l *{12}{c} @{}}
\toprule
& emp & \multicolumn{11}{c@{}}{emp\_} \\
\cmidrule(l){3-13}
& & incq1 & incq2 & incq3 & incq4
& incmiddle & incbelowmed & incabovemed
& ss40 & ss60 & ss65 & ss70 \\
\midrule
Treat$\times$After & \num{-0.007} & \num{0.006} & \num{-0.003} & \num{-0.004} & \num{-0.018}+ & \num{0.002} & \num{-0.003} & \num{-0.006} & \num{0.017} & \num{-0.004} & \num{-0.008} & \num{-0.038}+\\
& (\num{0.012}) & (\num{0.018}) & (\num{0.015}) & (\num{0.010}) & (\num{0.011}) & (\num{0.013}) & (\num{0.015}) & (\num{0.011}) & (\num{0.018}) & (\num{0.011}) & (\num{0.009}) & (\num{0.020})\\
\addlinespace
Konstant & \num{-0.083}*** & \num{-0.190}*** & \num{-0.031}*** & \num{-0.059}*** & \num{-0.008}+ & \num{-0.048}*** & \num{-0.137}*** & \num{-0.017}*** & \num{-0.126}*** & \num{-0.137}*** & \num{-0.108}*** & \num{-0.167}***\\
& (\num{0.006}) & (\num{0.010}) & (\num{0.008}) & (\num{0.005}) & (\num{0.004}) & (\num{0.006}) & (\num{0.008}) & (\num{0.005}) & (\num{0.009}) & (\num{0.005}) & (\num{0.008}) & (\num{0.013})\\
\midrule
Num.Obs. & \num{570} & \num{528} & \num{498} & \num{525} & \num{420} & \num{513} & \num{570} & \num{510} & \num{540} & \num{480} & \num{510} & \num{540}\\
R\textsuperscript{2} & \num{0.863} & \num{0.813} & \num{0.882} & \num{0.903} & \num{0.941} & \num{0.904} & \num{0.808} & \num{0.904} & \num{0.726} & \num{0.873} & \num{0.805} & \num{0.797}\\
R\textsuperscript{2} Adj. & \num{0.849} & \num{0.793} & \num{0.869} & \num{0.893} & \num{0.934} & \num{0.894} & \num{0.789} & \num{0.894} & \num{0.698} & \num{0.859} & \num{0.785} & \num{0.776}\\
R\textsuperscript{2} Within & & & & & & & & & & & & \\
R\textsuperscript{2} Pseudo & & & & & & & & & & & & \\
AIC & \num{-2623.7} & \num{-1828.7} & \num{-2054.8} & \num{-2417.0} & \num{-2337.2} & \num{-2306.4} & \num{-2350.7} & \num{-2414.6} & \num{-2013.0} & \num{-2159.1} & \num{-2125.1} & \num{-1679.2}\\
BIC & \num{-2393.4} & \num{-1606.7} & \num{-1844.3} & \num{-2203.8} & \num{-2163.4} & \num{-2090.1} & \num{-2120.4} & \num{-2207.1} & \num{-1794.2} & \num{-1962.9} & \num{-1917.6} & \num{-1460.3}\\
Log-Lik. & \num{1364.856} & \num{966.334} & \num{1077.391} & \num{1258.501} & \num{1211.581} & \num{1204.196} & \num{1228.360} & \num{1256.318} & \num{1057.525} & \num{1126.532} & \num{1111.542} & \num{890.587}\\
%%%Std.Errors & by: Delstat & by: Delstat & by: Delstat & by: Delstat & by: Delstat & by: Delstat
%%% & by: Delstat & by: Delstat & by: Delstat & by: Delstat & by: Delstat & by: Delstat \\
\bottomrule
\addlinespace
\multicolumn{13}{@{}l}{\footnotesize\textsuperscript{1} TODO: Fotnot till denna tabell}\\[0.5ex]
\multicolumn{13}{@{}l}{\footnotesize$^{+}\ p < 0.1$, $^{*}\ p < 0.05$, $^{**}\ p < 0.01$, $^{***}\ p < 0.001$.}\\[0.5ex]
\multicolumn{13}{@{}l}{\footnotesize All standard errors by Delstat.} % <-- new
\end{tabular}
%%%} % do not, under any circumstance, use \resizebox
%%%\end{table}
} %end of scope of \rotatebox directive
\endgroup
\end{document}
答案2
评论太长了。您的表格太宽,无法放在纵向页面上,因此旋转它是唯一合理的选择。为此,您可以使用rotating
包或rotatebox
按照包中的定义graphicx
。
然而,如果允许部分图块也可以旋转,解决方案就会更简单。
您是否期望发生如下情况:
(红线表示页面布局)
\documentclass{article}
\usepackage[margin=20mm]{geometry}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{caption}
\usepackage{rotating}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx, varwidth}
\newcommand\td{\textsuperscript{\textdagger}}
\usepackage{tabularx}
\begin{document}
\section{Section name}
\vfill
\begin{center}
\begin{sideways}
\small\linespread{0.8}\selectfont
\sisetup{
input-open-uncertainty =,
input-close-uncertainty=,
table-align-text-before= false,
table-format=-1.3{***}
}
\begin{talltblr}[
note{a} = {Prefix to column header names}
note{} = {\mbox{}\\
Standard errors in parentheses:\newline
\td: $p<0.1$,\quad
*: $p<0.05$,\quad
**: $p<0.01$,\quad
***: $p<0.001$.
}
]{width=0.75\textheight,
colsep=3pt,
colspec = {@{} X[l, m]
*{12}{S} @{}}
}
\toprule
& \SetCell[c=11]{c} {{{ emp\_ \TblrNote{a} }}} \\
\cmidrule{3-13}
&{{{emp}}} &{{{incq1}}} &{{{incq2}}} &{{{incq3}}} &{{{incq4}}} &{{{incmiddle}}}
&{{{incbmed}}} &{{{incamed}}} &{{{ss40}}} &{{{ss60}}} &{{{ss65}}} &{{{ss70}}} \\
\midrule
Treat x\newline After
& -0.007 & 0.006 & -0.003 & -0.004 & -0.018\td & 0.002
& -0.003 & -0.006 & 0.017 & -0.004 & -0.008 & -0.038\td \\
%
& (0.012) & (0.018) & (0.015) & (0.010) & (0.011) & (0.013)
& (0.015) & (0.011) & (0.018) & (0.011) & (0.009) & (0.020) \\
\addlinespace
Konstant
& -0.083\TblrNote{***}
& -0.190\TblrNote{***}
& -0.031\TblrNote{***}
& -0.059\TblrNote{***}
& -0.008\td & -0.048\TblrNote{***}
& -0.137\TblrNote{***}
& -0.017\TblrNote{***}
& -0.126\TblrNote{***}
& -0.137\TblrNote{***}
& -0.108\TblrNote{***}
& -0.167*** \\
%
& (0.006) & (0.010) & (0.008) & (0.005) & (0.004) & (0.006)
& (0.008) & (0.005) & (0.009) & (0.005) & (0.008) & (0.013) \\
\midrule
Num.Obs.
& {{{570}}} & {{{528}}} & {{{498}}} & {{{525}}} & {{{420}}} & {{{513}}}
& {{{570}}} & {{{510}}} & {{{540}}} & {{{480}}} & {{{510}}} & {{{540}}} \\
R2 & 0.863 & 0.813 & 0.882 & 0.903 & 0.941 & 0.904
& 0.808 & 0.904 & 0.726 & 0.873 & 0.805 & 0.797 \\
R2 Adj.
& 0.849 & 0.793 & 0.869 & 0.893 & 0.934 & 0.894
& 0.789 & 0.894 & 0.698 & 0.859 & 0.785 & 0.776 \\
R2 Within
& & & & & & & & & & & & \\
R2 Pseudo
& & & & & & & & & & & & \\
AIC & {{{-2623.7}}} & {{{-1828.7}}} & {{{-2054.8}}} & {{{-2417.0}}} & {{{-2337.2}}} & {{{-2306.4}}}
& {{{-2350.7}}} & {{{-2414.6}}} & {{{-2013.0}}} & {{{-2159.1}}} & {{{-2125.1}}} & {{{-1679.2}}} \\
BIC & {{{-2393.4}}} & {{{-1606.7}}} & {{{-1844.3}}} & {{{-2203.8}}} & {{{-2163.4}}} & {{{-2090.1}}}
& {{{-2120.4}}} & {{{-2207.1}}} & {{{-1794.2}}} & {{{-1962.9}}} & {{{-1917.6}}} & {{{-1460.3}}} \\
Log.Lik.
&{{{1364.856}}} & {{{966.334}}} &{{{1077.391}}} &{{{1258.501}}} &{{{1211.581}}} & {{{1204.196}}}
&{{{1228.360}}} &{{{1256.318}}} &{{{1057.525}}} &{{{1126.532}}} &{{{1111.542}}} & {{{890.587}}} \\
{Std. Errors\\ defined by:}
& {{{Delstat}}} & {{{Delstat}}} & {{{Delstat}}} & {{{Delstat}}} & {{{Delstat}}} & {{{Delstat}}}
& {{{Delstat}}} & {{{Delstat}}} & {{{Delstat}}} & {{{Delstat}}} & {{{Delstat}}} & {{{Delstat}}} \\
\bottomrule
\end{talltblr}
\end{sideways}
\end{center}
\end{document}
如您所见,列标题的名称已缩短,所有\num{...}
表达式都由列替换S
,因为表使用了tabularray
包。
编辑:添加的是表格中缺失的部分..