[XeTeX] No clipping support in XeTeX and \textcelsius
Ross Moore
ross at ics.mq.edu.au
Tue Apr 13 05:35:20 CEST 2010
Hello Tiandao,
On 13/04/2010, at 12:21 PM, Tiandao Li wrote:
> Hi,
>
> \documentclass[letterpaper,12pt]{article}
> \usepackage[cm-default]{fontspec} % provides font selecting commands
> \defaultfontfeatures{Mapping=tex-text}
> %\usepackage{xunicode}% provides unicode character macros
> %\usepackage{xltxtra} % provides some fixes/extras
> \usepackage{textcomp}
>
> \begin{document}
>
> Today is 25\textcelsius.
>
> \end{document}
>
> edit it using vim, then :! xelatex %. Without packages of xunicode
> and xltxtra, ℃ shows correctly. I am using Ubuntu 9.10 with xetex
> from texlive (2007).
Yes, it looks like it shows correctly, but there is
more to doing it right than just appearances.
What you are really getting can be seen by tracing:
>>> \textcelsius ->\TS1-cmd \textcelsius \TS1\textcelsius
>>>
>>> \TS1-cmd #1->\ifx \protect \@typeset at protect \@inmathwarn #1\else
>>> \noexpand #1\
>>> expandafter \@gobble \fi
>>> #1<-\textcelsius
>>> {\ifx}
>>> {true}
>>>
>>> \@inmathwarn #1->\ifmmode \@latex at warning {Command \protect #1
>>> invalid in math
>>> mode}\fi
>>> #1<-\textcelsius
>>> {\ifmmode}
>>> {false}
>>> {\else}
>>> {\char"89}
So you get the character at Hex: 0089 out of a font
that was cobbled together with such symbols.
If you extract the text from your PDF, e.g. with a Copy/Paste,
then you will not get the Celsius symbol at all.
Indeed U+00089 is not even a valid character, so should
not be used for this purpose.
BTW, you do not need XeTeX for this result; just using
pdfTeX or LaTeX + dvips would achieve the same thing.
Now to make proper use of XeTeX you should be working
with an OpenType font. Then this preamble works, and there
is no need for the {textcomp} package:
>>> \documentclass[letterpaper,12pt]{article}
>>> \usepackage[cm-default]{fontspec} % provides font selecting commands
>>> \defaultfontfeatures{Mapping=tex-text}
>>> \usepackage{xunicode}% provides unicode character macros
>>> \usepackage{xltxtra} % provides some fixes/extras
>>> %\usepackage{textcomp}
>>> \setmainfont{Lucida Grande}
>>> \begin{document}
>
Many other fonts can be used instead of "Lucida Grande",
but not all support the desired character at U+02103 .
Now Copy/Paste (or other text-extraction) will give the
correct character; e.g., for use in non-TeX-based documents.
And searches will find this character within the PDF.
If you actually want to use {textcomp} for the symbols, then this
>>> \documentclass[letterpaper,12pt]{article}
>>> \usepackage[cm-default]{fontspec} % provides font selecting commands
>>> \defaultfontfeatures{Mapping=tex-text}
>>> \usepackage{xunicode}% provides unicode character macros
>>> \usepackage{xltxtra} % provides some fixes/extras
>>> \usepackage{textcomp}
>>> \UndeclareUTFcharacter[\UTFencname]{x2103}{\textcelsius}
>>>
>>> \begin{document}
>
will give the same result as your own coding, but also allow
you to make use of other features of the Xunicode and XLT-extra
packages.
>
> Tiandao
>
>
>
> On Mon, Apr 12, 2010 at 6:07 PM, Fr. Michael Gilmary
> <FrMichaelGilmary at maronitemonks.org> wrote:
> Tiandao Li wrote:
>
> The following is the fonts used for English and Chinese, basically for
> English.
>
> \setmainfont{AR PL UKai CN}
> \newfontinstance\rmfont{Times New Roman}
> \newcommand{\en}[1]{{\rmfont #1}}
> \newcommand{\chem}[1]{$\mathrm{#1}$}
> \setmainfont{Times New Roman}
> \newfontinstance\cnfont{AR PL UKai CN}
> \newcommand{\cn}[1]{{\cnfont #1}}
>
> I am still learning xetex. if anything wrong, please correct me.
With XeTeX you can create documents where what you get is more
useful than just being able to see the expected image on-screen.
Individual characters have a much richer meaning, for use in
contexts other that just that of the moment.
Hope this helps,
Ross
------------------------------------------------------------------------
Ross Moore ross at maths.mq.edu.au
Mathematics Department office: E7A-419
Macquarie University tel: +61 (0)2 9850 8955
Sydney, Australia 2109 fax: +61 (0)2 9850 8114
------------------------------------------------------------------------
More information about the XeTeX
mailing list