0

I am trying to scale up a greek letter inside a math formula. To do this, i follow this answer and use \scaleobj from the package scalerel

However, when I try to use an expression that includes my upscaled symbol in a section heading and use \tableofcontents, errors occur.

What is the reason for the errors? How can I use my little formula in a section heading without breaking my table of contents?

Here is a mimium error producing example:

% minimum working example to demonstrate a problem with math mode and scalebox not working together with headers and table of contents
% this is the base class of my document
\documentclass{scrbook}
% minimum number of imports
\usepackage{scalerel}
\usepackage{amsmath}

% define upscaled \pi \newcommand{\PI}{\scaleobj{1.5}{\pi}} % use this symbol inside math mode \newcommand{\mypi}{(\PI_\text{mypi})}

\begin{document}

\tableofcontents

\chapter{Main Chapter}

Some text about \mypi.

% comment out the following line to get a minimum working example \section{What's the matter with \mypi?}

Some more text.

\end{document}

  • 3
    your definition is not robust, and such commands can break when wandering through files to another location (the toc in your case). Either protect when using it: \protect\mypi, or define it in a robust way e.g. with \NewDocumentCommand{\mypi}{}{\(\PI_\text{mypi}\)} – Ulrike Fischer Jul 08 '23 at 13:01
  • Thank you very much! This solves my problem :) – pusteblume Jul 08 '23 at 14:58
  • Unrelated please don't use \text to write something upright. Thst is not what that macro does use \textrm or \mathrm. Why? The output from \text depends on context, thus sometimes it is upright, other times italic or sans serif. Not what you want – daleif Jul 08 '23 at 18:07

0 Answers0