LaTeX error when using Lyx: Bad mathchar (32768) [closed]

I have been getting this error message when ouputing my LyX document: Bad mathchar (32768), with the following explanation: "A mathchar number must be between 0 and 32767. I changed this one to zero.", followed by two more errors: Missing number, treated as zero., with the explanation "A number should have been here; I inserted 0'. (If you can't figure out why I needed to see a number, look up weird error' in the index to The TeXbook.)"

The source of the error seems to be the following TeX file that creates a table:

                 &\multicolumn{3}{c}{Matem\'aticas}                                \\\cmidrule(lr){2-4}
&\multicolumn{1}{c}{(1)}         &\multicolumn{1}{c}{(2)}         &\multicolumn{1}{c}{(3)}         \\
\midrule
Tratamiento         &        0.07         &        0.08\sym{**} &        0.09\sym{***}\\
&      (0.08)         &      (0.05)         &      (0.03)         \\
Controles           &          No         &        S\'i         &        S\'i         \\
\midrule
Observaciones       &        2000         &        2000         &        2000         \


The TeX file is then saved in the same folder as the LyX file under the name regressions.tex and inserted in the LyX document by Insert-TeX Code:

\begin{threeparttable}
\estwide{regressions.tex}{3}{c}
\Figtext{\footnotesize{Errores est\'andares entre par\'entesis.\\ \textit{* p < 0.1, ** p < 0.05, *** p < 0.01.}}}
\end{threeparttable}


I can see the output in pdf of the LyX file this code is inserted in (although I get the afore-mentioned error message), but it doesn't work when I insert the LyX file as a Child file in another LyX file.

I have other similar tables in other Child LyX files across the master document, and they work fine. I haven't been able to find where the problem comes from. Any help would be appreciated, thanks!

The preamble should include:

\usepackage{booktabs}
\usepackage{threeparttablex}
% *****************************************************************
% 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
\end{tabular*}
}
}

\newcommand{\estauto}[3]{
\vspace{.75ex}{
\textsymbols% Note the added command here
\begin{tabular}{l*{#2}{#3}}
\toprule
\estinput{#1}
\bottomrule
\end{tabular}
}
}

% Allow line breaks with \\ in specialcells
\newcommand{\specialcell}[2][c]{%
\begin{tabular}[#1]{@{}c@{}}#2\end{tabular}
}


EDIT:

I have encountered this issue. It has nothing to do with the specific table used but the fact that the table may contain math characters or somehow messes with the way LyX deals with math characters inside tex code. No idea how that works behind the scenes but something flips up under certain circumstances. To solve the issue, there must be some TeX code that uses math in the LyX doxument, before the code above is called. "" suffices.

closed as unclear what you're asking by Joseph Wright♦Aug 11 '13 at 12:42

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• One should mention that the LyX Preamble needs to be set like in this post otherwise \estwide is undefined. – e-birk Apr 1 '13 at 21:43
• I assume that the contents of the file regressions.tex is the TeX code displayed above (though this is not clearly stated). Creating a PDF from a LyX file containing only \begin{threeparttable}....\end{threeparttable} works for me without error if I add this and \usepackage{threeparttable} to the LaTeX Preamble... Probably the problem came from something else, maybe before that? – e-birk Apr 1 '13 at 21:58
• Sorry for that. I included the LaTeX preamble. I am pretty sure the problem comes from the LaTeX code creating the table, because both the child file and the master document work without it. – Ines Apr 2 '13 at 14:28
• I know this is an old question, but still: As e-birk, I cannot reproduce the problem with the information given. Using the preamble from tex.stackexchange.com/questions/97764/…, inserting the threeparttable environment in an ERT with regressions.tex` as given, included in a second document as a child document, it compiles just fine. If this is still a problem, are you able to create a LyX minimal example or a LaTeX MWE? – Torbjørn T. Jul 8 '13 at 19:05
• With no MWE that reproduces the issue, I'm closing. That could be 'unclear' or 'off topic' (as it's not reproducible): I've gone for unclear. – Joseph Wright Aug 11 '13 at 12:43