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.

I'm trying to understand the pdflatex output and I found a big problem:

I have a warning at one location, for example the line is

\end{foo} test)test

pdflatex prints the warning message and after that the line information:

l.73 \end{foo}
                   test)test[1] [2] [3]) ("C:\Users\Nils\Documents\chapter2.tex"

I though the line after "l.73" is resevered for quotings from the tex file. But you can see that the name of the next file is printed, too.

If there is a rounded bracket in it, like in this example, the output can't be understood by a parser because there line should be checked for filenames but the first bracket will close the last file...

What can I do?

share|improve this question
1  
it prints the rest of the line test)test then the compiled pages [1][2] and [3] and then outputs the information about an included file. The ) after [3] is a closing parenthesis, the opening one is before your l.73 message. See logfile. –  Herbert Jan 9 '11 at 16:57
    
So I can check for e.g. "[1]" and only after that new filenames will begin. But what's about files without ouput? –  zee Jan 9 '11 at 17:25
    
What "parser" are you using? If you're doing your own parsing, have you tried calling pdflatex with the -file-line-error option? Then you'd get the filename at the beginning of the line, which might be easier to parse. –  frabjous Jan 9 '11 at 18:12
    
Yes, I wrote my own parser. I know that parameter but that doesn't help because I'm talking about warnings... –  zee Jan 9 '11 at 22:16

1 Answer 1

Your question is a little vague. Here only the test)test is printed on that line:

\documentclass{article}
\usepackage{lipsum}
\def\foo{}
\def\endfoo{\baz}
\begin{document}
\lipsum[1]
\begin{foo}
abc
\end{foo} test)test
\lipsum
\end{document}

So it really depends on what is causing that warning/error to be printed.

TeX's log output cannot be parsed unambiguously, but there are rules that it follows. When it opens a file, (file.tex is printed in the console; when that file is closed, a matching ) is printed. Pages written out are indicated by [1]...[2]...etc. Any heuristic you write to follow these rules must accept the fact that unmatched parentheses and brackets could appear in the output.

An alternative occurs to me. You can use the currfile and filehook package to print out unambiguous markers for file open/close and use this information instead. For example:

\RequirePackage{filehook,currfile}
\makeatletter
\def\fileindent{}
\def\pushindent{%
  \expandafter\def
  \expandafter\fileindent
  \expandafter{\fileindent\space\space}%
}
\def\popindent{%
  \edef\@tempa{%
    \noexpand\expandafter\def
    \noexpand\expandafter\noexpand\fileindent
    \noexpand\expandafter{%
      \noexpand\@gobbletwo\unexpanded\expandafter{\fileindent}%
    }%
  }%
  \@tempa
}
\makeatother
\AtBeginOfEveryFile{\typeout{\fileindent Begin file \currfilename}\pushindent}
\AtEndOfEveryFile{\popindent\typeout{\fileindent End file \currfilename}}
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum
\end{document}

Here, each nested file inclusion is indented in the console output (and this is the cause of the messy code up top). For your purposes this isn't necessary, but I find it easier for visual inspection.

share|improve this answer
    
I think thats not a possibility for my LaTeX IDE, because I can't just add commands to the file, that a user compiles... But thanks anyway. –  zee Jan 10 '11 at 2:36
2  
@zee You sort of can by executing pdflatex "\RequirePackage{ide-helper}\input{«filename»}" and as long as the ide-helper.sty package is available and doesn't conflict with anything else you shouldn't have any problems. –  Will Robertson Jan 10 '11 at 3:15
    
But the ide-helper needs a complete installation of miktex, too - that should not be required to use my IDE. I think detecting the pages of output in such a special line solves my problem for now... –  zee Jan 10 '11 at 22:25

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.