Ich versuche, der folgenden Tabelle einen Titel und eine Notiz hinzuzufügen:
\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}
Dies ist mein Versuch:
\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}
Dies liefert jedoch nicht das, was ich möchte. Außerdem möchte ich, dass die Tabelle zentriert ist.
Kann mir jemand helfen?
Vielen Dank!
Antwort1
Ich werde den Syntaxunterschied zwischen threeparttable
für normale Tabellen und erläutern threeparttablex
, der für Tabellen verwendet wird, die über mehrere Seiten verteilt sind. Ich habe einige Verbesserungen mit \extrarowheight
und den Regeln von hinzugefügt booktabs
, wobei Regeln mit unterschiedlicher Dicke eingeführt und für diese Regeln etwas vertikale Polsterung hinzugefügt wird:
\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}
Antwort2
Da (a) Sie keine Anweisungen verwenden \tnote
, (b) die Überschrift recht kurz ist und (c) eine der wichtigsten, bislang jedoch unbeachteten Formatierungsaufgaben darin besteht, zu verhindern, dass der Tabelleninhalt die Größe überschreitet \textwidth
, halte ich die Verwendung einer threeparttable
Umgebung nicht für besonders sinnvoll.
Verwenden Sie einfach eine tabularx
Umgebung, um Zeilenumbrüche in den Kopfzellen zuzulassen, und setzen Sie die längere Legende als normalen Text unterhalb der tabularx
Umgebung.
\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}
Antwort3
Wenn Ihre Tabelle wirklich so lang ist, dass sie auf zwei Seiten aufgeteilt werden muss, können Sie die Verwendung von und in Erwägung ziehen xltabular
( [referable]{threeparttablex}
um makecell
mehr vertikalen Platz um den Zellinhalt herum hinzuzufügen):
\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}
Nach zweimaliger Kompilierung sieht die Tabelle wie folgt aus:
Nachtrag: Angesichts@UnaKommentar: Hier ist die Version Ihrer Tabelle mit Anmerkungen oben im ersten Teil der Tabelle:
\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}