[l2h] textrm{} does not work -- and \texttt problems

Robin Fairbairns Robin.Fairbairns@cl.cam.ac.uk
Fri, 04 May 2001 10:05:39 +0100


edwin steiner wrote:

> Ross Moore wrote:
> > [Edwin Steiner wrote:]
> > > When LaTeX processes the document
> > > 
> > >     \documentclass{article}
> > >     \newcommand{\mytt}[1]{{\tt #1}}
> > >     \newcommand{\myrm}[1]{{\rm #1}}
> > >     \begin{document}
> > > 
> > >     \texttt{AAA\textrm{BBB}AAA},
> > 
> > Do you really expect this to work ?
> > What should it mean logically ?

baldly put like that, it looks silly.  rename the macros, as one might
for logical markup, and i can imagine any number of logical constructs
that it might be modelling.

> > This will depend on the expansion model for macros.
> [snip]

i've got my own complaints about that -- see below.

> My error was to assume that \textrm{foo} is the same as {\rm foo}.
> Well, it isn't. I looked it up in the LaTeX source. (And turned
> away blinded. No more LaTeX source for me. :-)

in fact, to all intents and purposes, the archaic form _does_ have the
same effect as the current latex command, in this case.  all the
kerfoodle you noticed is dealing with inserting italic corrections
when the surrounding or the included text is not an upright font.

> I'm using declarations now, and the output is perfect
> both in HTML and in DVI, no matter how deep
> the scopes of the declarations are nested . :-)

and provided that you're using a class that defines the old-style font
declarations.  not all do, nowadays.  at least use \ttfamily and
\rmfamily rather than the latex 2.09 declarations...

my own problem with expansion is that it doesn't distinguish between
the arguments of \texttt and \textrm (and the rest), and solemnly
enforces ligaturing of letters in the typewriter font that only exist
in the roman and sans fonts.  this arose because one of our people
wanted to write

  \subsection{\texttt{ls --colour=tty}}

and was getting latex2html output that had a single hyphen in it.

the solution is to separate the latex and the html version, and to
write

  \subsection{\verb+ls --colour=tty+}

for the html.  this offends my sensibilities (since it's not allowable
in latex).  fortunately the \verb form works equally well in either
output mode in running text; \texttt works nowhere in latex2html, for
this text.