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. Aug 6 '10 at 5:44
• @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)? Mar 30 '12 at 1:15
• Regarding the second part of the question: A separate question is available May 15 '14 at 11:36
• – user6853
Sep 1 '14 at 3:28
• @BenCrowell: duplicate? Sep 1 '14 at 6:13

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.

• (Note: this is the answer to (only) the "also" part of the question. For the answer to the main question, see other answers below.) Nov 12 '21 at 7:45

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.

• This is a great solution. You can put \batchmode whenever you want to get rid of messages and \scrollmode whenever you want to see the warnings and other staffs. Jan 4 '14 at 12:01
• At least MikTeX requires the commandline parameter to be -interaction=batchmode (no whitespace separator). May 15 '17 at 10:23

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)) 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. 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. Mar 30 '12 at 11:33
• @martin-heller Hi, I'm new to LaTeX, could be please an example for how to use it ? Jun 19 '18 at 9:49
• @SebMa please see the documentation: texdoc.net/pkg/silence . Simply call \WarningsOff[package] after loading the silence package to eliminate warnings from package. Jun 19 '18 at 19:31

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. Aug 6 '10 at 2:43
• Is it not true that rubber is fairly outdated? No release since 2006-03-17. I think mklatex is the way to go by now.
– jmc
Apr 3 '12 at 9:06
• I'd recommend using latexmk being also part of MikTex and Texlive. May 15 '14 at 8:59
• @NeilG — Feel free to do it yourself. (Currently I don't have the inspiration for a good review/recommendation of latexmk. But maybe later this week.) Also, I am in the process of studying arara (better late then never), and I have the feeling that it might deserve mention in an answer to this question. Currently I do not have the expertise yet to write a good answer.
– jmc
Aug 26 '14 at 11:48

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? 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". 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. 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 Aug 6 '10 at 8:09
• I ignore macports entirely. Aug 6 '10 at 8:24

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? 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.) 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. 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. Mar 15 '12 at 14:31
• @Daniel I implemented (parts of) your suggestion in the new version of pydflatex. Aug 24 '13 at 13:42

The modern solution is latexmk.

• Is there any intermediate between -silent and -verbose? Mar 28 '16 at 20:04
• @JoëlMeyer-Hamme I have no idea. Perhaps make another question? Mar 28 '16 at 20:04
• I'll keep looking. --interaction=batchmode looked promising but suppresses all warnings. Mar 28 '16 at 20:09
• @JoëlMeyer-Hamme You could use and maybe modify an output parser like pplatex listed as another answer here. Mar 28 '16 at 20:35
• errors - Use latexmk to filter the log file - TeX - LaTeX Stack Exchange ... but it doesn't have any solution that too late uses latexmk. Nov 13 '21 at 1:47

pdflatex -interaction=nonstopmode paper.tex 1> log || cat log

Consider also following tool:

Pretty Print LaTeX: pplatex

pplatex --cmd <yourlatexbinary> -q -- latexfile.tex


Based on the parser of kile.

Not part of MikTex or TexLive and not contained in Debian/Ubuntu repositories and there is also no Mac OSX homebrew formula. However, custom installation is not difficult. Update 2016: links on github to pre-compiled binaries for linux-x64 and windows are available.

Today I got very tired of pdflatex trashing my console at each run.

So after too many years of compliance I wrote this script for my .bashrc.

# Compile tex file containing svg
svgtex () {
pdflatex -shell-escape -halt-on-error -output-directory="out" \
$1 1> /dev/null [[$? = 0 ]] || echo grep Error out/${$1/tex/log}
}


I share it as OP asked for a script, and latexmk is not to be found on my distro. Defining a function in .bashrc works like an alias, except you can pass it arguments (e.g. filename=\$1)

I pass the following options:

• -shell-escape: required to include svg files, which my defense slides contain
• -halt-on-error: stop killing the terminal by hanging in batchmode or whatever
• -output-dir: stop trashing the source directory with .nav .toc .out .log .aux .snm files... am I forgetting any?

I just use it as svgtex file.tex and no output is produced.

N.B. Although only stdout is redirected to /dev/null, no error messages are printed in case of failure, so it seems pdflatex does not use stderr. Hence the last line to check the return code pdflatex and print only error lines.

You can always do less out/file.log if you want to know all about it.

On GNU/Linux I've found texfot to be the most reliable, and it comes packaged with TexLive. It filters the output of the command you pass it:

texfot pdflatex …options your-document.tex


See this answer for more details.

This is a comparison of the existing methods (plus a new suggestion by me below)

If you come across this question, you most likely want to quickly find the parts that you're interested in in the log file/output.

(the question itself only concern terminal output (stdout), but the errors/messages are in both the log file and terminal)

In my experience, the parts that you're possibly interested in are

• (most frequent) The errors raised by TeX.
• (less frequent, only if you do some TeX programming) Debug error messages printed by \show, \showtokens, \tl_show:n, \regex_show:n or similar.
• The warnings produced by TeX.
• Whether it can parse an existing file. (so you don't need to change your existing compilation command)

The table below compares the tools, with respect to the conditions above. The first line is my new suggestion.

The file in (7) is used.

Tool On error On \show (3) On warning Parse log file
texfot cat a.log Configurable Configurable Continue Yes
xelatex a.tex Prompt (4) Prompt Continue No
xelatex a.tex < /dev/null Stop Stop Continue No
latexmk [-g] a.tex Stop Stop Continue No
texfot xelatex a.tex Stop Stop Continue Partial (6)
xelatex a.tex < <(yes "") Continue Continue Continue No
latexmk [-g] -latexoption=-interaction=nonstopmode a.tex Continue Continue Continue No
texfot xelatex -interaction=nonstopmode a.tex Continue Continue Continue Partial
xelatex -interaction batchmode Hide and continue Hide and continue Hide No
latexmk -silent [-g] -latexoption=-interaction=nonstopmode a.tex Hide and continue Hide and continue Hide No
xelatex -interaction batchmode with manual \nonstopmode ... \batchmode Hide and continue (1) Configurable Hide No
rubber-info a.tex Configurable Hide Configurable Yes
pplatex -i a.log (5) Configurable Hide Configurable Yes
silence package ? ? ? No
pydflatex a.tex ? ? ? ?

(1): The user could wrap it manually, but it requires knowing where the error is in the first place.
(2): About texfot --interactive xelatex a.tex: The flag doesn't have any effect, see pdflatex bash script to supress all output except error messages?
(3): The "Stop" case can always be converted to "Continue". See How can I make TeX stop on the first error, but do not stop on \show (or \tl_show:n)? (disclaimer: my question)
(4): See How can one stop LaTeX compilation? for what to do with the prompt.
(5): May requires compilation from source if the provided binary does not work. Supports cmake.
(6): "Partial" means being able to run the compiler with any option, but requires re-run to filter.
(7): The example file:

\documentclass[12pt]{article}

\begin{document}

\ExplSyntaxOn
\def \a {123}
\show \a
\tl_show:N \a
\tl_analysis_show:n {123}
\ExplSyntaxOff

Some example formula x^2+1=0
\end{document}


Regardless of the method, because LaTeX log file is relatively unstructured, any solution that parses the log file is subject to error.