Skip to content
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

Wrong tilde inserted into LaTeX #492

Closed
jaredlander opened this issue Feb 27, 2013 · 7 comments
Closed

Wrong tilde inserted into LaTeX #492

jaredlander opened this issue Feb 27, 2013 · 7 comments
Milestone

Comments

@jaredlander
Copy link
Contributor

Run running functions that need a formula, say

lm(sons ~ fathers, data=heights)

The tilde is made into a "high" tilde instead of a "middle" tilde such as generated by $\sim$.

For example

<<father-son-lm>>=
heightsLM <- lm(sheight ~ fheight, data=father.son)
heightsLM
@

results in the following LaTeX

\begin{knitrout}
\definecolor{shadecolor}{rgb}{0.969, 0.969, 0.969}\color{fgcolor}\begin{kframe}
\begin{alltt}
> heightsLM <- \hlfunctioncall{lm}(sheight ~ fheight, data = father.son)
> heightsLM
\end{alltt}
\begin{verbatim}

Call:
lm(formula = sheight ~ fheight, data = father.son)

Coefficients:
(Intercept)      fheight  
     33.887        0.514  
\end{verbatim}
\end{kframe}
\end{knitrout}

and that generates
image

This is entirely cosmetic, but actually makes a big typographical difference. Is it possible to swap ~ with $\sim$ in the code blocks?

@yihui
Copy link
Owner

yihui commented Mar 3, 2013

This is where I absolutely hate LaTeX. It is ridiculously difficult to typeset certain characters such as the tilde and straight single quotes/backticks. You can learn endless hacks in posts like this http://tex.stackexchange.com/questions/312/correctly-typesetting-a-tilde but I do not want to spend time on this. If you have got an elegant solution, let me know. You can certainly modify the source hook to substitute ~ with other commands such as \url{~}. It is not worth the effort in my eyes.

@jaredlander
Copy link
Contributor Author

For now I'll leave it to the editor. When I get time I'll play with the hook. Should be fairly simple along the lines of

str_replace_all(string=x, pattern="~", replacement="\\url{~}")

or

str_replace_all(string=x, pattern="~", replacement="\$sim\$")

@yihui yihui closed this as completed Mar 7, 2013
@kendonB
Copy link

kendonB commented Feb 16, 2015

@jaredlander Did you solve this one?

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2020
@yihui
Copy link
Owner

yihui commented Apr 28, 2021

This is where I absolutely hate LaTeX.

Hey @yihui you were an idiot. Apparently you had no idea what you were talking about in 2013!

Repository owner unlocked this conversation Apr 28, 2021
@jaredlander
Copy link
Contributor Author

Yet still more knowledgeable than almost anyone else.

yihui added a commit that referenced this issue May 5, 2021
…e symbol ~ with the package option latex.tilde
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants