我正在尝试向下表添加标题和注释:
\documentclass{article}
\usepackage{longtable,pdflscape}
\begin{document}
\begin{longtable}[{l*{6}{c}r}]
\hline
& Gov. Rev & Gov. Exp & Interest Rate & DFPA & GDP & Inflation \\
\hline
\endhead
\textit{Business Cycle shock} & + & & & & + & + \\
\textit{Monetary Policy shock} & & & $-$ & & + & + \\
\textit{DFPA shock} & + & $-$ & & $-$ & & \\
\end{longtable}
\end{document}
这是我的尝试:
\documentclass{article}
\usepackage{booktabs, caption}
\usepackage{float}
\usepackage[flushleft]{threeparttable}
\begin{document}
\begin{longtable}[{l*{6}{c}r}]
\centering
\begin{threeparttable}
\caption{Identifying Sign Restrictions}
\hline
& Gov. Rev & Gov. Exp & Interest Rate & DFPA & GDP & Inflation \\
\hline
\endhead
\textit{Business Cycle shock} & + & & & & + & + \\
\textit{Monetary Policy shock} & & & $-$ & & + & + \\
\textit{DFPA shock} & + & $-$ & & $-$ & & \\
\begin{tablenotes}
\small
\item \textit{Note}: This table shows the sign restrictions on the impulse responses for each identified shock. A \enquote{$+$} means that the impulse response of the variable in question is restricted to be positive for six months following the shock, including the month of impact. Likewise, a \enquote{$-$} indicates a negative response. A blank entry indicates that no restrictions have been imposed.
\end{tablenotes}
\end{threeparttable}
\end{longtable}
\end{document}
但这并没有达到我想要的效果。此外,我希望桌子能居中。
谁能帮我?
多谢!
答案1
threeparttable
我将说明普通表格和threeparttablex
用于跨页表格的语法差异。我对\extrarowheight
和规则进行了一些改进booktabs
,引入了不同厚度的规则,并为这些规则添加了一些垂直填充:
\documentclass{article}
\usepackage{array, booktabs, caption, longtable, booktabs, makecell}
\usepackage{csquotes}
\usepackage{float}
\usepackage[flushleft]{threeparttablex}
\begin{document}
\setlength{\extrarowheight}{2pt}
\begin{ThreePartTable} \centering
\begin{TableNotes}
\small
\item\hskip -\fontdimen2\font\textit{Note}: This table shows the sign restrictions on the impulse responses for each identified shock. A \enquote{$+$} means that the impulse response of the variable in question is restricted to be positive for six months following the shock, including the month of impact. Likewise, a \enquote{$-$} indicates a negative response. A blank entry indicates that no restrictions have been imposed.
\end{TableNotes}
\begin{longtable}{l*{6}{c}r}
\caption{Identifying Sign Restrictions}\\
\toprule
& \makecell{Gov.\\ Rev} & \makecell{Gov.\\Exp} & \makecell{Interest\\ Rate} & DFPA & GDP & Inflation \\
\midrule
\endfirsthead
\midrule
& \makecell{Gov.\\ Rev} & \makecell{Gov.\\ Exp} &\makecell{Interest\\ Rate} & DFPA & GDP & Inflation \\
\midrule
\endhead
\bottomrule
\insertTableNotes
\endlastfoot
\textit{Business Cycle shock} & + & & & & + & + \\
\textit{Monetary Policy shock} & & & $-$ & & + & + \\
\textit{DFPA shock} & + & $-$ & & $-$ & & \\
\end{longtable}
\end{ThreePartTable}
\begin{table}[!h]
\begin{threeparttable}
\centering
\caption{Identifying Sign Restrictions}
\begin{tabular}{@{}l*{6}{c}@{}}
\toprule
& \makecell{Gov.\\ Rev} & \makecell{Gov.\\ Exp} & \makecell{Interest\\ Rate} & DFPA & GDP & Inflation \\
\midrule
\textit{Business Cycle shock} & + & & & & + & + \\
\textit{Monetary Policy shock} & & & $-$ & & + & + \\
\textit{DFPA shock} & + & $-$ & & $-$ & & \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item\hskip -\fontdimen2\font\textit{Note}: This table shows the sign restrictions on the impulse responses for each identified shock. A \enquote{$+$} means that the impulse response of the variable in question is restricted to be positive for six months following the shock, including the month of impact. Likewise, a \enquote{$-$} indicates a negative response. A blank entry indicates that no restrictions have been imposed.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
答案2
由于(a)您没有使用任何\tnote
指令,(b)标题很短,并且(c)主要但迄今为止未解决的格式化任务之一是防止表格材料超出\textwidth
,所以我认为使用threeparttable
环境并不是那么有用。
只需使用一个tabularx
环境来允许在标题单元格中换行,并将较长的图例排版为tabularx
环境下方的普通文本。
\documentclass{article}
\usepackage{booktabs,tabularx,ragged2e}
\newcolumntype{C}{>{\Centering\hspace{0pt}}X}
\usepackage[skip=0.333\baselineskip]{caption}
\usepackage[english=american]{csquotes} % select suitable language options
\begin{document}
\begin{table}
\setlength\tabcolsep{3.5pt} % default: 6pt
\caption{Identifying Sign Restrictions}
\begin{tabularx}{\textwidth}{@{} >{\itshape}l *{6}{C} @{}}
\toprule
& Gov. Rev & Gov. Exp & Interest Rate & DFPA & GDP & Inflation \\
\midrule
Business Cycle shock &$+$& & & &$+$&$+$ \\
Monetary Policy shock & & &$-$& &$+$&$+$ \\
DFPA shock &$+$&$-$& &$-$& & \\
\bottomrule
\end{tabularx}
\medskip
\textit{Note}: This table shows the sign restrictions on the impulse responses for each identified shock. A~\enquote{$+$} means that the impulse response of the variable in question is restricted to be positive for six months following the shock, including the month of impact. Likewise, a~\enquote{$-$} indicates a negative response. A blank entry indicates that no restrictions have been imposed.
\end{table}
\end{document}
答案3
如果您的表格真的很长,必须分成两页,那么您可以考虑使用xltabular
,[referable]{threeparttablex}
和makecell
(用于在单元格内容周围添加更多垂直空间):
\documentclass{article}
\usepackage[skip=1ex]{caption}
\usepackage{booktabs, makecell, xltabular}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage[referable, flushleft]{threeparttablex}
\usepackage{csquotes}
\usepackage{lipsum}
\begin{document}
\lipsum[1-4]
\begin{ThreePartTable}
\setlength\tabcolsep{3pt} % default: 6pt
\setcellgapes{2pt}
\makegapedcells
\begin{TableNotes}\small
\note{This table shows the sign restrictions on the impulse responses for each identified shock. A \enquote{$+$} means that the impulse response of the variable in question is restricted to be positive for six months following the shock, including the month of impact. Likewise, a \enquote{$-$} indicates a negative response. A blank entry indicates that no restrictions have been imposed.}
\end{TableNotes}
\begin{xltabular}{\linewidth}{@{}>{\itshape}l *{6}{C} @{}}
\caption{Identifying Sign Restrictions}
\label{tab:lonmngtable} \\
\toprule
& Gov. Rev
& Gov. Exp
& Interest Rate
& DFPA & GDP & Infla\-tion \\
\midrule
\endfirsthead
\caption[]{Identifying Sign Restrictions (cont.)} \\
\toprule
& \makecell{Gov.\\ Rev}
& \makecell{Gov.\\Exp}
& \makecell{Interest\\ Rate}
& DFPA & GDP & Inflation \\
\midrule
\endhead
\bottomrule
\multicolumn{7}{r}{\footnotesize\textit{Continue on the next page}}
\endfoot
\bottomrule
\insertTableNotes
\endlastfoot
Business Cycle shock & + & & & & + & + \\
Monetary Policy shock & & & $-$ & & + & + \\
DFPA shock & + & $-$ & & $-$ & & \\
xxxx shock & + & $-$ & & $-$ & & \\
xxxx shock & + & $-$ & & $-$ & & \\
\end{xltabular}
\end{ThreePartTable}
\end{document}
经过两次编译后,表格如下:
附录: 考虑到@Una评论,这是您的表格的版本,其中在表格第一部分的顶部有注释:
\usepackage[skip=1ex]{caption}
\usepackage{booktabs, makecell, xltabular}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage[referable, flushleft]{threeparttablex}
\usepackage{csquotes}
\usepackage{lipsum}
\begin{document}
\lipsum[1-3]
\begin{ThreePartTable}
\setlength\tabcolsep{3pt} % default: 6pt
\setcellgapes{2pt}
\makegapedcells
\begin{TableNotes}\small
\note{This table shows the sign restrictions on the impulse responses for each identified shock. A \enquote{$+$} means that the impulse response of the variable in question is restricted to be positive for six months following the shock, including the month of impact. Likewise, a \enquote{$-$} indicates a negative response. A blank entry indicates that no restrictions have been imposed.}
\end{TableNotes}
\begin{xltabular}{\linewidth}{@{}>{\itshape}l *{6}{C} @{}}
\caption{Identifying Sign Restrictions}
\label{tab:lonmngtable} \\
\insertTableNotes \\
\toprule
& Gov. Rev
& Gov. Exp
& Interest Rate
& DFPA & GDP & Infla\-tion \\
\midrule
\endfirsthead
\caption[]{Identifying Sign Restrictions (cont.)} \\
\toprule
& \makecell{Gov.\\ Rev}
& \makecell{Gov.\\Exp}
& \makecell{Interest\\ Rate}
& DFPA & GDP & Inflation \\
\midrule
\endhead
\bottomrule
\multicolumn{7}{r}{\footnotesize\textit{Continue on the next page}}
\endfoot
\bottomrule
\endlastfoot
Business Cycle shock & + & & & & + & + \\
Monetary Policy shock & & & $-$ & & + & + \\
DFPA shock & + & $-$ & & $-$ & & \\
xxxx shock & + & $-$ & & $-$ & & \\
xxxx shock & + & $-$ & & $-$ & & \\
\end{xltabular}
\end{ThreePartTable}
\end{document}