6

In xaringan how to create table having some cells being formatted as code.
In markdown I would declare such table in a following way:

header1 | header2 | header3
---------------------------
`fun1` | `code1` | text not formatted as code
`fun2` | `code2` | another
`fun3` | `code3` | and again

Of course I do not except syntax highlighting.

I was able to use knitr::kable(, format="html") to produce table, but cannot make it work for formatting cells as code. Tried adding <pre><code>fun1</code></pre>, did not helped.

jangorecki
  • 16,384
  • 4
  • 79
  • 160

1 Answers1

6

That is super easy to fix. In your header bar you need to add vertical bars to ensure that it is rendered as a table:

header1 | header2 | header3
--------|---------|---------
`fun1` | `code1` | text not formatted as code
`fun2` | `code2` | another
`fun3` | `code3` | and again

Tables can be a little pernickety to get rendered correctly.

At least this gets the font right but the table css might override some of your default code layout.

ekstroem
  • 5,957
  • 3
  • 22
  • 48