[Tex/LaTex] LyX TeX Table too big

beamerlyxtables

I am including a TeX file into a LyX document using Insert -> Child Document. The Table looks fine on the LyX screen but when I preview the PDF it is 10 times too big. Not sure how to fiddle with the magnification to make it look right. Or is using the child document route wrong?

Here is the MWE:

\begin{table}
\caption{Regression table}\label{tab1}
\centering

\smallskip
\begin{tabular}{@{}l cccccc @{}}
\toprule
& \multicolumn{2}{c}{Model 1}
& \multicolumn{2}{c}{Model 2}
& \multicolumn{2}{c@{}}{Model 3}\\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(l){6-7}
& Coef. & SE & Coef. & SE & Coef. & SE\\
\midrule
Variable 1 & 12.758 & * &  13.822 & *** & 2.123 & *\\
\midrule[\heavyrulewidth]
\multicolumn{7}{@{}l}{* $p < 0.05$, ** $p < 0.01$, *** $p < 0.001$.}\\
\end{tabular}
\end{table}

When I add this as an input to my LyX Beamer presentation the slide magnifies the table 5-10 times making it unreadable.

Best Answer

Your problem might be hidden in some settings that are not shown at the moment... Hence, the complete generated LaTeX code would be helpful. At least I found some information that was not mentioned before:

  • that you are probably using the package booktabs because of \toprule etc. Hence, you seem to have created the table by inserting TeX code/ERT into your child document.

  • what exact document class your main document and your child document have -- I assume "presentation (beamer)" for both.

Here I give a MWE that works for me as expected. The output is

output of LyX file

The LyX file looks like

lyx file

and here is the generated LaTeX code (very few lines are removed).

%% LyX 2.0.5.1 created this file.  For more info, see http://www.lyx.org/.
\documentclass[english]{beamer}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
% this default might be overridden by plain title style
\newcommand\makebeamertitle{\frame{\maketitle}}%
\AtBeginDocument{
  \let\origtableofcontents=\tableofcontents
  \def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
  \def\gobbletableofcontents#1{\origtableofcontents}
}
\long\def\lyxframe#1{\@lyxframe#1\@lyxframestop}%
\def\@lyxframe{\@ifnextchar<{\@@lyxframe}{\@@lyxframe<*>}}%
\def\@@lyxframe<#1>{\@ifnextchar[{\@@@lyxframe<#1>}{\@@@lyxframe<#1>[]}}
\def\@@@lyxframe<#1>[{\@ifnextchar<{\@@@@@lyxframe<#1>[}{\@@@@lyxframe<#1>[<*>][}}
\def\@@@@@lyxframe<#1>[#2]{\@ifnextchar[{\@@@@lyxframe<#1>[#2]}{\@@@@lyxframe<#1>[#2][]}}
\long\def\@@@@lyxframe<#1>[#2][#3]#4\@lyxframestop#5\lyxframeend{%
  \frame<#1>[#2][#3]{\frametitle{#4}#5}}
\def\lyxframeend{} % In case there is a superfluous frame end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{booktabs}
\makeatother
\usepackage{babel}

\begin{document}
\lyxframeend{}\lyxframe{test slide}

\begin{table}
\caption{Caption of table}
\label{tab1}\centering\begin{tabular}{@{}l cccccc @{}} 
\toprule
&\multicolumn{2}{c}{M1} &\multicolumn{2}{c@{}}{M2} &\multicolumn{2}{c@{}}{M3}\\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(l){6-7} &C &SE &C &SE &C &SE\\
\midrule
Variable 1 & 12.345 & * &  23.456 & *** & 34.567 & *\\
\midrule[\heavyrulewidth]
\multicolumn{7}{@{}l}{* $p < 0.05$, ** $p < 0.01$, *** $p < 0.001$.}\\
\end{tabular}
\end{table}

\lyxframeend{}
\end{document}
Related Question