## LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

 Options: Use Classic View Use Monospaced Font Show Text Part by Default Show All Mail Headers Topic: [<< First] [< Prev] [Next >] [Last >>]

 Re: LaTeX Error: which file? Michael John Downes <[log in to unmask]> Wed, 7 Aug 2002 09:35:50 -0400 text/plain (92 lines) Julius Smith <[log in to unmask]> writes: > When LaTeX encounters an error, we see something like the following: > > ! LaTeX Error: \begin{itemize} on input line 21 ended by \end{document}. > > However, I typically have many "\input" statements, so it is often annoying > to figure out which file contains the offending line. (In an emacs shell, > I routinely type "\C-u\C-r([a-z]" to get back to the last opened file, but > this is only right some of the time.) It seems it should not be hard to > improve the error message to say instead > > ! LaTeX Error: \begin{itemize} on input line 21 in foo.tex ended by > \end{document}. You are right of course that it is a good idea. I think it was already implemented in one of the early LaTeX 3 prototypes. But you don't have to wait until LaTeX 3 to get that functionality. There is a package "fink" on CTAN that tracks input file names (provided that you use \include{filename} or \InputIfFileExists{filename}{}). And with that, you "merely" need to redefine \begin and \@badend as shown below. You might want to suggest to the author of the fink package that he add this feature as an option. Failing that, write your own package that loads the fink package and adds the rest. ------------------------------------------------------------------------ %&elatex \begin{filecontents}{finktest1.tex} What if we have a missing end-itemize? \begin{itemize} \item First item \item Second item % end-itemize should have been here Some more text after. \end{filecontents} \begin{filecontents}{finktest2.tex} Just another file. \end{filecontents} \documentclass{article} \usepackage{fink} \makeatletter \newcommand{\iife}[1]{%   \InputIfFileExists{#1}{%     \typeout{>> Entering "#1"}%   }% } \def\begin#1{%   \@ifundefined{#1}{%     \def\reserved@a{%       \@latex@error{Environment #1 undefined}\@eha}%   }{%     \def\reserved@a{%       \def\@currenvir{#1}\edef\@currenvline{\on@line}%       \edef\@beginfile{\finkfile}%       \csname#1\endcsname     }%   }%   \@ignorefalse \begingroup \@endpefalse   \reserved@a } \def\@badend#1{%   \@latex@error{%     \protect\begin{\@currenvir}\@currenvline\MessageBreak     in file "\@beginfile"\MessageBreak     ended by \protect\end{#1}%   }%   \@eha } \@ifundefined{everyeof}{}{% e-TeX only   \everyeof{\typeout{>> Exiting "\finkfile"}}% } \makeatother \begin{document} La de dah. \iife{finktest1.tex} \iife{finktest2.tex} More text after. \end{document}