4

As long as I do not use \bf, my font works fine. Starting with $$ within which I first use \bf, and every instance thereafter, instead of getting the font I defined I keep getting bold letters. How do I fix this?

The problem might lie in the fact that I defined my own font. AMSFonts User Guide mentions several font families which can be used to define new fonts. Since it does not tell how to do so, I had to hack together a way to define my own font which I called \Cal.

\documentclass{article}
\usepackage{amsfonts}

\newfam\calfam
\font\calten=eusm10
\font\calseven=eusm7
\font\calfive=eusm5
\textfont\calfam=\calten
\scriptfont\calfam=\calseven
\scriptscriptfont\calfam=\calfive
\def\Cal{\fam=\calfam}

\begin{document}
${\Cal O}$ ${\Cal O}{\bf a}b{\Cal O}$ ${\Cal O}$
\end{document}

The first \Cal O shows up fine; the rest show up bold instead. Note that the b does NOT show up bold: so the bold-ness has obviously ended with the a. However, the O's keep showing up bold thereafter. How can I get regular \Cal O's throughout my document?

Thank you in advance. Update:

I found the answer: Does it matter if I use \textit or \it, \bfseries or \bf, etc

{\bf foo}, for example, resets all font attributes which had been set earlier before it prints foo in bold face.

In other words, when I used bf, I guess it reset some variable that I had not defined when defining my font. While it would be nice to know how to define my font to allow it to go back to normal, I guess I will have to use the longer \mathbf in the meanwhile.

8
  • 3
    \bf is deprecated in LaTeX. Using either \textbf or \bm from package bm (bold math) instead, it works as expected. Mar 8, 2015 at 5:14
  • 1
    Welcome to TeX.SX!
    – user31729
    Mar 8, 2015 at 5:15
  • See original post for response to comments. Thank you!
    – Alex
    Mar 8, 2015 at 5:16
  • Also, since you are using LaTeX, not plain TeX, you could just add \usepackage{eucal} and use the standard \mathcal to avoid the "hack together" method altogether. Mar 8, 2015 at 5:23
  • 1
    Please don't edit the answer into the question – that's not how this platform works :) Either wait for @PaulGessler to post an answer or, if he does not, self-answer. Mar 8, 2015 at 5:23

2 Answers 2

4

This is a typical “don't do it” code. The instructions \newfam and \font should never be used in LaTeX at the user's level. For instance, if you change the point size option of your document from the default 10pt to 11pt, you'll have to manually modify the font assignments.

You should rather rely on the font selection scheme, which is not really difficult. First, define a font family

\DeclareFontFamily{U}{eus}{\skewchar\font'60}
\DeclareFontShape{U}{eus}{m}{n}{%
     <-6>eusm5%
    <6-8>eusm7%
    <8->eusm10%
}{}
\DeclareFontShape{U}{eus}{b}{n}{%
     <-6>eusb5%
    <6-8>eusb7%
    <8->eusb10%
}{}

(the U encoding is predefined, and it applies no “transformation”). Then you can define a new math alphabet

\DeclareMathAlphabet{\matheucal}{U}{eus}{m}{n}
\SetMathAlphabet{\matheucal}{bold}{U}{eus}{b}{n}

In the document you'll use the “correct” syntax

$\matheucal{O}$ $\matheucal{O}\mathbf{a}b\matheucal{O}$ $\matheucal{O}$

With the \SetMathAlphabet instruction, the math alphabet will respect the \boldmath declaration and, if \usepackage{bm} is given, the code

\bm{\matheucal{O}}

will produce a boldface calligraphic “O” also under normal math version.

More than that, you'll ensure that the calligraphic letters have the correct size also in contexts where \large, \small, \footnotesize and similar declarations are in force, which will not be the case with your \font based approach.

This said, the eucal package does exactly what's outlined above; if you declare

\usepackage{eucal}

then Euler calligraphic will be output when \mathcal is used; if you want to keep the original meaning of \mathcal for using Euler calligraphic along with the default calligraphic (but you shouldn't, because the shapes are not so different from one another), load the package by

\usepackage[mathscr]{eucal}

that will make Euler calligraphic available with \mathscr.

2
  • Thank you very much-- your suggestion worked. But what can I do if \matheucal is already defined by another package, and I wish to use the same macro name? My re-definition does seem to take precedence, but LaTeX keeps complaining about it each time I re-compile the file...
    – Alex
    Nov 1, 2017 at 0:07
  • 1
    @Alex Without seeing code it's not possible to suggest workarounds. Please, open a new question with a minimal example.
    – egreg
    Nov 1, 2017 at 10:04
5

\bf is deprecated in LaTeX, you should use \textbf instead if it's meant to be upright, or \bm with \usepackage{bm} for bold math if it's meant to be bold italic math.

Since you are using LaTeX, there's already a solution for your problem in the package eucal. With this you can avoid the "hack together" method entirely:

\documentclass{article}
\usepackage{amsfonts,eucal}
\usepackage{bm}

\begin{document}
${\mathcal O}$%
${\mathcal O}{\bm a}b{\mathcal O}$%
${\mathcal O}$
\end{document}

enter image description here

4
  • Did you do a printscreen to get this image to display on the forum? Or is there an easier way?
    – Alex
    Mar 8, 2015 at 5:29
  • Yes, I used Snipping Tool and uploaded the image. More details at how can i upload an image to be included in a question or answer? Mar 8, 2015 at 5:36
  • \bm is not a font switch, it expects an argument... Same for \mathcal. Mar 8, 2015 at 12:17
  • @karlkoeller you're right, and a (a single token) is the argument. The same is true for \mathcal. Mar 8, 2015 at 12:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .