Dear Stackexchange users,
I want to write my thesis with lualatex and as I'm using lualatex I want to use to packages build around it. But I stumpled upon a strange effect: I wanted to redefine the partial-Operator to be upright. So I wrote a renewcommand-line. But if I try to compile the following document
\documentclass{article}
\usepackage{fontspec}
\usepackage{unicode-math}
\AtBeginDocument{\setmathfont{Latin Modern Math}}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\AtBeginDocument{\renewcommand{\partial}{\symup{\partial}}}
\begin{document}
$\partial \symup{\partial}$
\end{document}
I get the following eror
! TeX capacity exceeded, sorry [input stack size=5000].
and there is no output pdf produced. Has anyone any idea why this happens?
Regards Jakob
PS: The \AtBeginDocument has to be infront of the renewcommand as otherwise the renewcommand does not have any effect. The explanation for this behaviour is (see explanation:
unicode-math waits until \begin{document} to setup the default font and the default definitions.

\AtBeginDocument{\let\oldpartial\partial\renewcommand{\partial}{\symup{\oldpartial}}}– moewe May 14 '18 at 15:56\renewcommand{\partial}{...\partial ...}is defining an infinite loop. – David Carlisle May 14 '18 at 15:59\let\old...trick, because otherwise TeX ends up in an infinite loop.\renewcommand{\partial}{\symup{\partial}}tells TeX to replace every occurrence of\partialwith\symup{\partial}. But then there is a new\partialand so that is replaced with\symup{\partial}, etc, etc. See also https://tex.stackexchange.com/q/47351/35864 – moewe May 14 '18 at 15:59