When I output a table of regression results from Stata to latex using esttab, style(tex), it includes a phrase -- \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} -- at the top of the table code as shown below. I believe this phrase defines my star symbols. I.e., is provided to define \sym{*}, \sym{**}, \sym{***} within the tables.
Example:
{
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{tabular}{l*{5}{c}}
\toprule
--TABLE GUTS--
\bottomrule
\end{tabular}
}
However, (1) I don't need this phrase within my latex tables, because I've added this line at the top of my latex doc and tables compile fine without it. (2) For some odd reason beamer can't read tables with this phrase inside. So I can't use the same table for beamer that I'm using for latex.
Can anyone tell me how to either (A) repress this phrase from Stata, i.e. via my esttab specification, or better yet (B) allow beamer to read tables that have this phrase in the table as shown above?
Note on Option A: I do realize that I can repress the output by adding , fragment to my esttab, and then adding the necessary tabular text manually with prehead(), posthead(), prefoot(), postfoot(). Maybe I'll go that route. But this is sort of a pain, so I'm looking for a solution that JUST deletes the \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} bit. I realize this probably doesnt exist, but I'm guessing option (B) does exist.
I'm working in TexShop on a mac, in case this is a version-specific problem with beamer.
ADDITION: Here is an example of my problem. The code below does not compile. However, if you delete the \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} at the top, it compiles just fine. Note that I have added [fragile] as suggested, but it doesn't seem to help. Perhaps I have a package loaded that's interacting with the fragile environment, or that's causing the problem in the first place? Some of these packages came with my beamer model I adopted from Cameron Bracken. Others I've added over time for various reasons, and at this point it's a mess of packages some of which I do not need for this particular presentation. So I'm totally up for changing some of the loaded packages if helpful.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This Beamer template was created by Cameron Bracken.
%% Anyone can freely use or modify it for any purpose
%% without attribution.
%%
%% Last Modified: January 9, 2009
%%
\documentclass[xcolor=x11names,compress]{beamer}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% General document %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows,matrix,positioning}
\usetikzlibrary{decorations.fractals}
\usepackage{float} % Allows my mini-page figure things
\usepackage{graphicx} % Allows including images
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage[framemethod=tikz]{mdframed}
\usepackage{lipsum}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Beamer Layout %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\useoutertheme[subsection=false,shadow]{miniframes}
\useinnertheme{default}
\usefonttheme{serif}
\usepackage{palatino}
\usepackage{xcolor}
\usepackage{geometry}
\setbeamerfont{title like}{shape=\scshape}
\setbeamerfont{frametitle}{shape=\scshape}
\usepackage[flushleft]{threeparttable}
\setbeamercolor*{lower separation line head}{bg=DeepSkyBlue4}
\setbeamercolor*{normal text}{fg=black,bg=white}
\setbeamercolor*{alerted text}{fg=red}
\setbeamercolor*{example text}{fg=black}
\setbeamercolor*{structure}{fg=black}
\setbeamercolor*{palette tertiary}{fg=black,bg=black!10}
\setbeamercolor*{palette quaternary}{fg=black,bg=black!10}
\renewcommand{\(}{\begin{columns}}
\renewcommand{\)}{\end{columns}}
\newcommand{\<}[1]{\begin{column}{#1}}
\renewcommand{\>}{\end{column}}
\setbeamertemplate{itemize items}[circle]
\setbeamertemplate{itemize subitems}[circle]
\setbeamercovered{transparent}
\setbeamertemplate{caption}{\insertcaption} % this gets rid of "figure" in front of figure captions
%\usepackage{lmodern} % these two allow me to align math equations w/in columns
%\usepackage{amsmath,amssymb}
\usepackage{bbm} % to use indicator function mathbbm{1}
\usepackage[percent]{overpic} % allows to write over pictures
\usepackage{wrapfig} % wrap text around fig
\usepackage{array} % for this stupid formatting that was automated when i converted from word
\usepackage{supertabular}
\usepackage{hhline}
\makeatletter
\newcommand\arraybslash{\let\\\@arraycr}
\makeatother
\usepackage{chngpage} % to be able to center tables w/ table-specific margins
\usepackage{subcaption} % allows \tablecaption (again, part of stupid automated formatting)
\usepackage[labelformat=parens,labelsep=quad,skip=3pt]{caption}
\usepackage{tikz} % tikz package for putting rectangles around tables
\usetikzlibrary{calc}
\newcommand\Wider[2][3em]{%
\makebox[\linewidth][c]{%
\begin{minipage}{\dimexpr\textwidth+#1\relax}
\raggedright#2
\end{minipage}%
}%
}
\newcommand{\sym}[1]{{#1}}
\makeatletter
%primitive input in tabular
\AddToHook{env/tabular/begin}{\let\input\@@input}
\makeatother
\begin{document}
\begin{frame}[fragile]{Distributional effects: farm size}
\begin{table}[H] \tiny\centering
\begin{threeparttable}
{\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{tabular}{l*{5}{c}}
\toprule
&\multicolumn{1}{c}{\shortstack{Title}}&\multicolumn{1}{c}{\shortstack{Title}}&\multicolumn{1}{c}{\shortstack{Title}}&\multicolumn{1}{c}{\shortstack{Title}}&\multicolumn{1}{c}{\shortstack{Title}}\\
\midrule
Null/negative yield effect $\times$ HVY\_{t-1}& 50.98\sym{*} & 88.84\sym{***}& -16.71 & -20.29\sym{*} & -0.638 \\
& (29.82) & (20.41) & (16.74) & (10.68) & (2.175) \\
\addlinespace
Positive yield effect $\times$ HVY\_{t-1}& 0.890 & 39.75 & -34.28\sym{**} & -4.681\sym{**} & 0.933 \\
& (29.15) & (29.44) & (13.40) & (2.369) & (1.240) \\
\midrule
District FE & Yes & Yes & Yes & Yes & Yes \\
State-Year FE & Yes & Yes & Yes & Yes & Yes \\
Observations & 1698 & 1696 & 1696 & 1696 & 1696 \\
Within R$^2$ & 0.0118 & 0.0201 & 0.0258 & 0.0149 & 0.0125 \\
\bottomrule
\end{tabular}}
\begin{tablenotes}
\scriptsize \item Blah blah blah
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{frame}
\end{document}
Due to the way the content of a beamer frame is handled, you can't just use
#1within a beamer frame. You would have to double the hash symbol two times:To use your original syntax, you could use the
fragileframe option. This changes how beamer processes the frame content: