Estoy intentando agregar un título y una nota a la siguiente tabla:
\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}
Este es mi intento:
\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}
Sin embargo, esto no logra lo que me gustaría obtener. Además me gustaría que la mesa estuviera centrada.
¿Alguien puede ayudarme?
¡Muchas gracias!
Respuesta1
Ilustraré la diferencia de sintaxis entre threeparttable
tablas ordinarias y threeparttablex
tablas que se dividen en páginas. Agregué algunas mejoras \extrarowheight
y las reglas booktabs
que introducen reglas con espesor variable y agrega algo de relleno vertical para estas reglas:
\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}
Respuesta2
Dado que (a) no está utilizando ninguna \tnote
directiva, (b) el título es bastante corto y (c) una de las principales tareas de formato, pero hasta ahora no abordada, es evitar que el material tabular exceda \textwidth
, no creo que usar un threeparttable
entorno es muy útil.
Simplemente emplee un tabularx
entorno para permitir saltos de línea en las celdas del encabezado y escriba la leyenda más larga como texto normal debajo del tabularx
entorno.
\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}
Respuesta3
Si su tabla es realmente tan larga que debe dividirse en dos páginas, entonces puede considerar usar xltabular
y [referable]{threeparttablex}
( makecell
para agregar más espacio vertical alrededor del contenido de las celdas):
\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}
Después de dos compilaciones la tabla es:
Apéndice: Considerando@Unacomentario, aquí está la versión de su tabla con notas en la parte superior de la primera parte de la tabla:
\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}