我在 LyX 中使用以下 TeX 代码创建双表。在 .pdf 中查看时,我不知道为什么标题“主标题”出现在文本面板 A:效果下方。绝对应该是相反的。您知道为什么以及我应该如何解决这些问题吗?谢谢!
%%%%%%%%%%%%%%%%%%%%%%
%% LyX 2.0.7 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[10pt,spanish]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{setspace}
\onehalfspacing
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
% Packages for tables
\usepackage{booktabs}% Pretty tables
\usepackage{threeparttablex}% For Notes below table
% *****************************************************************
% siunitx
% *****************************************************************
\newcommand{\sym}[1]{\rlap{#1}} % Thanks to Joseph Wright & David Carlisle
\usepackage{siunitx}
\sisetup{
detect-mode,
group-digits = false,
input-symbols = ( ) [ ] - +,
table-align-text-post = false,
input-signs = ,
}
% Character substitution that prints brackets and the minus symbol in text mode. Thanks to David Carlisle
\def\yyy{%
\bgroup\uccode`\~\expandafter`\string-%
\uppercase{\egroup\edef~{\noexpand\text{\llap{\textendash}\relax}}}%
\mathcode\expandafter`\string-"8000 }
\def\xxxl#1{%
\bgroup\uccode`\~\expandafter`\string#1%
\uppercase{\egroup\edef~{\noexpand\text{\noexpand\llap{\string#1}}}}%
\mathcode\expandafter`\string#1"8000 }
\def\xxxr#1{%
\bgroup\uccode`\~\expandafter`\string#1%
\uppercase{\egroup\edef~{\noexpand\text{\noexpand\rlap{\string#1}}}}%
\mathcode\expandafter`\string#1"8000 }
\def\textsymbols{\xxxl[\xxxr]\xxxl(\xxxr)\yyy}
% *****************************************************************
% Estout related things
% *****************************************************************
\let\estinput=\input % define a new input command so that we can still flatten the document
\newcommand{\estwide}[3]{
\vspace{.75ex}{
\textsymbols% Note the added command here
\begin{tabular*}
{\textwidth}{@{\hskip\tabcolsep\extracolsep\fill}l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular*}
}
}
\newcommand{\estauto}[3]{
\vspace{.75ex}{
\textsymbols% Note the added command here
\begin{tabular}{l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular}
}
}
% Allow line breaks with \\ in specialcells
\newcommand{\specialcell}[2][c]{%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}
}
% *****************************************************************
% Custom subcaptions
% *****************************************************************
% Note/Source/Text after Tables
% The new approach using threeparttables to generate notes that are the exact width of the table.
\newcommand{\Figtext}[1]{%
\begin{tablenotes}[para,flushleft]
\hspace{6pt}
\hangindent=1.75em
#1
\end{tablenotes}
}
\newcommand{\Fignote}[1]{\Figtext{\emph{Note:~}~#1}}
\newcommand{\Figsource}[1]{\Figtext{\emph{Source:~}~#1}}
\newcommand{\Starnote}{\Figtext{\textit{* p < 0.1, ** p < 0.05, *** p < 0.01.}\\ Errores est\'andares corregidos por correlaci\'on y heteroskedasticidad a nivel de escuela entre par\'entesis.}}% Add significance note with \starnote
\makeatother
\usepackage{babel}
\addto\shorthandsspanish{\spanishdeactivate{~<>}}
\begin{document}
$ $ %esto evita el error
\begin{table}[htbp]
\begin{threeparttable}
\caption{My Title}
\label{efectos_generales}
\Figtext{\textbf{Panel A: Efecto estudiante en corto plazo}} \estwide{output/raw_tables/regressions_general2.tex}{3}{c}
\Figtext{\textbf{Panel B: Efecto estudiante en mediano plazo}} \estwide{output/raw_tables/regressions_general2_1.tex}{3}{c}
\Figtext{\footnotesize{Panel A - Controles: (2)}}
\Figtext{\footnotesize{Panel B - Controles: (3)}}
\Figtext{\footnotesize{Errores est\'andares corregidos por correlaci\'on y heteroskedasticidad a nivel de escuela entre par\'entesis.\\ \textit{* p < 0.1, ** p < 0.05, *** p < 0.01.}}}
\end{threeparttable}
\end{table}
\end{document}
答案1
原因是我认为‘这就是threeparttable
工作原理’。
解决这个问题最简单的方法是将标题前环境threeparttable
,所以你有
\begin{table}[htbp]
\caption{My Title}
\label{efectos_generales}
\begin{threeparttable}
...
\end{threeparttable}
\end{table}