[R] [OT] getting a ~ character in LaTeX

Kurt Hornik Kurt.Hornik at ci.tuwien.ac.at
Wed Jan 17 08:21:28 CET 2001

>>>>> Peter Dalgaard BSA writes:

> Douglas Bates <bates at stat.wisc.edu> writes:
>> I am writing course notes in LaTeX.  In the part where I am describing
>> model-fitting functions in R I want to use a ~ character inline.  If I
>> am displaying an example of R code in its own environment I use the
>> alltt environment, which protects the ~ character.  I have forgotten
>> how to protect the ~ when I am writing something like
>> The operator `~' is used to define a model formula in \R.
>> The left hand side is evaluated as the response.  The right hand
>> side can consist of several \Emph{terms} with special meanings
>> I welcome suggestions.

> I have at a similar spot:

> As mentioned earlier, e.g.\ in connection with boxplots and
> stripplots, the argument to |lm| is a \emph{model formula}, in which
> the  tilde symbol (|~|) should be read as ``described by''.

> (with \usepackage{shortvrb} and \MakeShortVerb| )

That is the most convenient solution, but in Doug's case there might be
a problem with typesetting

	foo ~ bar | baz


In the short run, I think the official solution is to use
and if you look at the code for this you will see that

In the long run, I realized when working on the newsletter style file
with Fritz that if we have texinfo/HTML like markup commands such as
\code and \file then *inside* these we really want a behavior similar to
alltt or inside \url, i.e., only the escape and the grouping chars
should be special (only `\' `{' and `}').  I am planning to write macros
for this, maybe in a style file of its own so that we can also use it in
Rd.sty, for example.

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list