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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am happy with the great majority of what unicode-math does. But at times I find that I prefer a symbol the way it was before. With \varnothing and \complement, for example. In those cases I was able to save them under a different name before loading unicode-math, but this doesn't always work.

Right now I'm trying to access the \mathcal alphabet from plain LaTeX. How might I accomplish this?


Additional Question

I've been looking through unicode-math, trying to figure out where exactly the original \mathcal alphabet gets discarded, but I eventually gave up.

It would be interesting if someone could explain:

  • how/where the original \mathcal font is defined anyway, and
  • what kind of 'switch' is thrown by unicode-math that makes it unavailable.
share|improve this question
1  
You can't, unless you are using CM Math (then it will be default) See also this question: tex.stackexchange.com/questions/120065/… – Henri Menke Aug 7 '13 at 21:33
    
@HenriMenke Hm... But the comments there imply that you cannot use Computer Modern at all if you use unicode-math. So what do you mean by "unless"? --- Anyway, the notion that there's no way to do it is so silly I reject it. Even if I cannot just load it as a font, I could patch unicode-math to leave \mathcal alone or, as a last resort, I could typeset the alphabet in a box before loading unicode-math and then use the box. --- But I have to believe there are more elegant solutions than that. – mhelvens Aug 7 '13 at 21:46
    
Let me cite the following comment from the linked question: »You can't use Computer Modern with unicode-math, the last example you get it from Latin Modern Math which is the closest you can get. – Khaled Hosny« Please note, that Khaled Hosny is one of the original developers of unicode-math. Saving the alphabet to a box might indeed be possible, but will for sure bring several downsides. – Henri Menke Aug 8 '13 at 10:35
    
I read those comments. And I have no doubt Khaled is right in that there is no standard option through the unicode-math interface by which the original font can be retrieved (perhaps there should be). But I would even be happy with a patch or 'hack' – one which is more elegant than using boxes. --- Indeed, storing those characters in boxes has downsides. I mention some in my answer below. --- Anyway, thanks for your help! – mhelvens Aug 8 '13 at 12:45
    
@mhelvens The problem is that the entire math font mechanism is altered to deal with Unicode math fonts. For 'traditional' TeX, you simply change the family (\mathcal boils down to \fam2, at least 'out of the box'). That simply doesn't work once you switch to the Unicode mechanism, which doesn't use families at all. – Joseph Wright Aug 8 '13 at 12:56
up vote 2 down vote accepted

Just override the declarations with the original one:

\documentclass{article}

\usepackage{unicode-math}

\DeclareMathAlphabet{\mathcal}{OMS}{cmsy}{m}{n}

\begin{document}
$\mathcal{DFIP}_{\mathcal{DFIP}_{\mathcal{DFIP}}}$
\end{document}

enter image description here

This is the output of pdffonts, showing that cmsy is used.

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
GQWLIO+CMSY10                        Type 1C           Builtin          yes yes no       4  0
NCPDNV+CMSY7                         Type 1C           Builtin          yes yes no       5  0
BZNGBB+CMSY5                         Type 1C           Builtin          yes yes no       6  0
MMERCJ+LMRoman10-Regular-Identity-H  CID Type 0C       Identity-H       yes yes yes      8  0
share|improve this answer
    
And I guess this is the actual answer. Thanks! :-) – mhelvens Apr 21 at 20:53
    
@mhelvens Sorry for being late; but maybe this wouldn't have worked at the time. – egreg Apr 21 at 20:54
    
That's fine. I found a different solution at the time. And right now it's best to keep the Q&A's current. – mhelvens Apr 22 at 14:27

I'll just share the solution I'm using at the moment. It's far from ideal, but it's fine if you only need a few letters of the calligraphic alphabet. For example, I need only D, F, I and P throughout my document:

\documentclass{article}

\makeatletter
\newcommand\preserveCal[2]{
    \expandafter\newsavebox\csname box@\string#1\endcsname
    \expandafter\savebox\csname box@\string#1\endcsname{\ensuremath{\mathcal{#2}}}
    \expandafter\def\expandafter#1\expandafter
        {\expandafter\usebox\csname box@\string#1\endcsname}
}
\preserveCal{\calD}{D}
\preserveCal{\calF}{F}
\preserveCal{\calI}{I}
\preserveCal{\calP}{P}
\makeatother

\usepackage{unicode-math}

\begin{document}
    \noindent$\mathcal{DFIP}$\par
    \noindent$\calD\calF\calI\calP$
\end{document}

enter image description here

This is a generally applicable 'last resort' way to preserve symbols that are destroyed by a package. The problem is that these don't scale with the font. Also, each symbol takes up a whole box register, and I believe there are only 256 box registers available.

share|improve this answer
    
I generally don't like to accept my own answers on SE, especially not this one. But since it is the only answer I've found that actually works, I will. If someone else shares a more elegant answer in the future, I'll happily surrender the green tick. – mhelvens Aug 11 '13 at 13:09

Very late answer, but you could also locally set the mathcodes of the letters to the ones plain TeX defines. Then you load the Computer Modern Calligraphic fonts and redefine \mathcal to locally switch to this family and use the “legacy” mathcodes.

This solution is superior to the other answer, because you obtain proper scaling of the calligraphic letters in sub/superscripts.

\documentclass{article}

\usepackage{unicode-math}

\newtoks\legacymathcodes\legacymathcodes={
\mathcode`A="7141 \mathcode`B="7142 \mathcode`C="7143
\mathcode`D="7144 \mathcode`E="7145 \mathcode`F="7146
\mathcode`G="7147 \mathcode`H="7148 \mathcode`I="7149
\mathcode`J="714A \mathcode`K="714B \mathcode`L="714C
\mathcode`M="714D \mathcode`N="714E \mathcode`O="714F
\mathcode`P="7150 \mathcode`Q="7151 \mathcode`R="7152
\mathcode`S="7153 \mathcode`T="7154 \mathcode`U="7155
\mathcode`V="7156 \mathcode`W="7157 \mathcode`X="7158
\mathcode`Y="7159 \mathcode`Z="715A
}

\font\tensy=cmsy10
\font\sevensy=cmsy7
\font\fivesy=cmsy5
\newfam\cmcalfam
\textfont\cmcalfam=\tensy
\scriptfont\cmcalfam=\sevensy
\scriptscriptfont\cmcalfam=\fivesy
\protected\def\mathcal#1{{\fam\cmcalfam
    \the\legacymathcodes #1}}

\begin{document}
$\mathcal{DFIP}_{\mathcal{DFIP}_{\mathcal{DFIP}}}$
\end{document}

enter image description here

If you don't want to type all the mathcodes, e.g. in case you want to extend it to lowercase as well (which CM doesn't have), you could also set the mathcodes in a loop.

\documentclass{article}

\usepackage{unicode-math}

\font\tensy=cmsy10
\font\sevensy=cmsy7
\font\fivesy=cmsy5
\newfam\cmcalfam
\textfont\cmcalfam=\tensy
\scriptfont\cmcalfam=\sevensy
\scriptscriptfont\cmcalfam=\fivesy
\protected\def\mathcal#1{%
  \begingroup
    \fam\cmcalfam
    \count0=`A
    \loop\ifnum\count0<\numexpr`Z+1\relax
      \mathcode\count0=\the\numexpr"7141 - `A + \count0\relax
      \advance\count0 by 1
    \repeat
    #1%
  \endgroup
}

\begin{document}
$\mathcal{DFIP}_{\mathcal{DFIP}_{\mathcal{DFIP}}}$
\end{document}
share|improve this answer
    
Yep! That's definitely better. Accepted. – mhelvens Apr 20 at 11:56
    
@mhelvens I improved my answer. Especially note, that I have changed \def\mathcal to \protected\def\mathcal, which is more appropriate since assignments happen inside \mathcal. – Henri Menke Apr 21 at 8:04

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.