LyX ⇒ Two tables on the same line with xtable/knitr
Two tables on the same line with xtable/knitr
I would like to get two tables on the same line due to their small size. I generate them with xtable via knitr chunks and they are placed one above the other by default. I tried to use multicol but the tables simply disappear. I also tried to make a simple table with one line and two columns and put the knitr chunks inside but this send me an error.
Does anyone know a way to do this in Lyx ?
Sincerely
Hive
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
-
- Site Moderator
- Posts: 542
- Joined: Sat Sep 01, 2012 6:38 am
Re: Two tables on the same line with xtable/knitr
Two tables on the same line with xtable/knitr
I tried to do what you said but it still doesn't work. In attach, a mwe of what I did. Maybe I missed something ?
I looked at knitr chunk options but didn't find something usefull to set.
- Attachments
-
- mwe_tables.tex
- (3.81 KiB) Downloaded 366 times
-
- mwe_tables.lyx
- (4.53 KiB) Downloaded 317 times
-
- Site Moderator
- Posts: 542
- Joined: Sat Sep 01, 2012 6:38 am
Re: Two tables on the same line with xtable/knitr
http://wiki.lyx.org/FAQ/MinimalExample
The example that you posted has a lot of preamble code. There are also other document settings that are non-standard. Can you create a new document and try to only modify the document settings that are necessary to reproduce the problem?
Re: Two tables on the same line with xtable/knitr
- Attachments
-
- mwe_tables.lyx
- (3.11 KiB) Downloaded 347 times
-
- Site Moderator
- Posts: 542
- Joined: Sat Sep 01, 2012 6:38 am
Two tables on the same line with xtable/knitr
First, if you look at the source code (View > Source), you will see
Code: Select all
@}
Second, xtable produces a floating environment by default. Since you are having LyX take care of the floats in this case, we need to tell xtable to not use a float (and just produce a fixed table). We do this with:
Code: Select all
print.xtable(m_table, floating = FALSE)
Re: Two tables on the same line with xtable/knitr
I also find another solution with two minipages side by side : insert -> box -> without border (maybe not the exact names, I work on french lyx version). Put your knitr chunk inside and then set the width of your minipages less than 50 in order to let them share the same line of the page.
In attach an example of each cases.
Thank you for our help

- Attachments
-
- mwe_tables.lyx
- (4.6 KiB) Downloaded 375 times