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.

Alex
  • 418
  • 3
  • 12
  • 3
    \bf is deprecated in LaTeX. Using either \textbf or \bm from package bm (bold math) instead, it works as expected. – Paul Gessler Mar 08 '15 at 05:14
  • 1
    Welcome to TeX.SX! –  Mar 08 '15 at 05:15
  • See original post for response to comments. Thank you! – Alex Mar 08 '15 at 05: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. – Paul Gessler Mar 08 '15 at 05: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. – Sean Allred Mar 08 '15 at 05:23
  • @PaulGessler Well, the point was, the standard mathcal O prints like a regular O with a little gap in the middle, not large enough to see in print. That was why I wanted my own O, with a noticeable curve, which is not what regular MathCal gives. Edit: Thank you, your answer does both. – Alex Mar 08 '15 at 05:27
  • @SeanAllred So... what should I do now? Technically what I edited into the post is not the "answer", just a workaround... Please do explain, because this is a convention I have trouble understanding on other StackExchange forums as well. – Alex Mar 08 '15 at 05:27
  • @Alex I'm logging off for the night, but I'm certain we'd be happy to explain everything in chat if you drop on in :) – Sean Allred Mar 08 '15 at 06:08

2 Answers2

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

Paul Gessler
  • 29,607
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.

egreg
  • 1,121,712
  • 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 01 '17 at 00:07
  • 1
    @Alex Without seeing code it's not possible to suggest workarounds. Please, open a new question with a minimal example. – egreg Nov 01 '17 at 10:04