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}
\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\textto write something upright. Thst is not what that macro does use\textrmor\mathrm. Why? The output from\textdepends on context, thus sometimes it is upright, other times italic or sans serif. Not what you want – daleif Jul 08 '23 at 18:07