Issue: My Latex files are pretty big already, but lately I added the scalerel package and since then get the error message

! Undefined control sequence.\calc@initB ->\calc@B\calc@A \addtocontents{toc}{\setcounter{tocdepth}{3}}

However the interesting thing is, once I remove the package I still run into errors, I need to reload my .tex file to make it work again.

I finally figured out that the package in combination with \addtocontents{toc}{\setcounter{tocdepth}{3}} causes the error.

Question: Is there any incompatibility of the package scalerel with certain settings or other packages known? Or is there any altnerative to get my subspricts that small?

MWE:

\documentclass[a4paper,
12pt,
bibliography=totoc,
index=totoc,
parskip=false
]{scrreprt}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[style=authoryear]{biblatex}

\usepackage{scalerel}           % scale math even smaller

\begin{document}
\addtocontents{toc}{\setcounter{tocdepth}{3}} % here comes the trouble

$\varphi_{\scaleto{sig}{3pt}}$

\nocite{Kister.2019, Blankertz.2019}
\printbibliography

\end{document}

• why do you want to set the tocdepth in the toc??? (\protect\setcounter probably works, but it seems a very strange construct) – David Carlisle Sep 7 '19 at 8:24
• there is no need to use scaling to get small subscripts you can use \DeclareMathSizes to declare the font sizes to use for subscripts at each main font size. – David Carlisle Sep 7 '19 at 8:30

This is a "fragile command in a moving argument" error, so the standard \protect command avoids the error
\addtocontents{toc}{\protect\setcounter{tocdepth}{3}} % here comes the trouble