When I need to use something repeatedly within a document, I make my own command. E.g.:
\newcommand{\notification}[2]{ % line 2
Hello #1, your #2 pie is ready. % line 3
} % line 4
Then I can use it in the document like so:
\notification{Mr. White}{pumpkin} % line 6
However, if I make some mistake while coding the newcommand
, it does not say "l.3"; it will say "l.6". See in the example below (I have added an extra "&"):
\documentclass{article}
\newcommand{\notification}[2]{
Hello #1, your #2 & pie is ready.
}
\begin{document}
\notification{Mr. White}{pumpkin}
\end{document}
The error message is as follows:
! Misplaced alignment tab character &.
\notification #1#2-> Hello #1, your #2 &
pie is ready.
l.6 \notification{Mr. White}{pumpkin}
In this case, it is simple to diagnose, because I can quickly recognize the line Hello #1, your #2 pie is ready.
and find it with a search; however, in more complex documents, Hello #1, your #2 pie is ready.
might appear dozens of times, so I don't know where to look; or the reported error displays other code (which I will assume is underlying TeX code) not actually included within any of the code I wrote, so the messages seem of little help.
What are some general steps one can take to aid in the identification of the source of errors of this type?
\foo #1…#9->
is always the expansion of a macro, so you have to look not only at the line number given byl.<nr>
, but also at the definition of the macro. But if you are searching for a something like symbolic TeX debugger: You are not the only one, but there isn't such a tool.