<div dir="ltr"><div class="gmail_default" style="font-size:small">Scott and all,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Here you go.  As you will see, the Table is fine, but we get the "knitr errors" message:</div><div class="gmail_default" style="font-size:small">LaTeX Error: Not in outer par mode.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Doug</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">P.S. We like various capabilities that the kableExtra package provides us with, e.g.,</div><div class="gmail_default" style="font-size:small">in this simple example the add_header_above via kable_styling.</div><div class="gmail_default" style="font-size:small">Of course if we ever find out how to directly import a data frame into the LYX table</div><div class="gmail_default" style="font-size:small">capability, we will probably use it a lot.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 11, 2021 at 12:05 PM Scott Kostyshak <<a href="mailto:skostysh@lyx.org">skostysh@lyx.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sun, Apr 11, 2021 at 09:12:15AM -0600, Doug Martin wrote:<br>
> Tom Philips and I create tables in LYX using the knitr package function<br>
> kable (with the package kableExtra) in the<br>
> following way:<br>
> <br>
> <br>
> <br>
>    1. Insert > Float > Table<br>
>    2. In the float, enter a name and header for the table in the space<br>
>    provided<br>
>    3. Just below the name, *but still inside the float*, press Ctrl-L to<br>
>    create a box for Latex code<br>
>    4. Enter all the code for the table including the kable code that<br>
>    actually generates it into the box for Latex code<br>
> <br>
> This causes a “Not in outer par mode” error (see below), but creates a<br>
> table that we are quite fine with.  Our Tech<br>
> Support person at Springer told us that the reason is due to embedding the<br>
> Rnw file for Table output in the LYX file,<br>
> so that there is a table code inside another table in LaTeX as highlighted<br>
> below.<br>
> <br>
> <br>
> <br>
> \begin{table}[H]<br>
> <br>
> \caption{Equity Returns in Twenty--One Countries: 12/31/1899--12/31/2019}<br>
> <br>
> \begin{table}<br>
> <br>
> \centering\begingroup\fontsize{10}{12}\selectfont<br>
> <br>
> \begin{tabular}{lcccc}<br>
> <br>
> \toprule<br>
> <br>
> …..<br>
> <br>
> …..<br>
> <br>
> \end{tabular}<br>
> <br>
> \endgroup{}<br>
> <br>
> \end{table}<br>
> <br>
> \label{tab:GlobalEquityReturns}<br>
> <br>
> \end{table}<br>
> <br>
> and he suggested to solve the problem by adding the yellow highlighted<br>
> lines below.<br>
> <br>
> \begin{table}[H]<br>
> <br>
> \caption{Global Annualized Real Returns For Stocks, Bonds and Bills}<br>
> <br>
> \begingroup<br>
> <br>
> \def\table{\begin{center}\fontsize{10}{12}\selectfont}<br>
> <br>
> \def\endtable{\end{center}}<br>
> <br>
> \begin{table}<br>
> <br>
> ……<br>
> <br>
> <br>
> <br>
> *And the second insertion will be: *<br>
> <br>
> \end{table}<br>
> <br>
> \endgroup<br>
> <br>
> \label{tab:GlobalEquityBondsCashReturns}<br>
> <br>
> \end{table}<br>
> <br>
> <br>
> This actually works fine.  Except that for every table we have to do that<br>
> insertion, and Tom and I are just<br>
> wondering if there some capability of LYX to accomplish the same thing<br>
> without us having to do those insertions<br>
> for every table?<br>
> <br>
> Doug<br>
<br>
Hi Doug,<br>
<br>
Could you send (to the list) a minimal example .lyx file (complete with<br>
a simple knitr chunk with kable code) that we can experiment with?<br>
<br>
Thanks,<br>
Scott<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">R. Douglas Martin<div>Professor Emeritus in Applied Mathematics and Statistics</div><div>Founder and Former Director of MS-CFRM Program</div><div><a href="http://depts.washington.edu/compfin/" target="_blank">depts.washington.edu/compfin/</a></div><div>University of Washington</div></div></div>