# Reducing the console output of LaTeX

When I run pdfLaTeX, I get very verbose output:

(/usr/local/texlive/2008/texmf-dist/tex/generic/pgf/frontendlayer/tikz/librarie
s/tikzlibrarycalc.code.tex)
...


Is there a script to soak up all the verbose output and allow the important stuff to pass through, like errors, overfull hboxes, and so on?

Also, is there a reason why it sends a hard return to the console for lines longer than 79 characters?

-
This is not a pdfLaTeX thing: the file comments are TeX itself, and so you get them with all of the engines. –  Joseph Wright Aug 6 '10 at 5:44
Thank you, I have updated the tag. –  Neil G Aug 6 '10 at 7:28
@JosephWright: I don't think the (presumably renamed) {latex-project} was appropriate, but I don't know which tex tag belongs here. Could you please add it (and get rid of then-obsolete comments)? –  doncherry Mar 30 '12 at 1:15

Rubber has (among other things) some filtering capabilities, and generally gives errors in a very compressed form. You can also tell it to give you only certain kinds of warnings using --warn=.

-
I haven't installed this yet, but I'll mark this as correct after I try it out. –  Neil G Aug 6 '10 at 2:43
Please fix the link: rubber.sf.net –  Jukka Suomela Aug 6 '10 at 7:51
@Jukka: Fixed it. –  ShreevatsaR Aug 6 '10 at 8:30
Works great. I had to manually install it because macports wanted to install a full tex install as a dependency. –  Neil G Aug 6 '10 at 19:39
@Neil: MacPorts pulled this one on me last year when it decided that MacTeX 2009 was not good enough and I really needed 1 GB of TeX Live 2007 installed on my system. Its existence was subsequently terminated with extreme prejudice. Checkout homebrew if you are interested in a package manager that strives to avoid these shenanigans. –  Sharpie Aug 10 '10 at 18:37
show 1 more comment

The line feed after 79 characters is defined in Web2C's configuration file, called texmf.cnf. The variable name is max_print_line which you can change in the file (not recommended in general, but in that case the setting is really harmless); and if you run TeX from a shell you can also set this variable in the environment (export max_print_line=1048576 for Korn-like shells, set max_print_line 1048576 for C shells).

I am not aware of a way to forbid line breaks entirely; I only set the variable to a very large value when this behaviour annoys me.

-
Thank you. That worked. –  Neil G Aug 5 '10 at 23:42

This is what the silence package is intended to help with.

-
This is great, thank you. Do you know how to get rid of this stuff, though? (/usr/local/texlive/2008/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/local/texlive/2008/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/local/texlive/2008/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/local/texlive/2008/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/local/texlive/2008/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/local/texlive/2008/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) –  Neil G Aug 5 '10 at 23:48
That's TeX: it tells you what files its using. I've never seen a way to turn it off. –  Joseph Wright Aug 6 '10 at 5:45
+1, could you add a little more information to this answer? E.g. an example of filtered output (if that makes any sense) or just quote the short CTAN package description. –  doncherry Mar 30 '12 at 11:33

I have used rubber-info and it is the best TeX error parser I have seen. The package is not actively maintained though. I have it report error through growl as in this screenshot:

-
Great. Do I have to install rubber to get this to work, or can I just \usepackage something? –  Neil G Aug 6 '10 at 7:27
Rubber is a Python script, not a Latex package. You install rubber and simply run "rubber -Wall foo.tex" instead of something like "pdflatex foo; bibtex foo; pdflatex foo". –  Jukka Suomela Aug 6 '10 at 7:53
rubber is similar to latexmk. but you can use rubber-info to parse the log and continue using any compilation process you are using already. –  Leo Liu Aug 6 '10 at 8:08
Great. I will check it out. I tried installing with macports, which lists Tex as a dependency, so I was avoiding the huge install: [~] port deps rubber: Library Dependencies: python26 Runtime Dependencies: texlive –  Neil G Aug 6 '10 at 8:09
I ignore macports entirely. –  Leo Liu Aug 6 '10 at 8:24

The solution is

1. Either use the -interaction batchmode switch or put \batchmode at the start of the document(or anywhere you want to stop displaying output).

2. Use \scrollmode, \nonstopmode, or \errorstopmode anywhere you want to enable output generation. \errorstopmode enables errors interaction.

3. Use \batchmode anywhere you want to disable output generation.

• To reduce clutter use the command line switch, and use the following template.

>

     \begin{document}
\scrollmode
....
\batchmode
\end{document}


This will only show output from latex between the the \scrollmode and \batchmode and very little else.

If you are using WinEdt(or possibly some other automated process) it seems to like to open 0 length pdf's for no reason. It also doesn't seem to have an easy way to check for 0 length files.

• Add the follow to the ExecCompiler.edt file in the \Exec directory right after the string "// Check if the Output was Generated ...". (It is near the bottom)

ExecCompiler.edt

Run('DeleteFileIfEmpty.exe "%P\%N.pdf"','%P',0,0,'%N.pdf',0,0,1);
IfFileExists("%P\%N.pdf", "Relax;", !"JMP('Exit');");

• Here is C code of for a simple tool that deletes a file if it is empty.

DeleteFileIfEmpty.cpp

#include <tchar.h>
#include <Windows.h>

long GetFileSize(const TCHAR *fileName)
{
WIN32_FILE_ATTRIBUTE_DATA fileInfo;
if (NULL == fileName) return -1;
if (!GetFileAttributesEx(fileName, GetFileExInfoStandard, (void*)&fileInfo)) return -1;
return (long)fileInfo.nFileSizeLow;
}

int _tmain(int argc, _TCHAR* argv[])
{
argv = CommandLineToArgvW(GetCommandLine(), &argc); if (argc < 2) return -1;

_TCHAR *fn = new _TCHAR[1000]; ZeroMemory(fn, 1000*sizeof(_TCHAR)); _TCHAR *fn2 = fn;
for(int i = 1; i < argc; i++) { _tcscpy(fn2, argv[i]); fn2 += _tcslen(argv[i]); _tcscpy(fn2++, _T(" ")); } fn2--;
if (GetFileSize(fn) > 0) return -1;

DeleteFile(fn);
return 1;
}


http://www.freefilehosting.net/deletefileifempty

Put the DeleteFileIfEmpty.exe in a path that is in the %path% environment or the bin dir that WinEdt is setup to use.

This was tested with WinEdt6 and works. Reduces output clutter(no package loading msgs, banners, etc...) and doesn't open up empty files when there is an error.

-

In order to neatly format the output, I created my own solution: pydflatex. You would compile a file with

pydflatex myfile.tex


And get an output along the lines of

On top of giving a neat, condensed output, it will also hide the auxilliary files, so as not to clutter your folder.

Edit It is now also possible to run

pydflatex -l file.tex


which will parse an existing log without typesetting.

-
This looks pretty nice Olivier! However, I personally would prefer a more UNIX-like "one tool, one task" philosophy. So is it possible to get the output formatting only (without all that wrapper and cons stuff). That is, get a similar output by pdflatex file | pyformat or cat file.log | pyformat? –  Daniel Mar 15 '12 at 7:54
I'm not sure I understand... what you describe is what pydflatex does, just typeset a document with pydflatex doc.tex instead of pdflatex doc.tex | pyformat. You will get a similar result. So pydflatex does only the formatting. (Independently from pydflatex, I advocate using scons to ensure that pdfLaTeX will be run sufficiently many times, the bibliography will be built, etc.) –  Olivier Mar 15 '12 at 9:57
I do not want to use another tool for the typesetting, just for the output formatting, so I can easily plug it in existing generation processes (based on makefiles, different tex engines, ...). So in fact my process is some-tool-that-produces-pdflatex-like-log-output | pyformat. Furthermore, it would be great to filter already generate log files through it, that is, be able to do a cat file.log | pyformat. Generally speaking, this is about separation of concerns: Engine invocation is a concern that could (and should) be separated from output formatting, so both can be used independently. –  Daniel Mar 15 '12 at 10:20
Ah, that makes sense. I will try to make that available with pydflatex (should be easy, because it is already what happens inside pydflatex, first execution, then log parsing). Good point. –  Olivier Mar 15 '12 at 14:31
@Daniel I implemented (parts of) your suggestion in the new version of pydflatex. –  Olivier Aug 24 at 13:42