我有一张相当宽的表格(13 列),我将其从 Excel 转换为 LaTex。我使用 resizebox 使表格适合页面。但表格中的数字很小。有什么建议可以改变这种情况吗?我不希望标题文本发生变化,表格也应该适合页面。
这是我的基本代码:
\usepackage{pdflscape}
\usepackage[left=1.0in, right=1.0in, top=1.0in, bottom=1.0in]{geometry}
\usepackage[table]{xcolor}
\usepackage{layout}
\usepackage{footnote}
\usepackage{epstopdf}
\usepackage{lscape}
\usepackage{rotating}
\usepackage{subfigure}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{longtable}
\usepackage{color}
\usepackage{natbib}
\usepackage{setspace}
\usepackage{multirow}
\usepackage{caption}
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{float}
\usepackage{adjustbox}
\usepackage[normalem]{ulem}
\usepackage{xr}
\usepackage{longtable}
%*****The commands below define new column types suited for variable description************
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
\begin{landscape}
\begin{center}
\begin{scriptsize}
\begin{table}[htb]
\centering
\captionsetup{singlelinecheck=off}
\caption[.]{\textbf{This is a test table}\newline
\footnotesize{ This table reports estimates from the following panel regression model:
\begin{equation*}
\begin{split}
ABCD\textsuperscript{xyz}Firm_{ijt}=\alpha_0+\beta_{1}\times FirmSize_{ijt} +\beta_{2} \times FirmAge_{it}+\beta_{3} \times Profit_{jt} \times FirmSize_{j} \\
+ \beta_{4} \times FirmAge_{ijt} \times Profits_{j} +
\beta_{5} \times Market_{ijt} \times Profits_{j} +
\phi_{j}+\gamma_{t}+\varepsilon_{ijt}
\end{split}
\end{equation*}
A big caption (9 lines of text) goes here describing all the variables
}
}
\resizebox{1\textwidth}{!}{
\begin{tabular}{lcccc|cccc|cccc|}
\toprule
\multicolumn{7}{l}{\textbf{Panel A: Some text here}} \\
\midrule
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
\midrule
& ABCD\textsuperscript{xyz}Firm & ABCD\textsuperscript{xyz}Firm & ABCD\textsuperscript{xyz}Firm & ABCD\textsuperscript{xyz}Firm & ABCD\textsuperscript{xyz}Firm & ABCD\textsuperscript{xyz}Firm & ABCD\textsuperscript{xyz}Firm & ABCD\textsuperscript{xyz}Firm & ABCD\textsuperscript{xyz}Firm & ABCD\textsuperscript{xyz}Firm & ABCD\textsuperscript{xyz}Firm & ABCD\textsuperscript{xyz}Firm \\
\midrule
& ABCD & ABCD & ABCD & ABCD & EFGH & EFGH & EFGH & EFGH & PQRS & PQRS & PQRS & PQRS \\
\midrule
FirmSize & 0.027*** & 0.023*** & 0.023*** & 0.023*** & 0.008*** & 0.033*** & 0.043*** & 0.063*** & 0.025*** & 0.043*** & 0.053*** & 0.063*** \\
& (0.003) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) \\
FirmAge & -0.096*** & -0.097*** & -0.097*** & -0.098*** & -0.097*** & -0.088*** & -0.088*** & -0.088*** & -0.097*** & -0.097*** & -0.088*** & -0.068*** \\
& (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) \\
Mkt & 0.043 & 0.053 & 0.166** & 0.035 & 0.027 & 0.043 & 0.056 & 0.012 & 0.032 & 0.044 & 0.118 & 0.020 \\
& (0.088) & (0.088) & (0.228) & (0.088) & (0.090) & (0.089) & (0.092) & (0.091) & (0.089) & (0.089) & (0.215) & (0.090) \\
Share & 0.114 & 0.011 & 0.011 & 0.999 & 0.127 & 0.035 & 0.044 & 0.056 & 0.312 & 0.039 & 0.056 & 0.679 \\
& (0.124) & (0.119) & (0.119) & (0.308) & (0.121) & (0.119) & (0.119) & (0.119) & (0.120) & (0.119) & (0.120) & (0.285) \\
Profits & 0.3*** & 0.276*** & 0.264*** & 0.264*** & 0.267*** & 0.254*** & 0.265*** & 0.265*** & 0.268*** & 0.269*** & 0.266*** & 0.265*** \\
& (0.026) & (0.026) & (0.026) & (0.026) & (0.026) & (0.028) & (0.026) & (0.026) & (0.026) & (0.026) & (0.026) & (0.026) \\
FirmSize x Profits & -0.011*** & & & & 0.010*** & & & & 0.013*** & & & \\
& (0.003) & & & & (0.003) & & & & (0.004) & & & \\
FirmAge x Profits & & -0.042** & & & & 0.049 & & & & 0.038 & & \\
& & (0.018) & & & & (0.02) & & & & (0.023) & & \\
Mkt x Profits & & & -0.668*** & & & & -0.006 & & & & 0.327 & \\
& & & (0.246) & & & & (0.203) & & & & (0.305) & \\
Share x Profits & & & & -0.560 & & & & 0.123 & & & & 0.327 \\
& & & & (0.355) & & & & (0.435) & & & & (0.500) \\
N & 60000 & 60000 & 60000 & 60000 & 60000 & 60000 & 60000 & 60000 & 60000 & 60000 & 60000 & 60000 \\
adj. R-sq & 0.067 & 0.076 & 0.072 & 0.079 & 0.067 & 0.075 & 0.074 & 0.064 & 0.079 & 0.075 & 0.072 & 0.074 \\
\cmidrule(lr){2-5} \cmidrule(lr){6-9} \cmidrule(l){10-13}
Fixed Effects
& \multicolumn{4}{c}{Industry, Year}
& \multicolumn{4}{c}{Industry, Year}
& \multicolumn{4}{c}{Industry, Year} \\
\bottomrule
\end{tabular}%
}
\end{table}
\end{scriptsize}
答案1
我建议不要使用scriptsize
,lscape
而是使用sidewaystable
。
您可以使用 填充宽度tabular*
。
无论如何,将表格从 Excel 转换为 LaTeX 需要一些手工操作。
\documentclass{article}
\usepackage[left=1.0in, right=1.0in, top=1.0in, bottom=1.0in]{geometry}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{caption}
\begin{document}
\begin{sidewaystable}
\centering
\captionsetup{singlelinecheck=off}
\caption[This is a test table]{This is a test table}
\begin{minipage}{\textwidth}
\footnotesize
This table reports estimates from the following panel regression model:
\begin{equation*}
\begin{split}
A_{ijt}&=\alpha_0+\beta_{1}\times B_{ijt} \times C_{j}+\beta_{2} \times
D_{it}+\beta_{3} \times E_{jt} \times F_{j} \\
&\qquad+ \beta_{4} \times G_{ijt} \times H_{j} +
\beta_{5} \times I_{ijt} \times J_{j} +
\phi_{j}+\gamma_{t}+\varepsilon_{ijt}
\end{split}
\end{equation*}
A big caption goes here describing all the variables
\end{minipage}
\medskip
\small
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}l*{12}{c}}
\toprule
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
\midrule
& Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y & Y \\
& Vari & Vari & Vari & Vari & Vari & Vari & Vari & Vari & Vari & Vari & Vari & Vari \\
\midrule
A & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\midrule
B & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\midrule
C & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\midrule
D & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\midrule
E & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\midrule
F & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\midrule
G & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\midrule
H & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\midrule
I & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\midrule
N & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\midrule
AR & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\cmidrule(lr){2-5} \cmidrule(lr){6-9} \cmidrule(l){10-13}
XYZ
& \multicolumn{4}{c}{Some text}
& \multicolumn{4}{c}{Some text}
& \multicolumn{4}{c}{Some text} \\
\bottomrule
\end{tabular*}
\end{sidewaystable}
\end{document}
答案2
(在 OP 提供了更具代表性的数字和表格的其他单元格后更新了答案)
没有必要诉诸\resizebox
。由于您的 12 个数据列标题非常宽(并且似乎没有明显的换行点),因此有必要将表格材料的主体从 切换\scriptsize
到。\tiny
如果您使用包的线条绘制宏booktabs
,请不要使用垂直线。没有例外。无论如何,表格中几乎不需要垂直线。真的。
请注意,在论证中塞入大量材料是没有必要的,甚至不是一个好主意\caption
。这些材料大部分是图例,而不是标题。
如果所有数字都按小数点对齐,数字数据材料的可读性和可理解性将会增强。
最后但同样重要的一点是,您还应该努力从序言中删除多余的内容。在下面的代码中,我尝试开始。您一定要确定哪些包在您的文档中根本没有使用 - 因此不应该从一开始就加载。
\documentclass[11pt,a4paper]{article} % or 'letterpaper', as appropriate
\usepackage{pdflscape}
\usepackage[margin=1in]{geometry}
\usepackage[table]{xcolor}
\usepackage{layout}
\usepackage{footnote}
%%\usepackage{epstopdf} % shouldn't be needed
%%\usepackage{lscape} % don't load both 'pdflscape' and 'lscape'
\usepackage{rotating}
%\usepackage{subfigure} % deprecated -- don't use!
%\usepackage{graphicx} % is loaded by 'rotating' package
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{setspace}
%%\usepackage{amsfonts} % is loaded automatically by 'amssymb' package
\usepackage{amssymb}
\usepackage{longtable}
%\usepackage{color} % don't load since 'xcolor' is already loaded
\usepackage{natbib}
%%\usepackage{setspace} % don't load a package more than once
\usepackage{multirow}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{float}
\usepackage{adjustbox}
\usepackage[normalem]{ulem}
\usepackage{xr}
%%\usepackage{longtable} % don't load a package more than once
\usepackage{array}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\vn[1]{\mathrm{#1}} % "variable name"
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\usepackage{hyperref} % be sure to load this package **last**
\begin{document}
\begin{sidewaystable}
\scriptsize
\setlength\tabcolsep{0pt} % make LaTeX figure out intercolumn space
\captionsetup{singlelinecheck=off,
font=scriptsize, textfont=bf,
skip=0.5\baselineskip}
\caption{This is a test table}
This table reports estimates from the following panel regression model:
\begin{equation*}
\begin{split}
\vn{ABCD\textsuperscript{xyz}Firm}_{ijt}
&=\alpha_0+\beta_{1}\times \vn{FirmSize}_{ijt}
+\beta_{2}\times \vn{FirmAge}_{it}
+\beta_{3}\times \vn{Profit}_{jt} \times \vn{FirmSize}_{j} \\
&\quad +\beta_{4}\times \vn{FirmAge}_{ijt} \times \vn{Profits}_{j}
+\beta_{5}\times \vn{Market}_{ijt} \times \vn{Profits}_{j}
+\phi_{j}+\gamma_{t}+\varepsilon_{ijt}
\end{split}
\end{equation*}
A big legend (9 lines of text) goes here describing all the variables.
\smallskip
\tiny
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
l*{12}{d{2.5}}}
\toprule
\multicolumn{7}{l}{\textbf{Panel A: Some text here}} \\
\cmidrule(lr){2-5} \cmidrule(lr){6-9} \cmidrule(l){10-13}
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 \\
\addlinespace %\midrule
& \mc{ABCD\textsuperscript{xyz}Firm}
& \mc{ABCD\textsuperscript{xyz}Firm}
& \mc{ABCD\textsuperscript{xyz}Firm}
& \mc{ABCD\textsuperscript{xyz}Firm}
& \mc{ABCD\textsuperscript{xyz}Firm}
& \mc{ABCD\textsuperscript{xyz}Firm}
& \mc{ABCD\textsuperscript{xyz}Firm}
& \mc{ABCD\textsuperscript{xyz}Firm}
& \mc{ABCD\textsuperscript{xyz}Firm}
& \mc{ABCD\textsuperscript{xyz}Firm}
& \mc{ABCD\textsuperscript{xyz}Firm}
& \mc{ABCD\textsuperscript{xyz}Firm} \\
\addlinespace %\midrule
& \mc{ABCD} & \mc{ABCD} & \mc{ABCD} & \mc{ABCD}
& \mc{EFGH} & \mc{EFGH} & \mc{EFGH} & \mc{EFGH}
& \mc{PQRS} & \mc{PQRS} & \mc{PQRS} & \mc{PQRS} \\
\midrule
FirmSize & 0.027^{***} & 0.023^{***} & 0.023^{***} & 0.023^{***} & 0.008^{***} & 0.033^{***} & 0.043^{***} & 0.063^{***} & 0.025^{***} & 0.043^{***} & 0.053^{***} & 0.063^{***} \\
& (0.003) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) & (0.002) \\
FirmAge & -0.096^{***} & -0.097^{***} & -0.097^{***} & -0.098^{***} & -0.097^{***} & -0.088^{***} & -0.088^{***} & -0.088^{***} & -0.097^{***} & -0.097^{***} & -0.088^{***} & -0.068^{***} \\
& (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) & (0.005) \\
Mkt & 0.043 & 0.053 & 0.166** & 0.035 & 0.027 & 0.043 & 0.056 & 0.012 & 0.032 & 0.044 & 0.118 & 0.020 \\
& (0.088) & (0.088) & (0.228) & (0.088) & (0.090) & (0.089) & (0.092) & (0.091) & (0.089) & (0.089) & (0.215) & (0.090) \\
Share & 0.114 & 0.011 & 0.011 & 0.999 & 0.127 & 0.035 & 0.044 & 0.056 & 0.312 & 0.039 & 0.056 & 0.679 \\
& (0.124) & (0.119) & (0.119) & (0.308) & (0.121) & (0.119) & (0.119) & (0.119) & (0.120) & (0.119) & (0.120) & (0.285) \\
Profits & 0.3^{***} & 0.276^{***} & 0.264^{***} & 0.264^{***} & 0.267^{***} & 0.254^{***} & 0.265^{***} & 0.265^{***} & 0.268^{***} & 0.269^{***} & 0.266^{***} & 0.265^{***} \\
& (0.026) & (0.026) & (0.026) & (0.026) & (0.026) & (0.028) & (0.026) & (0.026) & (0.026) & (0.026) & (0.026) & (0.026) \\
FirmSize$\times$Profits & -0.011^{***} & & & & 0.010^{***} & & & & 0.013^{***} & & & \\
& (0.003) & & & & (0.003) & & & & (0.004) & & & \\
FirmAge$\times$Profits & & -0.042** & & & & 0.049 & & & & 0.038 & & \\
& & (0.018) & & & & (0.02) & & & & (0.023) & & \\
Mkt$\times$Profits & & & -0.668^{***} & & & & -0.006 & & & & 0.327 & \\
& & & (0.246) & & & & (0.203) & & & & (0.305) & \\
Share$\times$Profits & & & & -0.560 & & & & 0.123 & & & & 0.327 \\
& & & & (0.355) & & & & (0.435) & & & & (0.500) \\
\addlinespace
N & \mc{60000} & \mc{60000} & \mc{60000} & \mc{60000} & \mc{60000} & \mc{60000}
& \mc{60000} & \mc{60000} & \mc{60000} & \mc{60000} & \mc{60000} & \mc{60000} \\
adj.\ R-sq & 0.067 & 0.076 & 0.072 & 0.079 & 0.067 & 0.075 & 0.074 & 0.064 & 0.079 & 0.075 & 0.072 & 0.074 \\
\cmidrule(lr){2-5} \cmidrule(lr){6-9} \cmidrule(l){10-13}
Fixed Effects
& \multicolumn{4}{c}{Industry, Year}
& \multicolumn{4}{c}{Industry, Year}
& \multicolumn{4}{c}{Industry, Year} \\
\bottomrule
\end{tabular*}
\end{sidewaystable}
\end{document}
答案3
根据此评论,这里有一个建议sidewaystable
与包结合使用siunitx
来对齐数字:
\documentclass[11pt]{article}
\usepackage[left=1.0in, right=1.0in, top=1.0in, bottom=1.0in]{geometry}
\usepackage{rotating}
\usepackage{amsmath}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{float}
\usepackage{siunitx}
\begin{document}
\begin{sidewaystable}
\captionsetup{singlelinecheck=off}
\caption{\textbf{This is a test table}}\vspace{-0.5\baselineskip}
{\footnotesize This table reports estimates from the following panel regression model:
\begin{equation*}
\begin{split}
A_{ijt}=\alpha_0+\beta_{1}\times B_{ijt} \times C_{j}+\beta_{2} \times
D_{it}+\beta_{3} \times E_{jt} \times F_{j} \\
+ \beta_{4} \times G_{ijt} \times H_{j} +
\beta_{5} \times I_{ijt} \times J_{j} +
\phi_{j}+\gamma_{t}+\varepsilon_{ijt}
\end{split}
\end{equation*}
A big caption goes here describing all the variables
}
\centering \medskip
\begin{tabular}{l*{12}{S[table-format=3.3]}}
\toprule
& {1} & {2} & {3} & {4} & {5} & {6} & {7} & {8} & {9} & {10} & {11} & {12} \\
\midrule
& {Y} & {Y} & {Y} & {Y} & {Y} & {Y} & {Y} & {Y} & {Y} & {Y} & {Y} & {Y} \\
& {Vari} & {Vari} & {Vari} & {Vari} & {Vari} & {Vari} & {Vari} & {Vari} & {Vari} & {Vari} & {Vari} & {Vari} \\
\midrule
A & 123.456 & 123.456 & 123.456 & 123.456 & 123.456 & 123.456 & 123.456 & 123.456 & 123.456 & 123.456 & 123.456 & 123.456 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\[3pt]
B & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\[3pt]
C & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\[3pt]
D & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\[3pt]
E & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\[3pt]
F & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\[3pt]
G & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\[3pt]
H & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\[3pt]
I & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
& 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\[3pt]
N & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
AR & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
\cmidrule(lr){2-5} \cmidrule(lr){6-9} \cmidrule(lr){10-13}
{XYZ} & \multicolumn{4}{c}{Some text} & \multicolumn{4}{c}{Some text} & \multicolumn{4}{c}{Some text} \\
\bottomrule
\end{tabular}
\end{sidewaystable}
\end{document}