Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible to get some kind of "stacktrace" in TeX errors? I sometimes get errors which only show some deep LaTeX internals, but nothing about which LaTeX macro referenced it.

Thanks,

share|improve this question
add comment

1 Answer

up vote 19 down vote accepted

While "stacktracing" might not be possible since the state of macro expansion can be indeterminate (a priori and a posteriori). However, widening the context of your error reporting might provide some sense of where you are and what's going on. Try something like \setcounter{errorcontextlines}{999} for this. For myself, liberally sprinkling my code with lots of \typeout's or PackageWarning (et al.) lines provides most of what I need (write a routine that switches these on and off according to a global flag you set). Of course, many packages accept a debug or verbose option that dumps lots more state info to the .log file. Otherwise, the big gun is the trace package to give good control over \tracingall. The manual provided with it contains some worked examples and useful words of advice. Other words of wisdom can be found here (contains such pearls as: "The best advice to those faced with TeX errors is not to panic.").

share|improve this answer
2  
You can't use \setcounter here: you need to use the plain TeX \errrocontextlines 999\relax. –  Joseph Wright Nov 2 '10 at 15:09
7  
Actually you can use \setcounter: latex.ltx contains the line \let\c@errorcontextlines\errorcontextlines –  Ulrike Fischer Nov 2 '10 at 15:32
    
Now this I did not know: I always stick with the plain TeX approach to \errorcontextlines (as it's a primitive in any case) –  Joseph Wright Nov 2 '10 at 15:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.