3

Im trying to make tufte-book to use EB Garamond. It does, but sadly, i have quite a few overfull boxes because many packages/styles use bold fonts.

An MWE for the complaint would be this:

\documentclass[a4paper,nobib,twoside,nofonts,nols]{tufte-book}

\usepackage{ebgaramond}

\ifxetex
  \usepackage{fontspec}
  \setmainfont{EB Garamond}
  % some more renewals, as suggested in http://tex.stackexchange.com/a/202189/9293
  % \renewcommand{\bfseries}[1]{\swshape}

\fi

\begin{document}
\part{Whine and cheese}
\end{document}

The above mwe compiles with the warnings:

LaTeX Font Warning: Font shape `EU1/EBGaramond(0)/bx/n' undefined
(Font)              using `EU1/EBGaramond(0)/m/n' instead on input line 32.

[1] [2] (index.aux)stdin -> index.pdf
[1][2]
4341 bytes written


LaTeX Font Warning: Some font shapes were not available, defaults substituted.

If i use my full document, its getting worse, because quite a few line breaks are at the wrong places (i suspect the font substitution to be the culprit).

I already tried to renew the \bfseries command, as i suspect it to be responsible to be used in the book.sty, but if i do, the text for the part changes (first few chars are omitted, and "Part" is dropped, too), probably because redefining \bfseries does more than setting font weight :/

Therefore i ask you: a) How to redefine the acutal font parameterization only for \part, and b) How to redefine all bold for all usage of ebgaramond? (Because EB Garamond does not support bx)

or in general: How to fix such an problem?

  • 1
    EB Garamond has no bold font. End of game. – egreg Sep 25 '16 at 20:01
  • hmm. why that? (ebgaramond.sty defines a BoldFont. Why is that one not used?) Or to put it differently: Who does misbehave? ebgaramond.sty? xetex? or book.sty? Or me? – helt Sep 25 '16 at 20:10
  • 1
    ebgaramond.sty defines a bold font, but if you look closely, it's the medium size one. You get the warning because you're overriding the action of the package by declaring \setmainfont{EB Garamond}; remove the declaration and the warning will disappear. – egreg Sep 25 '16 at 20:16
  • thanks. and once again, TeX leaves me puzzled... So basically thats an answer, right? Mind posting it below? – helt Sep 25 '16 at 20:23
  • And I don't think the overfull boxes have anything to do with boldface missing. – egreg Sep 25 '16 at 20:24
3

The ebgaramond package contains the code

  \setmainfont
      [ Numbers = {\ebgaramond@figurealign,\ebgaramond@figurestyle},
        UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont    = *-Regular ,
        BoldItalicFont     = *-Italic ,
      ]
      {EBGaramond12}

which is executed when the typesetting engine is XeLaTeX or LuaLaTeX. The two macros for the Numbers option are set with package options (or applying the default values).

If you look closely, the BoldFont option declares the same font for UprightFont and the same for BoldItalicFont and ItalicFont. The reason is simple: EB Garamond features no boldface font so the package instructs fontspec to use medium weight fonts for it.

Analogously, the .fd file for the fonts with pdflatex has

\DeclareFontShape{T1}{EBGaramond-LF}{b}{n}{ <-> ssub * EBGaramond-LF/m/n }{}

and other similar (silent) substitutions whose purpose is avoiding warning messages like the one you report.

Why do you get it nonetheless? Because of the declaration

\setmainfont{EB Garamond}

that you have after loading the package, which overrides the previous one. Since the font doesn't have boldface to begin with, when fontspec is building the font family data, it doesn't find it, so it doesn't define it and when requested for boldface, LaTeX issues the standard warning for a (nonsilent) substitution.

Remove the declaration.


Avoid also xlxtra: at present it just loads some packages:

  • ifxetex
  • fontspec
  • realscripts
  • metalogo

Just load fontspec instead. The realscripts package may or may not work with the fonts you declare: it's better to experiment whether it does good or not. If you don't need to typeset the XeLaTeX or other similar logos, you don't need metalogo. If you do, load it explicitly.

|improve this answer|||||
  • 1
    It isn't necessary to load ifxetex or fontspec either since ebgaramond will load them if XeLaTeX is used (or LuaLaTeX). Nor, in fact, is it necessary to load ebgaramond since ebgaramond-maths will load it. So \usepackage{ebgaramond-maths} would be sufficient. – cfr Sep 25 '16 at 20:55
  • @cfr This is contingent to the particular packages and might go wrong if different ones are loaded. – egreg Sep 25 '16 at 21:46
  • So is the advice to remove \setmainfont. That may not be at all desirable if the standard font support package is not Xe/Lua aware. – cfr Sep 25 '16 at 21:55
  • @cfr So many variations are possible. But, as a general rule, I like to see the essential packages I need. – egreg Sep 25 '16 at 21:57
0

The following code sample works (for me) with TeXLive, with document classes that include article, tufte-book, and memoir, as processed by pdflatex, tex + dvi, and xetex.

The output should look something like this:

enter image description here

From source code like this:

\documentclass{tufte-book}
%  \documentclass{article} % also works
%  \documentclass{memoir}  % also works

\RequirePackage{lmodern}   % supports \ttfamily\bfseries
\RequirePackage{garamondx} % supports \rmfamily\bfseries
\edef\EBfamilydefaultbf{\familydefault}
\edef\EBrmdefaultbf{\rmdefault}
\RequirePackage[oldstyle,proportional,scaled=1.05]{ebgaramond} 
\edef\EBfamilydefault{\familydefault}
\edef\EBrmdefault{\rmdefault}

\RequirePackage{ifthen}
\makeatletter%
  \newcommand{\iffont}[3]{\ifthenelse{\equal{\f@family}{#1}}{#2}{#3}}
  \newcommand{\ifseries}[3]{\ifthenelse{\equal{\f@series}{#1}}{#2}{#3}}
\makeatletter

\let\oldbfseries\bfseries
\renewcommand{\bfseries}{\iffont{\EBrmdefault}%
  {\fontfamily{\EBrmdefaultbf}\selectfont\oldbfseries}%
  {\oldbfseries}%
}
%  
\let\oldmdseries\mdseries
\renewcommand{\mdseries}{\iffont{\EBrmdefaultbf}%
  {\fontfamily{\EBrmdefault}\selectfont\oldmdseries}%
  {\oldmdseries}%
}
%  
\let\oldrmfamily\rmfamily
\renewcommand{\rmfamily}{\ifseries{b}%
  {\fontfamily{\EBrmdefaultbf}\selectfont}%
  {\oldrmfamily}%
}

\begin{document}
% ----------------------------------------------------------------
% the following is necessary solely to undo some 'garamondx' patches
\edef\rmdefault{\EBrmdefault}\normalsize\mdseries\upshape\rmfamily%
% ----------------------------------------------------------------

\centering    
\DeclareRobustCommand{\lit}[1]{\ttfamily\textbackslash{#1}}
\begin{tabular}{rl}
\lit{rmfamily}\lit{mdseries}\lit{upshape} & \rmfamily\mdseries\upshape Quantum\\
\lit{rmfamily}\lit{mdseries}\lit{itshape} & \rmfamily\mdseries\itshape Quantum\\
\lit{rmfamily}\lit{mdseries}\lit{scshape} & \rmfamily\mdseries\scshape Quantum\\[1ex]
\lit{rmfamily}\lit{bfseries}\lit{upshape} & \rmfamily\bfseries\upshape Quantum\\
\lit{rmfamily}\lit{bfseries}\lit{itshape} & \rmfamily\bfseries\itshape Quantum\\
\lit{rmfamily}\lit{bfseries}\lit{scshape} & \rmfamily\bfseries\scshape Quantum\\[1ex]
\lit{ttfamily}\lit{mdseries}\lit{upshape} & \ttfamily\mdseries\upshape Quantum\\
\lit{ttfamily}\lit{mdseries}\lit{itshape} & \ttfamily\mdseries\itshape Quantum\\
\lit{ttfamily}\lit{mdseries}\lit{scshape} & \ttfamily\mdseries\scshape Quantum\\[1ex]
\lit{ttfamily}\lit{bfseries}\lit{upshape} & \ttfamily\bfseries\upshape Quantum\\
\lit{ttfamily}\lit{bfseries}\lit{itshape} & \ttfamily\bfseries\itshape Quantum\\[1ex]
\lit{sffamily}\lit{mdseries}\lit{upshape} & \sffamily\mdseries\upshape Quantum\\
\lit{sffamily}\lit{mdseries}\lit{itshape} & \sffamily\mdseries\itshape Quantum\\[1ex]
\lit{sffamily}\lit{bfseries}\lit{upshape} & \sffamily\bfseries\upshape Quantum\\
\lit{sffamily}\lit{bfseries}\lit{itshape} & \sffamily\bfseries\itshape Quantum\\
\end{tabular}

\end{document}

Caveat: I am no sort of LaTeX guru.

|improve this answer|||||
  • \bfseries etc. are declared as robust commands which include checks for maths mode. Aside from typographic considerations, this is probably going to have rather strange side-effects. – cfr Jan 25 '17 at 1:53
  • I guess it still checks, maybe, but .... – cfr Jan 25 '17 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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