1

I would like to use \mathsmaller in a section title but it is incompatible with hyperref. Here is a MWE:

    \documentclass{book}
\usepackage{amsmath}    %automatically loads ansbsy which gives \boldsymbol
\usepackage{relsize}
\usepackage{hyperref}
\begin{document}

$\mathcal{SQUARING}^{+}$%compiles

$\mathsmaller{SQUARING^{+}}$%compiles

$\mathsmaller{\mathcal{SQUARING}^{+}}$%compiles

\section{$\mathcal{SQUARING}^{+}$ }%compiles

%\section{Function $\mathsmaller{SQUARING}^{+}$ }%does NOT compile with hyperref

%\section{Function $\mathsmaller{\mathcal{SQUARING}^{+}}$}%does NOT compiles with hyperref

\end{document}

schremmer
  • 2,107

1 Answers1

2
  • Have a look at the \texorpdfstring macro, to be used in sectioning headers. The second argument -- with the material that's to be written to the pdf bookmark -- should contain no TeX-type math code.
  • My personal opinion is that the result looks pretty ugly :).

\documentclass{article}
\usepackage{amsmath}
\usepackage{relsize}
\usepackage{hyperref}

\begin{document}

$\mathcal{SQUARING}^{+}$%compiles $\mathsmaller{SQUARING^{+}}$%compiles $\mathsmaller{\mathcal{SQUARING}^{+}}$%compiles

% note the use of \texorpdfstring in \section directives \section{% \texorpdfstring{$\mathcal{SQUARING}^{+}$}% Code for text {SQUARING+}% Code for PDF bookmark } \section{% \texorpdfstring{$\mathsmaller{SQUARING}^{+}$}% Code for text {SQUARING+}% Code for PDF bookmark }

\end{document}

enter image description here

enter image description here


Edit 2022-01-26

% 3rd Version
\section{%
    \texorpdfstring{$\mathsmaller{\mathcal{SQUARING}^{+}}$}% Code for text
                   {SQUARING+}% Code for PDF bookmark
}
% 4th Version
\section{%
    \texorpdfstring{$\mathsmaller{\mathtt{SQUARING}^{+}}$}% Code for text
                   {SQUARING+}% Code for PDF bookmark
}

enter image description here

  • 1
    +1. I've taken the liberty of adjusting the code that's used in the second argument of \texofpdfstring. – Mico Jan 23 '22 at 02:44
  • 1
    @Mico Thanks! :) – Dr. Manuel Kuehner Jan 23 '22 at 02:54
  • @Dr. Manuel Kuehner 1. I beg to disagree: mathcal is unbelievably ugly, regardless of size. Is there an alternative? 2. I am writing for people absolutely convinced that mathematical writing is absolutely consistent. So, since I said I would use mathcalfor proper names of functions, I have to, no matter where. 3. They would immediately spot that the font in your section 2 above is different and wonder what it's supposed to indicate. So, I appreciate your help but can't use it. 4. I have inserted the word Function in the section titles for it to look the way it does. – schremmer Jan 26 '22 at 22:22
  • @schremmer I do not understand what you mean. The second \section in the provided answer does not use \mathcal. – Dr. Manuel Kuehner Jan 26 '22 at 23:54
  • @Dr. Manuel Kuejner Sorry about that. I wanted to use some script font, say like Apple Chancery or Noteworthy, for proper names of functions because I want to support the impression that functions are entities the way numbers are entities. (My past in Category Theory showing up.) But donI have to use the same font everywhere, including section titles, for the reason I gave before. I was hoping for exactly the first Squaring+ in your answer but in a section title. – schremmer Jan 27 '22 at 02:44
  • @Dr. Manuel Kuejner Sorry about that. I wanted to use some script font, say like Apple Chancery or Noteworthy, for proper names of functions to support the idea that functions are entities the same way as numbers are entities. (My past in Category Theory showing up?) But I didn’t know how to do that so I used mathcal for lack of anything better. But then I ran into the section problem. What I would like of course is exactly your first Squaring+ in a section title. In other words, the size of your section 2 but with mathcal for lack of anything better. (I couldn't remember how to delete.) – schremmer Jan 27 '22 at 02:54
  • @schremmer I have added an edit (incl. \mathtt version). If that is what you want then it is very simple. – Dr. Manuel Kuehner Jan 27 '22 at 03:02
  • 1
    @Dr. Manuel Kuehner Of course, there is no changing the fact that mathcal is awful. But with section 3, you gave me what I think is the best I can hope for under the circumstances: at least, it is not overwhelming. As for mathtt, it’s nice but I think I need script to have something really “different”. So, thanks for all the work. – schremmer Jan 27 '22 at 04:15
  • 1
    @Dr. Manuel Kuehner [Squaring]{http://freemathtexts.org/Calculus/Schremmer_CARW/SmallMathCall.pdf} – schremmer Jan 27 '22 at 05:09