I use knitr
to weave my .Rnw documents into .tex and then .pdf document (still using pdflatex
).
I'm looking for a solution to have the exact same format for inline code and for code chunks. I can use the texttt{}
function to get the same font, but I am looking for a way to get the exact same format (font, background color, syntax highlighting).
Somebody has an idea?
I found the following approximate solution:
\documentclass{article}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
\usepackage{sansmath}
\begin{document}
<<>>=
options(digits = 3, scipen = 6)
some_small_number <- 0.000000000123456
@
Default math font: \Sexpr{some_small_number}
Sans-serif font: {\sansmath \Sexpr{some_small_number}}
\end{document}
Output:
I would prefer it matches to Helvetica, but at least is it somewhat similar.
UPDATE: Loading sansmath
after setting default font, \sfdefault
, does make the math font match the current default (code and image above is corrected for this).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With