[XeTeX] Maths and Symbols in Latex
Ross Moore
ross at maths.mq.edu.au
Thu Jul 1 02:51:11 CEST 2004
Hi Jon an Jonathan,
On 01/07/2004, at 4:54 AM, Jonathan Kew wrote:
>
> On 30 Jun 2004, at 11:45 am, Jon Breitenbucher wrote:
>
>> On Jun 30, 2004, at 2:21 PM, Jonathan Kew wrote:
>>
>>> I'd recommend using {\char"2022} rather than {\XeTeXglyph...} <snip>
>>
>> Strange, when I do \renewcommand{\textdollar}{\char"0024} I must
>> enter {\textdollar}100,000 in the source or I get an error
> Try
> \renewcommand{\textdollar}{\char"0024\relax}
I'd recommend using \renewcommand{\textdollar}{{\char"0024}}
or \renewcommand{\textdollar}{{^^^^0024}}
with the extra braces.
The advantage is that the expansion of the macro acts as a single
token, if ever the \textdollar becomes a parameter to another macro,
after some expansion; e.g. when writing into the .aux or .toc file,
or for the index or bibliography.
Even better is to use a declaration:
\DeclareRobustCommand{\textdollar}{{\char"0024}}
or
\DeclareRobustCommand{\textdollar}{{^^^^0024}}
Here's an example to better show the distinction
between these approaches:
\documentclass[11pt]{article}
\newcommand{\textdollari}{\char"0024\relax}
\newcommand{\textdollarii}{{\char"0024}}
\DeclareRobustCommand{\textdollariii}{{\char"0024}}
\begin{document}
%\listoffigures
\begin{figure}
\caption{%
Compare \textbf\textdollari100,000 with \textbf\textdollarii100,000
and \textbf\textdollariii100,000.}
\end{figure}
\end{document}
This typesets fine, until you uncomment the \listoffigures usage,
then run LaTeX twice:
Document Class: article 2001/04/21 v1.4e Standard LaTeX document class
(/usr/local/teTeX/share/texmf/tex/latex/base/size11.clo)) (./chtest.aux)
(./chtest.lof
! Missing number, treated as zero.
<to be read again>
\aftergroup
l.1 ...00 and \textbf \textdollariii 100,000.}}{1}
Here's what the .aux file looks like:
[glenlivet:~] rossmoor% more chtest.aux
\relax
\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces
Compare
\textbf \char "0024\relax 100,000 with \textbf {\char "0024}100,000
and \textbf \textdollariii 100,000.}}{1}}
The .lof file is similar.
Debugging this kind of problem is damnably difficult,
as you don't get a decent refence to the line of your source
that needs changing. Besides, everything looks OK at first glance.
> That should ensure that as TeX is reading the number, it stops where
> you want and doesn't continue reading if the macro happens to be
> followed by digits.
>
> Or you could use
> \renewcommand{\textdollar}{^^^^0024}
> as the ^^^^ notation reads exactly 4 hex digits, if I remember right.
Best if all such definitions are made robust for LaTeX.
Hope this helps,
Ross
>
> (147712 is the decimal equivalent of hex 0024100, in case you wondered
> where that came from.)
>
> Jonathan
>
> _______________________________________________
> XeTeX mailing list
> postmaster at tug.org
> http://tug.org/mailman/listinfo/xetex
>
------------------------------------------------------------------------
Ross Moore ross at maths.mq.edu.au
Mathematics Department office: E7A-419
Macquarie University tel: +61 +2 9850 8955
Sydney, Australia fax: +61 +2 9850 8114
------------------------------------------------------------------------
More information about the XeTeX
mailing list