Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm experimenting with Unicode-Math. I am using Neo-Euler with Concrete so I am generating my document with xelatex. I want \Re to give me the AMS-style double-lined \mathbb{R} but I am having trouble redefining \Re in my .cls.

That is, using test.cls at the bottom of this question I run this sample document and it works great; I see the double-lined R in all three places.

\documentclass{test}
% If \def here then it does not work. 
\begin{document}
\def\Re{\mathbb{R}}
Hello.  $x=4\mathbb{R}$. Give me a $\Re$ and a $\R$.
\end{document}

However, if I move the \def to above the \begin{document} then I only see the double-lined R in two places and in the middle I get Knuth's \Re, the somewhat-fractur single-lined shape. In particular, putting my redefinition inside the .cls below has no effect. I expect there is some \AtBeginDocument at work, but I was unable to make it out. Is there some way to not have the \def inside the \begin{document}?

% test.cls

% --- Class structure: identification part
% ---
\ProvidesClass{ltest}[2012/09/10 version 0.01 Test unicode-math]
\NeedsTeXFormat{LaTeX2e}

% --- Class structure: initial code part
% ---


% --- Class structure: declaration of options part
% ---
% This class extends the article class
% Read all the documentclass options; pass them to article
%\DeclareOption*{\InputIfFileExists{\CurrentOption.tut}{}{%
%    \PassOptionsToClass{\CurrentOption}{report}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}

% --- Class structure: execution of options part
% ---
\ProcessOptions \relax

% --- Class structure: declaration of options part
% ---
\LoadClass{article}

% --- Class structure: main code part
% ---

% Set the fonts
\usepackage{fontspec}
\setmainfont[Ligatures=TeX,  % CM-Super Concrete
             Path = /usr/local/texlive/2012/texmf-dist/fonts/type1/public/cm-super/,
             ItalicFont = sfoti10.pfb,
             SmallCapsFont = sfocc10]{sform10.pfb}

\usepackage[math-style=upright]{unicode-math} % see http://tex.stackexchange.com/questions/50995/font-mixup-with-neo-euler-and-fontspec
\setmathfont[Path=/usr/local/texlive/texmf-local/fonts/opentype/euler/]{euler.otf}
% \AtBeginDocument{\DeclareMathAlphabet\mathbf{U}{eur}{b}{n}} % fontspec manual p. 11; doesn't seem to do anything.
\setmathfont[range=\mathbb,
             Path=/usr/local/texlive/2012/texmf-dist/fonts/type1/public/amsfonts/symbols/]{msbm10.pfb}  

\newcommand{\R}{\mathbb{R}}
share|improve this question
    
You have an accept rate of 0 %. You will get more qualified answers if you upvote helpfull answers you got and accept the most helpfull answer. –  Kurt Sep 10 '12 at 14:07
    
Not related to the issue, but normally I would not hard-code the font paths into a class file. –  Joseph Wright Sep 10 '12 at 14:14
add comment

1 Answer

up vote 4 down vote accepted

unicode-math does many of its workings \AtBeginDocument.

Just put the redefinition of \Re in \AtBeginDocument after loading unicode-math (also in the class, if you so wish).

\documentclass{test}

\AtBeginDocument{\def\Re{\mathbb{R}}}

\begin{document}
Hello.  $x=4\mathbb{R}$. Give me a $\Re$ and a $\R$.
\end{document}
share|improve this answer
    
Ah, nice. Thank you. –  Jim Hefferon Sep 10 '12 at 14:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.