3

I am trying to include my website address in the address block of a letter.

My webaddress has a tilde character, and my usual solution, $\sim$, to the tilde formatting problem is not working.

The relevant code is

\documentclass[english]{letter}
...
\address{ Street \\ City, ST 00000 \\ \url{http://my.web.address/~blah} }
...

This gives a bad-looking top-aligned tilde.

If I replace ~ with $\sim$, then "http://my.web.address/$\sim$blah" appears in the output PDF. Using \texttildelow gives a compilation error.

Edit: This is not a duplicate. Solutions for the referenced questions do not work inside \address{}.

mafp
  • 19,096

2 Answers2

7

If you are using the default Computer Modern Fonts, then the Latin Modern fonts might be an alternative, because they are derived from the Computer Modern Fonts. The tilde is lower. Also there is a proportionally spaced typewriter variant that might look better than the mono-spaced font for URLs.

\documentclass{letter}
\usepackage{url}
\usepackage[T1]{fontenc}
\usepackage[variablett]{lmodern}
\address{ Street \\ City, ST 00000 \\ \url{http://my.web.address/~blah} }
\begin{document}
\begin{letter}{}
\opening{Dear xy,}
\closing{Yours sincerely}
\end{letter}
\end{document}

Result

Heiko Oberdiek
  • 271,626
0

I wanted to add another working solution here.

The href package seems to allow special characters within \address{} using the two-parameter href command.

For instance, \href{http://my.web.address/~blah}{http://my.web.address/$\sim$blah} works.

However, the single parameter version of the href command, \href{http://my.web.address/~blah}, does not typeset the tilde nicely.