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.

Remarks

The newtxmath-package comes with support for various fonts, including libertine, minion or garamondx. Personally I like the Garamond very much, but garamondx is not part of the default installation. Thus I use ebgaramond instead.

To do so, I just copied the part, where the fonts are set up from newtxmath.

Problem statement

Here is a minimal NOT working example of what I have tried so far to load ebgaramond as a math alphabet. (unicode-math or mathspec is not an option, it needs to be pdflatex compatible)

\documentclass{article}
\usepackage{ebgaramond}
\usepackage[cmintegrals,cmbraces]{newtxmath}
\DeclareSymbolFont{letters}{OML}{EBGaramond12-Italic-lf-t1--base}{m}{it}
\SetSymbolFont{letters}{bold}{OML}{EBGaramond12-Italic-lf-t1--base}{b}{it}
\DeclareFontSubstitution{OML}{EBGaramond12-Italic-lf-t1--base}{m}{it}
\begin{document}
ABCDEFGHIJKLMNOPQRSTUVWXYZ

abcdefghijklmnopqrstuvwxyz

1234567890

$ABCDEFGHIJKLMNOPQRSTUVWXYZ$

$abcdefghijklmnopqrstuvwxyz$

$1234567890$
\end{document}

Bonus question

How can I use swash glyphs as mathcal alphabet?


EDIT 2014-01-03

Pointed out by cfr's comment, the question reduces to How can I create OML files for ebgaramond? (The bonus question remains valid)

share|improve this question
    
This doesn't work because there is no font definition file for EBGaramond12-Italic-lf-t1--base in the OML encoding. First, that is not a font family name. Second, no support is provided in ebgaramond for OML at all. Assuming that the fonts themselves include the required characters, you would need to generate additional support files in order to use the OML encoding in regular LaTeX/pdfLaTeX. Basically this involves supplementing or replacing the existing ebgaramond support package. This is not especially difficult if you are sufficiently persistent but it is time-consuming and a bit fiddly. –  cfr Jan 1 at 19:05
    
It should be more straightforward to setup the swash characters for mathcal, at least assuming that the mathcal alphabet doesn't need to contain much else. –  cfr Jan 1 at 19:07
    
Do you know that it is very easy to install garamondx using the getnonfreefonts script? That would surely be by far the simplest solution. –  cfr Jan 1 at 19:08
    
I'd accept an answer pointing out, how to create the OML support files - I will also offer a bounty. Using getnonfreefonts is only a practical solution on my own computer. –  Henri Menke Jan 3 at 7:40
    
I don't typeset much mathematics and I'm not very familiar with the set up for maths fonts. What exactly should the output look like? The upper and lower case letters should be in the italic shape of EBGaramond, I assume. What about the numbers? Right now, I'm getting OSF upright numbers in both text and maths when I typeset your sample and I'm not sure that is correct! It shouldn't be terribly difficult to get what is wanted into the OML files. I'm just not sure what I'm trying to do right now. –  cfr Jan 3 at 20:24

1 Answer 1

up vote 13 down vote accepted
+100

Update

The simplest solution is now to use ebgaramond-maths, a new package available from CTAN.

ebgaramond-maths is now included in TeX Live. If you have TeX Live 2014 installed, you should get the package when you update. (For example, running tlmgr update --all at the command line or using your GUI wrapper of choice.)

The answer below is now likely to be useful only if you want to tweak the results or apply the method to a different font.

Original Answer

Setting up the \mathcal stuff is relatively straightforward. Setting up the OML support is less so.

Provide OML support for EBGaramond

Several approaches are possible. I've taken what seemed to me to be the simplest given the way the existing ebgaramond package works. I would probably do this differently if I was generating support for both text and mathematics from scratch but in this case I'm trying to avoid duplication of effort as much as possible.

Variables

  • Make a working directory somewhere which I'll call ${work}. Doesn't matter where so long as you have permission to write there. (Don't do this as root, obviously.)

  • I'll call ${texmain} your main, current texmf directory. On my system, that's /usr/local/texlive/current or /usr/local/texlive/2013.

Working environment

Change to ${work}. From now on, I assume that all commands are executed in this directory and that all created files are saved here.

Copy needed files to your working directory or make symbolic links if preferred:

cp ${texmain}/texmf-dist/tex/fontinst/mathetx/oml.etx ${texmain}/texmf-dist/fonts/opentype/public/ebgaramond/EBGaramond12-Italic.otf ./

or

ln -s ${texmain}/texmf-dist/tex/fontinst/mathetx/oml.etx ${texmain}/texmf-dist/fonts/opentype/public/ebgaramond/EBGaramond12-Italic.otf ./

Create a preliminary encoding file

This is not the encoding file you'll finally tell TeX about but it will form the basis for that file.

First, run fontinst in interactive mode. (That is, just type 'fontinst' as the command.) At the prompt:

\input finstmsc.sty
\etxtoenc{oml}{oml-ebgaramond}
\bye

This will produce oml-ebgaramond.enc which you can lightly modify before feeding to otftotfm.

sed -i -e 's/TeXMathItalicEncoding/EBGaramondTeXMathItalicEncoding/g' -e 's/oldstyle//' oml-ebgaramond.enc

Generate the TeX font

ebgaramond already provides the type1 files you need so there is no need to regenerate those. All that is required is to generate a suitable .tfm.

otftotfm -e oml-ebgaramond.enc EBGaramond12-Italic.otf > EBGaramond-Maths.map

This will create both the .tfm file and the .map file fragment TeX needs to use the font. Essentially, the .tfm just is a font as far as TeX is concerned. (pdfTeX sees things slightly differently - it wants the type1 bit as well.)

It will also create a new encoding file with what will almost certainly be a very weird name. This is the encoding file TeX will use, as specified in the .map file fragment. oml-ebgaramond.enc can now be deleted if you wish as it is no longer required.

Create the font definition for LaTeX

otftotfm does not generate font definition files for LaTeX as far as I can tell but the file is pretty simple in this case. Create a file with the following content:

%Filename: OMLEBGaramond-Maths.fd
%Based on a file created using fontinst v1.928

%THIS FILE SHOULD BE PUT IN A TEX INPUTS DIRECTORY

\ProvidesFile{OMLEBGaramond-Maths.fd}
   [2014/01/03 font definitions for OML/EBGaramond-Maths.]

\DeclareFontFamily{OML}{EBGaramond-Maths}{}

\DeclareFontShape{OML}{EBGaramond-Maths}{m}{it}{
   <-> EBGaramond12-Italic--oml-ebgaramond
}{}

\DeclareFontShape{OML}{EBGaramond-Maths}{b}{it}{<->ssub * EBGaramond-Maths/m/it}{}
\DeclareFontShape{OML}{EBGaramond-Maths}{bx}{it}{<->ssub * EBGaramond-Maths/m/it}{}

\endinput

and save it as OMLEBGaramond-Maths.fd. This tells LaTeX what the font family EBGaramond-Maths consists of in the OML encoding. Specifically, it tells it which TeX fonts belong to this family in this encoding and the characteristics of each one. (In this case, there's only one such font which is then substituted for other weights as there is no bold in EBGaramond and OML only cares about the italic shape.)

Create a package file for LaTeX (optional)

It is generally easier to load a package than repeat the font set up each time you wish to use a particular configuration, so I would create a LaTeX package. To do so, create another file with the following content:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ebgaramond-maths}[2014/01/03 v1.0 ebgaramond-maths for use with EBGaramond]

\RequirePackage{ebgaramond}

% \pdfmapfile{+EBGaramond-Maths.map}

\DeclareSymbolFont{letters}   {OML}   {EBGaramond-Maths} {m} {it}
\DeclareSymbolFont{operators} {OT1}   {EBGaramond-LF}    {m} {n}

\SetSymbolFont{letters}   {bold}  {OML} {EBGaramond-Maths} {b}  {it}
\SetSymbolFont{operators} {bold}  {OT1} {EBGaramond-LF}    {bx} {n}

\DeclareFontSubstitution{OML}{EBGaramond-Maths}{m}{it}
\DeclareFontSubstitution{OT1}{EBGaramond-LF}{m}{n}

\SetMathAlphabet{\mathbf}   {normal}  {OT1} {EBGaramond-LF} {bx} {n}
\SetMathAlphabet{\mathbf}   {bold}    {OT1} {EBGaramond-LF} {bx} {n}
\SetMathAlphabet{\mathit}   {normal}  {OT1} {EBGaramond-LF} {m}  {it}
\SetMathAlphabet{\mathit}   {bold}    {OT1} {EBGaramond-LF} {bx} {it}

\DeclareMathAlphabet{\mathcal} {OT1} {EBGaramond-LF} {m} {sw}

\endinput

and save it as ebgaramond-maths.sty.

  • If you do not wish to ask people to install the fonts, uncomment the relevant line in the .sty file.

Then, from ${work} the result can be tested prior to installation of the fonts:

\documentclass{article}
\usepackage{ebgaramond}
\usepackage[cmintegrals,cmbraces]{newtxmath}
\pdfmapfile{+EBGaramond-Maths.map}
\usepackage{ebgaramond-maths}

\begin{document}
ABCDEFGHIJKLMNOPQRSTUVWXYZ

abcdefghijklmnopqrstuvwxyz

1234567890

$ABCDEFGHIJKLMNOPQRSTUVWXYZ$

$abcdefghijklmnopqrstuvwxyz$

$1234567890$

$\Gamma\varGamma\Delta\Lambda\varLambda\Xi\varXi\Pi\varPi\Sigma\varSigma\Upsilon\varUpsilon\Phi\varPhi\Psi\varPsi\Omega\varOmega$

$\alpha\beta\gamma\delta\epsilon\varepsilon\zeta\eta\theta\iota\kappa\lambda\mu\nu\xi\pi\rho\varrho\sigma\varsigma\tau\upsilon\phi\varphi\chi\psi\omega$

$\mathbf{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$

$\mathbf{abcdefghijklmnopqrstuvwxyz}$

$\mathbf{0123456789}$

$\mathit{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$

$\mathit{abcdefghijklmnopqrstuvwxyz}$

$\mathit{0123456789}$

$\mathrm{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$

$\mathrm{abcdefghijklmnopqrstuvwxyz}$

$\mathrm{0123456789}$

$\mathcal{ABCDEFGHIJKLMNOPQRSTUVWXYZ}$

$\mathcal{abcdefghijklmnopqrstuvwxyz}$

$\mathcal{0123456789}$

\end{document}

produces:

enter image description here

share|improve this answer
    
Thank you for your really detailed answer. I will try it out as soon as possible. I will award the bounty, when TeX.SX lets me do it. –  Henri Menke Jan 4 at 15:41
    
No worries. Let me know how it goes. It is always hard to think exactly what I do to explain it so let me know if anything seems to be missing or doesn't make sense. Since you are using TL 2013 on GNU/Linux, it should all apply fairly straightforwardly but the proof is in the pudding, as they say. –  cfr Jan 4 at 16:45
1  
Would you mind uploading this as a package to CTAN, that we can all enjoy it in TeXlive 2014? (This would be worth definitely worth another 200 rep bounty) –  Henri Menke May 4 at 15:05
1  
There's no rush. –  Henri Menke May 4 at 18:20
2  
@HenriMenke I hope you meant that last comment as I just uploaded to ctan. (However, I always get the format wrong so I doubt that this particular attempt will succeed. I'm pretty sure this is not entirely my fault and that they do change their minds. Though I'm not claiming to be entirely blameless, either. In any case, somebody will probably tell me which layout they want.) –  cfr Sep 2 at 2:28

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.