저는 Stata용 Benn Jan의 esttab 명령을 사용하고 Jörg Weber가 제공한 유용한 팁을 사용하여 그 결과를 LaTeX 문서 초안과 결합하고 있습니다. 회귀 테이블에 일부 비표준 결과를 포함하고 싶지만 이를 선으로 구분하고 자막과 연결할 수도 있습니다. Stata의 do 파일은 다음과 같습니다:
sysuse auto, clear
reg mpg weight length i.foreign, robust
test weight+length=0
estadd scalar f_test=r(F)
estadd scalar ppdiff=r(p)
lincom weight+length
estadd scalar marginal=r(estimate)
est store A
esttab A using auto.tex, replace nonotes nomtitles f ///
label booktabs b(3) alignment(S) eqlabels(none) ///
drop(0.foreign) star(* 0.10 ** 0.05 *** 0.01) stats(marginal f_test ppdiff N r2, ///
fmt(3 3 3 %9.0gc 3) layout("\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}" "\multicolumn{1}{c}{@}") ///
labels(`"Hypothesis test"' `"F-test"' `"p-value"' `"Observations"' `"\(R^{2}\)"'))
관련 LaTeX 코드는 다음과 같습니다.
\documentclass[12pt,A4,fleqn]{article} % fleqn: align equations left
% Document:
\usepackage{geometry} % Custom margins for single page, etc.
\usepackage{fullpage} % Use the full page
\usepackage{setspace} % Enables custom margins, doublespacing, etc.
\usepackage{pdflscape} % Use: \begin{landscape} ... \end{landscape}
\usepackage{bm}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{lscape}
\usepackage{datetime}
\usepackage{longtable}
\usepackage{lscape} % To create a table in a landscape environment
\usepackage{rotating} % To use sideways table
\usepackage{rotfloat} % Use H with a sideways table
\usepackage{mathtools}
\usepackage{bibentry}
\usepackage{graphics}
\usepackage{threeparttable}
\usepackage{siunitx}
\usepackage{booktabs,dcolumn}
\usepackage{array}
\usepackage{hyperref}
% Font/text:
\usepackage[latin9]{inputenc} % Font definition and input type
\usepackage[T1]{fontenc} % Font output type
\usepackage{lmodern} % Latin Modern fonts
\usepackage{textcomp} % Supports many additional symbols
\usepackage{amsmath} % Math equations, etc.
\usepackage{amsthm} % Math theorems, etc.
\usepackage{amsfonts} % Math fonts (e.g. script fonts)
\usepackage{amssymb} % Math symbols such as infinity
\DeclareMathOperator*{\Max}{Max} % Better looking max function
\DeclareMathOperator*{\Min}{Min} % Better looking min function
\usepackage{color} % Enables colored text
\definecolor{darkblue}{rgb}{0.0,0.0,0.66} % Custom color: dark blue
\usepackage[hyperfootnotes=false,bookmarksopen]{hyperref} % Enable hyperlinks, expand menu subtree
\hypersetup{ % Custom hyperlink settings
pdffitwindow=false, % true: window fit to page when opened
pdfstartview={XYZ null null 1.00}, % Fits the default zoom of the page to 100%
pdfnewwindow=true, % Links in new window
colorlinks=true, % false: boxed links; true: colored links
linkcolor=darkblue, % Color of internal links
citecolor=darkblue, % Color of links to bibliography
urlcolor=darkblue } % Color of external links
%\usepackage{kpfonts} % for nice fonts
% Images:
\usepackage{graphicx} % Allows more types of images to be included
\usepackage[position=bottom]{subfig} % Enables arrayed images
\usepackage[section]{placeins} % Forces floats to stay in section
\usepackage{float} % Used with restylefloat
\restylefloat{figure} % "H" forces a figure to be "exactly here"
\usepackage[justification=centering]{caption} % Center captions
% Tables/arrays:
\usepackage{booktabs} % Table format - increases table spacing
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}} % Spacing for tables increased
\renewcommand{\arraystretch}{1} % Spaces arrays at 1x
\usepackage{dcolumn} % Align decimals in tables (as option)
%\newcolumntype{.}{D{.}{.}{-1}} % Align decimals e.g. \begin{tabular}{c...}
% Miscellaneous:
\interfootnotelinepenalty=10000 % Footnotes won't break across pages
\usepackage[semicolon]{natbib} % Bibliography and citation formating
\usepackage{datetime} % Custom date format for date field
\newdateformat{mydate}{\monthname[\THEMONTH] \THEYEAR} % Defining month year date format
%\usepackage{tikz} % Timelines and other drawings
%\usetikzlibrary{decorations} % Formating for Tikz
% *****************************************************************
% Estout related things
% *****************************************************************
\newcommand{\sym}[1]{\rlap{#1}}% Thanks to David Carlisle
\let\estinput=\input% define a new input command so that we can still flatten the document
\newcommand{\estwide}[3]{
\vspace{.75ex}{
\begin{tabular*}
{\textwidth}{@{\hskip\tabcolsep\extracolsep\fill}l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\addlinespace[.75ex]
\end{tabular*}
}
}
\newcommand{\estauto}[3]{
\centering{
\vspace{.75ex}{
\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
\newcommand{\figtext}[1]{
\vspace{-0.4ex}
\captionsetup{justification=justified,font=footnotesize}
\caption*{\hspace{6pt}\hangindent=1.5em #1}
}
\newcommand{\fignote}[1]{\figtext{\emph{Note:~}~#1}}
\newcommand{\figsource}[1]{\figtext{\emph{Source:~}~#1}}
% Add significance note with \starnote
\newcommand{\starnote}{\figtext{* p<0.1, ** p<0.05, *** p<0.01. Clustered standard errors in parentheses.}}
% *****************************************************************
% siunitx
% *****************************************************************
\usepackage{siunitx} % centering in tables
\sisetup{
detect-mode,
tight-spacing = true,
group-digits = false ,
input-signs = ,
input-symbols = ( ) [ ] - + *,
input-open-uncertainty = ,
input-close-uncertainty = ,
table-align-text-post = false
}
% *****************************************************************
% *****************************************************************
% *****************************************************************
% DOCUMENT BEGINS HERE
% *****************************************************************
% *****************************************************************
% *****************************************************************
\begin{document}
\begin{table}[h]
\caption{Auto example}
\estauto{auto}{3}{S[table-format=3.4]}
\starnote
\label{tab2}
\end{table}
\end{document}
이 예에서 "p-value"와 "Observations" 사이에 줄을 삽입하려면 어떻게 해야 합니까(do 파일만 수정하여)? 그리고 테이블의 이 부분에 일종의 식별자를 삽입하려면 어떻게 해야 합니까? 어떤 제안이라도 대단히 감사하겠습니다.