-
-
Notifications
You must be signed in to change notification settings - Fork 879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing tilde inserted in latex #1992
Comments
I don't understand---if it throws an error, how did you get the PDF output that looked nice? It seems you need |
I don't know how that worked while generating errors. I'm absolutely happy with the |
Let me rethink about it (darn it I have completely forgotten that it was @jaredlander who filed #492---he is my VIP). Thanks for filing the issue again! |
And you're my MVP |
I just provide a package option to allow for customizing the tilde symbol. Two examples: Using \texttildelow in textcomp\documentclass{article}
\usepackage{textcomp} % enable middle tilde
\newcommand{\tildemid}{\raisebox{0.5ex}{\texttildelow}}
\begin{document}
<<setup, include=FALSE>>=
knitr::opts_knit$set(latex.tilde = r"(\hlopt{\tildemid})")
@
<<>>=
y ~ x
@
\end{document} Using the math symbol \sim\documentclass{article}
\begin{document}
<<setup, include=FALSE>>=
knitr::opts_knit$set(latex.tilde = r"(\hlopt{\scriptsize{\ensuremath{\sim}}})")
@
<<>>=
y ~ x
@
\end{document} The output of the second example looks better in my eyes, but keep in mind that the symbol is actually not a tilde, so you won't be able to copy the code and run it. As I mentioned in #492, this is a surprisingly complicated task: https://tex.stackexchange.com/q/312/9128 I can't provide a good default (ideally the correct ~ character with no extra dependency, which seems to be impossible), and will let you decide which solution you want to adopt. |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
This is a comment to #492 (Code chunks with a formula as in
lm(y~x)
are typeset as a "high" tilde instead of a "middle" tilde) and may be closed at will:In the .Rnw LaTeX preamble, I add
Then in the
setup
chunk, I addTo avoid a
textcomp
dependency, I also triedwhich looks really nice, but generates
missing $ inserted
errors.I chose to not further pursue that road but use the first solution.
The text was updated successfully, but these errors were encountered: