# TeX capacity exceeded, sorry , due to \def command

I'm planning a very flexible python program computing the steady states of a system of differential equations.

I want to print the output of this program into a .tex file as you can see in the following example.


\documentclass[11pt,onehalfspacing,numbers=noenddot,openany]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[utf8]{inputenc}
\usepackage{oldgerm}
\usepackage{amsmath,amsthm,amssymb,eurosym,amsfonts}
\numberwithin{equation}{section}
\usepackage[ngerman]{babel}
\usepackage{xspace}
\usepackage[margin=2cm]{geometry}
\usepackage{graphicx}
\usepackage{pdfpages}
\begin{document}
\def\P{\mathrm{\P}}
\def\I{\mathrm{\I}}
\def\D{\mathrm{\D}}
\def\t{\mathrm{\t}}
\def\cp{\mathrm{c}_\mathrm{p}}

\chapter{Model 1}
\begin{aligned} \P = \cp \I \end{aligned}
\end{document}


The example results in the following error message

! TeX capacity exceeded, sorry [grouping levels=255].<recently read>    \math@bgroup \P


Well the program apologizes at least :-)


Do you know a nice work around solution for this problem?

Alex

• welcome to tex.sx. using \def has nothing to do with the problem. loops can be created just as easily by careless inclusion of the command name that's being defined being used in the expansion of the definition. – barbara beeton Nov 11 '16 at 14:23
• It is almost impossible to exceed TeX capacity. If you do, you normally have a recursion without break. Which in fact you do. Please clarify what your defs should do. – MaestroGlanz Nov 11 '16 at 15:11
• You probably want \DeclareMathOperator{\P}{P} and the same for the other letters. And don't use \def. – egreg Nov 11 '16 at 15:40

Your \P, defined \def\P{\mathrm{\P}}, calls an infinite loop.
You probably want \def\P{\mathrm{P}}. Similarly, \I, \D, \t.
• not only \I, but all the one-letter commands are loopy. only the definition of \cp is correct. (looks like a case of uncleaned cut-and-paste.) – barbara beeton Nov 11 '16 at 14:21