[XeTeX] Fontspec question

Ross Moore ross at ics.mq.edu.au
Tue Jan 8 06:30:39 CET 2008


Hello David,

On 08/01/2008, at 8:36 AM, David Denton wrote:

> Hello XeTeX users,
>
> This is very much a newbe question, the answer to which is probably
> quite obvious, but I have not been able to solve it in looking at the
> documentation. I am using Xelatex under Miktex 2.7. My project
> involves a main font in with words and phrases scattered throughout in
> an alternate font. My main font is established as follows:
>
> \setmainfont[Mapping=tex-text]{LMRoman12}
>
> I define my alternate font as follows:
>
> \newfontfamily\cr{BJECree}
>
> To invoke the alternate font I do: \cr

Oh no!!   Don't redefine \cr .

It is a TeX primitive that denotes the end of a line in tabular
layouts. You will have weird difficulties with any tabular
material that you try to typeset.

(\cr - mnemonic for  <CR> = carriage-return )


Rule #1 for macro-writers:

   Do *not* use 1-letter or 2-letter macro names,
   unless you really, really, really know what you
   are doing; and even then, you should choose something
   longer that better describes the purpose of the macro.


>
> But how can I easily switch back and forth between the main font  
> and the
> alternate font without having to redefine the main font each time.
>
> If I define the main font thusly:
>
> \newfontfamily\lmr{LMRoman12}
>
> and switch back and forth between \lmr and \cr I do not seem to be
> able to keep the latex mapping. Any ideas would be appreciated.

I don't know what "keep the latex mapping" means.
What kind of errors do you get?

Try changing your macro-names, to see whether that helps.

e.g.  \newfontfamily\cree{BJECree}e


But why keep switching?
If you only use the alternate font for words and phrases,
then take advantage of TeX groupings:

e.g.;
   .... in this sentence some {\cree words} are in
   {\cree a different font} whereas most is in
   the same {\cree basic} font. ...


Or use a macro with parameter, as follows:

\newcommand{\altfont}[1]{{\cree #1}}

   .... in this sentence some \altfont{words} are in
   \altfont{a different font} whereas most is in
   the same \altfont{basic} font. ...


This way you only ever set the main font once,
and the switches into the alternate font are well-defined.



>
> -- 
> Best regards,
> David
>


Hope this helps,

	Ross


------------------------------------------------------------------------
Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114
------------------------------------------------------------------------




More information about the XeTeX mailing list