LyXHow to set in bold the first line of a table knitr ?

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
Hive
Posts: 11
Joined: Mon Feb 08, 2016 2:55 pm

How to set in bold the first line of a table knitr ?

Post by Hive »

Hello everyone

I would like to set the first line of my tables in bold, like this little example :
Image

Pretty easy with lyx but I didn't find any solution to do it in knitr/Lyx, except this post which explains how to bold the row names but not the entire line.

I'm sure it's just a single option to give to xtable but I don't get it. Any help will be appreciated.
Attachments
mwe_table_bold.tex
(2.29 KiB) Downloaded 371 times
mwe_table_bold.lyx
(2.05 KiB) Downloaded 319 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

scottkosty
Site Moderator
Posts: 542
Joined: Sat Sep 01, 2012 6:38 am

How to set in bold the first line of a table knitr ?

Post by scottkosty »

In your 'm' object (which you might need to change to a data.frame and store strings in it), add the

Code: Select all

\textbf{}
yourself to the individual elements that you want bolded (in this case the first row), (perhaps using gsub()?). Then in print.xtable you'll need to modify the sanitize function so that it doesn't escape your backslash.
Hive
Posts: 11
Joined: Mon Feb 08, 2016 2:55 pm

Re: How to set in bold the first line of a table knitr ?

Post by Hive »

After modifying row values in the form "\\textbf{value}", and setting print.xtable option "sanitize.text.function=identity", it greatly works.

Many thanks for your help !

I'll see if the option "add.to.row" can also do the job. I'll notice you if I find something useful.
Post Reply