Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

LaTex problem with tilde

818 views
Skip to first unread message

Beth Linker

unread,
Apr 4, 1998, 3:00:00 AM4/4/98
to

I'm writing a paper about the Internet, and I want to refer to the
~user convention for home directories in Unix. To do that, I need a
tilde that isn't over a letter, but I'm having trouble getting it to
show up. One of the LaTeX books I have says you probably don't need that
character. I've been able to get a ~ over a space, but I'm trying to write
"\~user" and the best I can get is a ~ kind of smushed into a backslash.
Anyone know how to get it to show up neatly?

-Beth

--
Beth Linker
bsli...@unix.amherst.edu

Karsten Tinnefeld

unread,
Apr 4, 1998, 3:00:00 AM4/4/98
to

Beth Linker wrote:

Either replace ~user by \textasciitilde user
or
take a look at url.sty (that is meant to typeset uniform resource
locators, but since they are a superset to unix paths it can typeset
paths as well (yes, I know that according to RFC 1738 there is not such
thing as ~ in URLs, but who cares.))

--
Karsten Tinnefeld <tinn...@irb.informatik.uni-dortmund.de>
Software@IRB: FB Informatik, Universität Dortmund, D-44221 DO
Phone +49 231 755 4700, Fax +49 231 755 2386, PGP key available.

Robin S. Socha

unread,
Apr 4, 1998, 3:00:00 AM4/4/98
to

> Karsten Tinnefeld <tinn...@irb.informatik.uni-dortmund.de> writes:

> Replace ~user by \textasciitilde user

\usepackage{textcomp}, right?

Robin

--
Robin S. Socha
What the world needs now is killfiles that actually kill.

Karsten Tinnefeld

unread,
Apr 4, 1998, 3:00:00 AM4/4/98
to

Robin S. Socha wrote:

> > Replace ~user by \textasciitilde user
>
> \usepackage{textcomp}, right?

false. builtin.

from the author guide:
New feature, 1995/12/01.

Bad luck the author guide is not build into xemacs.

Ralph Miarka

unread,
Apr 5, 1998, 4:00:00 AM4/5/98
to

Karsten Tinnefeld wrote:
>
> Beth Linker wrote:
>
> > I'm writing a paper about the Internet, and I want to refer to the
> > ~user convention for home directories in Unix. To do that, I need a
> > tilde that isn't over a letter, but I'm having trouble getting it to
> > show up. One of the LaTeX books I have says you probably don't need that
> > character. I've been able to get a ~ over a space, but I'm trying to write
> > "\~user" and the best I can get is a ~ kind of smushed into a backslash.
> > Anyone know how to get it to show up neatly?
>
> Either replace ~user by \textasciitilde user
> or
> take a look at url.sty (that is meant to typeset uniform resource
> locators, but since they are a superset to unix paths it can typeset
> paths as well (yes, I know that according to RFC 1738 there is not such
> thing as ~ in URLs, but who cares.))

There are some further possibilities:
you could use \~{}user
or (what I prefer) $\sim$user

Ralph


Peter John Acklam

unread,
Apr 6, 1998, 3:00:00 AM4/6/98
to

Ralph Miarka wrote:
>
> There are some further possibilities:
> you could use \~{}user
> or (what I prefer) $\sim$user

Except that it *really* ugly when text and math fonts are mixed.
Just try \texttt{/home/$\sim$user}. It doesn't look pretty.

Peter

Ralph Miarka

unread,
Apr 7, 1998, 3:00:00 AM4/7/98
to

Peter John Acklam wrote:
> > or (what I prefer) $\sim$user
>
> Except that it *really* ugly when text and math fonts are mixed.
> Just try \texttt{/home/$\sim$user}. It doesn't look pretty.
>
> Peter

\texttt{/home/{\scriptsize$\sim$}user}
might look better.
I understand your complaints about this *dirty* hack,
but I didn't like \~{}user either.
Do you have a better solution ???

Ralph


Ralph Miarka

unread,
Apr 7, 1998, 3:00:00 AM4/7/98
to

David Carlisle

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

> \texttt{/home/{\scriptsize$\sim$}user}
> might look better.
> I understand your complaints about this *dirty* hack,
> but I didn't like \~{}user either.
> Do you have a better solution ???

If you really don't want to use url.sty, why not just use the standard
latex command \textasciitilde which will give you the tilde character
from the current font. This assumes you are using an encoding which has
such, otherwise it gives you the tilde accent \~{}. However the only
ascii-based text encoding that doesn't have this character is OT1.

David

Matt Austern

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

David Carlisle <dav...@nag.co.uk> writes:

This actually solves only part of the problem. The other part is
when you want to write a sentence like this:

In \Cplusplus, a class \verb|X| may have a special member
function called a \textit{destructor}. The destructor's
name is \verb|X::~X()|.

Or, similarly, if you want to include a code sample.
\begin{verbatim}
The \textasciitilde command produces a ~ character.
\end{verbatim}

The problem, that is, is how to make sure that tildes in verbatim text
are mapped to the correct tilde character (assuming you're using a
verbatim font that has a tilde character) rather than the tilde
accent.

David Carlisle

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

> The problem, that is, is how to make sure that tildes in verbatim text

they should come out right in verb anyway, but you probably shouldn't
be using verb as it can't be used in arguments, instead use something
like
\newcommand\codefragment[1]{\texttt{\let~\textasciitilde#1}}

Matt Austern

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

David Carlisle <dav...@nag.co.uk> writes:

That gets too hard if you need to put in fragments of code in a
language where ~, &, {, }, #, %, _, ^, and \ are all commonly used
characters. It also gets too hard if you want to display a multiline
fragment, preserving the exact indentation and spacing.

Yes, \verb and \verbatim have limits. Sometimes, though, even with
those limits, they're the only reasonable choice. At some point,
though, I'll have to figure out how to get ~ displayed properly in
those environments.


Donald Arseneau

unread,
Apr 8, 1998, 3:00:00 AM4/8/98
to

In article <fxtra38...@isolde.mti.sgi.com>, Matt Austern <aus...@sgi.com> writes...

> name is \verb|X::~X()|.
>
>The problem, that is, is how to make sure that tildes in verbatim text
>are mapped to the correct tilde character (assuming you're using a
>verbatim font that has a tilde character) rather than the tilde
>accent.

The computer modern tt font has an ascii tilde character, not an accent.
It is higher and smaller than people are accustomed to these days because
Times Roman's is too low. You will probably get closer to what you expect
by using Courier as the typewriter font.

If you have a glyph, in any font, that you would prefer in cmtt you can
make a virtual font to substitute it, or use url.sty to substitute it.

My suggestion is to not use tt, but:

\usepackage{url}
\newcommand\bla{\begingroup \urlstyle{sf}\Url}

You might want to declare a different set of line-breaking rules
appropriate for the logic of your fragments.

I suppose the same style of substitution could be set up for verbatim.

Donald Arseneau as...@triumf.ca

0 new messages