I try to insert a subfigure in a template from my university. But I get follwing error message:

"TeX capacity exceeded, sorry [input stack size=5000].
\@nomath ...e \@font@warning {Command \noexpand #1
                                                  invalid in math mode}\fi 
l.133 \subfloat

The files are available on overleaf: https://www.overleaf.com/read/xzrpbzzfytjx

Test2.tex works fine - this is just a copied example from the internet. But if I insert the same coding in the template (Test1.tex) I get the error message. I assume that some entry in the template causes the error?

Example Code (this includes twbook.cls is available via the overleaf-link):



\includegraphics[width=0.2\linewidth] {Unbenannt.png} \label{subfig:p1a0s}
\caption{Dummy figure}%

  • Welcome to TeX.SE! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. The easier it is to copy and test your code, the more likely your question will be answered and can help others with a similar situation. – thymaro May 13 '18 at 12:09
  • The problem with external links is that they can become broken or the content might move to another place on the external site or it might change over time, obliterating what was asked. So, please download the code to your machine, run it, delete superfluous code that does not add anything to the problem at hand and then post your fresh MWE here. This will augment the probability of getting an answer. – thymaro May 13 '18 at 12:11
  • I added the minimal code. As mentioned this includes the file twbook.cls - this includes a lot of coding. – chrisiwu May 13 '18 at 12:19
  • It's still possible to comment out piece by piece of the class, to try to figure out exactly where the problem comes from. Seems that \documentclass{scrbook} \usepackage{hyperref} \usepackage[demo]{graphicx} \renewcommand*{\thefigure}{\protect\small\arabic{figure}\protect\normalsize} \usepackage{subfig} \begin{document} \begin{figure*} \subfloat[]{\includegraphics[width=0.2\linewidth] {Unbenannt.png} } \end{figure*} \end{document} is enough to reproduce the issue, for example. – Torbjørn T. May 13 '18 at 12:31
  • 1
    The redefinition of \thefigure is very wrong. – egreg May 13 '18 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.