2

I am currently working on a document where I want the default font to be, as usual, Computer Modern. In particular, unless otherwise specified, this is the font that should be displayed.

Notwithstanding, at some points of the paper, I would like to be able to write a word with the font bookman, and then change back to Computer modern. I tried to use the advices given here, and produced something like this.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm,xparse}
\usepackage{bookman}
\usepackage[OT1]{fontenc}

\newcommand{\cmr}{\fontfamily{cmr}\selectfont} \newcommand{\pbk}{\fontfamily{pbk}\selectfont}

\begin{document} \cmr \section{Irrational Numbers.}

    Let the set of rational numbers be defined by
\[\mathbb Q:=\left\{\frac{a}{b} \mid a\in \mathbb Z,  b\in \mathbb N, \gcd(a,b)=1\right\}\]

    \textbf{Claim. } The {\pbk square root} of 2 is irrational.

      \begin{proof}
             Assume for the sake of contradiction that \ldots
          \end{proof}

\end{document}

produced image

As you can see in the image, even though Computer Modern was set to be the default font at the beginning via \cmr, and bookman was in fact used when appealing to \pbk, the later was also used in several environments such as \section or \begin{proof}, which was not what I wanted. What have I made wrong? And how could I repare it? Are there easier/alternative proceedings?

Thanks in advance.

user265131
  • 123
  • 3

3 Answers3

2

You need no \cmr command, if you don't load bookman, whose main purpose is to set Bookman as the main font.

If you look inside bookman.sty, you'll be able to retrieve the LaTeX font family name, that is, pbk.

Now you can define commands to switch to this font. I recommend as much abstraction as possible. Comments at the end.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}

\newcommand{\pbk}{\fontfamily{pbk}\selectfont} \DeclareTextFontCommand{\textpbk}{\pbk}

\newcommand{\memph}[1]{\textpbk{#1}} % change here if needed

\newcommand{\numberset}[1]{\mathbb{#1}} \newcommand{\NN}{\numberset{N}} \newcommand{\QQ}{\numberset{Q}} \newcommand{\ZZ}{\numberset{Z}}

\theoremstyle{definition} \newtheorem*{claim}{Claim}

\begin{document}

\section{Irrational Numbers.}

Let the set of rational numbers be defined by [ \QQ:=\left{ \frac{a}{b} ;\middle|; a\in \ZZ, b\in \NN \right} ]

\begin{claim} The \memph{square root} of $2$ is irrational. \end{claim}

\begin{proof} Assume for the sake of contradiction that \ldots \end{proof}

\end{document}

enter image description here

Comments

  1. Once you see the output, you should realize that the chosen font is not so good for emphasizing. With the proposed indirection, you can do several experiments *without changing the text inside document.

  2. Similarly for the number set notation.

  3. I removed the condition on the greatest common divisor. My mathematician self screamed when seeing it. I was able to keep him quiet on the choice of not having zero in the natural numbers, but…

egreg
  • 1,121,712
  • Thanks for the advice! You were right, I should have defined the rational numbers via an equivalence relation, rather than through the gcd condition. All in all, 2/4 is a rational number as well :) – user265131 Nov 21 '21 at 16:04
1

delete the line \usepackage{bookman} that file is, in total

\renewcommand{\rmdefault}{pbk}
\renewcommand{\sfdefault}{pag}
\renewcommand{\ttdefault}{pcr}

so setting the defaults for the whole document to be bookman, which you don't want.

Also you don't really want

\usepackage[OT1]{fontenc}

That does nothing as OT1 is the default, but you should almost always use T1 to get correct hyphenation.

David Carlisle
  • 757,742
1

David Carlisle’s answer, which would give you the file

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm,xparse}
\usepackage[T1]{fontenc}

\newcommand{\cmr}{\fontfamily{cmr}\selectfont} \newcommand{\pbk}{\fontfamily{pbk}\selectfont}

\begin{document} \cmr \section{Irrational Numbers.}

    Let the set of rational numbers be defined by
\[\mathbb Q:=\left\{\frac{a}{b} \mid a\in \mathbb Z,  b\in \mathbb N, \gcd(a,b)=1\right\}\]

    \textbf{Claim. } The {\pbk square root} of 2 is irrational.

      \begin{proof}
             Assume for the sake of contradiction that \ldots
          \end{proof}

\end{document}

works for PDFLaTeX. In XeLaTeX or LuaLaTeX, you would want:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm,xparse}
\usepackage{fontspec}

\setmainfont{Latin Modern Roman} \newfontfamily\cmr{Latin Modern Roman}[Ligatures={Common, TeX}] \newfontfamily\pbk{TeX Gyre Bonum}[Scale=MatchLowercase, Ligatures={Common,TeX}]

\begin{document} \cmr \section{Irrational Numbers.}

    Let the set of rational numbers be defined by
\[\mathbb Q:=\left\{\frac{a}{b} \mid a\in \mathbb Z,  b\in \mathbb N, \gcd(a,b)=1\right\}\]

    \textbf{Claim. } The {\pbk square root} of 2 is irrational.

      \begin{proof}
             Assume for the sake of contradiction that \ldots
          \end{proof}

\end{document}

In either, you could add the command

\DeclareTextFontCommand\textbookman{\pbk}

\textbookman{square root}

Davislor
  • 44,045