Skip to content

[OT] getting a ~ character in LaTeX

5 messages · Douglas Bates, Brian Ripley, Stuart Luppescu +2 more

#
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.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On 16 Jan 2001, Douglas Bates wrote:

            
There is no really good simple idea. $sim$ is not too bad, \verb|~|
will give a raised tilde in most TeX fonts: you can also use
\textasciitilde (as used by Rdconv) in normal text.

V&R (well, R) made a virtual monospaced font taking ~ from a IBM
public version of Courier, scaled to fit, plus

\def\~{{\tt\char'176}}

which make \~ work as you might hope.
#
On 16-Jan-2001 Douglas Bates wrote:
How about \sim? That's what I use when I need a ~ meaning ``is distributed
as.'' You may need \usepackage{amsmath} with this, but I'm not sure.
______________________________________________________________________
Stuart Luppescu         -=-=-  University of Chicago
$(B:MJ8$HCRF`H~$NIc(B        -=-=-  s-luppescu at uchicago.edu
http://www.consortium-chicago.org/people/sl.html
Finger sl70 at musuko.uchicago.edu forPGP Public Key
ICQ #21172047  AIM: psycho7070
Acceptance testing:
        An unsuccessful attempt to find bugs.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Douglas Bates <bates at stat.wisc.edu> writes:
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
	\textasciitilde
and if you look at the code for this you will see that
	latex.ltx:\DeclareTextCommandDefault{\textasciitilde}{\~{}}
	t1enc.def:\DeclareTextSymbol{\textasciitilde}{T1}{`\~}

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.

-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._