86

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?

doncherry
  • 54,637
Neil G
  • 17,947

14 Answers14

35

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.

Arthur Reutenauer
  • 2,920
  • 19
  • 17
  • 1
    (Note: this is the answer to (only) the "also" part of the question. For the answer to the main question, see other answers below.) – user202729 Nov 12 '21 at 07:45
  • This does not seem to work with lualatex – Nasser Apr 15 '22 at 16:22
  • Recent versions of bibtex now read the max_print_line environment variable and report 3 is a bad bad if it is >= 20000, the hard-coded initial value of BUF_SIZE. https://tug.org/svn/texlive/trunk/Build/source/texk/web2c/bibtex.ch?r1=63237&r2=63238& – Michael Hoffman Jan 04 '24 at 22:21
25

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;
}

You can download this file at

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.

Uiy
  • 6,132
  • 1
    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. – mahmood Jan 04 '14 at 12:01
  • At least MikTeX requires the commandline parameter to be -interaction=batchmode (no whitespace separator). – Twonky May 15 '17 at 10:23
  • 1
    but -interaction batchmode also do not show compile errors! which is not good. – Nasser Apr 15 '22 at 16:10
20

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

vanden
  • 30,891
  • 23
  • 67
  • 87
Martin Heller
  • 11,391
  • 7
    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 05 '10 at 23:48
  • 2
    That's TeX: it tells you what files its using. I've never seen a way to turn it off. – Joseph Wright Aug 06 '10 at 05:45
  • 5
    +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
  • @martin-heller Hi, I'm new to LaTeX, could be please an example for how to use it ? – SebMa Jun 19 '18 at 09:49
  • 3
    @SebMa please see the documentation: http://texdoc.net/pkg/silence . Simply call \WarningsOff[package] after loading the silence package to eliminate warnings from package. – Martin Heller Jun 19 '18 at 19:31
20

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=.

Neil Olver
  • 4,942
  • I haven't installed this yet, but I'll mark this as correct after I try it out. – Neil G Aug 06 '10 at 02:43
  • Please fix the link: http://rubber.sf.net/ – Jukka Suomela Aug 06 '10 at 07:51
  • @Jukka: Fixed it. – ShreevatsaR Aug 06 '10 at 08:30
  • Works great. I had to manually install it because macports wanted to install a full tex install as a dependency. – Neil G Aug 06 '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
  • 1
    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 03 '12 at 09:06
  • Wow, Rubber is absolutely perfect! I also noticed it wasn't updated for a while, but who cares if everything works :). And it has support for absolutely every configuration I want to do! – Janko Apr 02 '14 at 21:55
  • 1
    I'd recommend using latexmk being also part of MikTex and Texlive. – Hotschke May 15 '14 at 08:59
  • @jmc: people are still coming to this question. It would be good to accept latexmk as the modern answer. Would you mind adding it? Maybe link here: http://www.ctan.org/pkg/latexmk/ – Neil G Aug 26 '14 at 08:16
  • 1
    @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'm not sure why people call rubber outdated. The latest release is 2015-12 as I write this, which is fairly recent. – Clément Aug 06 '16 at 20:08
11

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

pydflatex run

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.

Olivier
  • 3,151
  • 1
    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 07: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 09: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
  • 2
    @Daniel I implemented (parts of) your suggestion in the new version of pydflatex. – Olivier Aug 24 '13 at 13:42
  • ah, the new -l switch? Looks good, I will give it a try next week. – Daniel Aug 25 '13 at 06:45
  • Olivier, I have tried it. Some remarks: I have a "standard" MacPorts python installation. (1) I had to install the argparse package, which probably should be listed in the dependencies. (2) It took me a while to figure that the package name for termstyle is actually python-termstyle, which should be mentioned for the uninspired. (3) On my first try I only got a UnicodeDecodeError: 'utf8' codec can't decode bytes in position 91944-91949: unsupported Unicode code range (in nice red color, though :-). The respective character was an ü. Missing UTF8 support is a show stopper, though. – Daniel Aug 29 '13 at 13:36
  • @Daniel, thanks for the feedback! argparse is part of standard Python distros > 2.7. UTF-8 is supported, but the log has to be in utf-8. If yours is, please send it to me (or, better, the tex file), or file an issue on github. Thanks again! – Olivier Aug 30 '13 at 17:58
  • I have investigated the issue: Even though the input file is UTF8 and my locale settings are as well, pdflatex seems to generate a LATIN1-encoded log file. I have raised a new question about this. – Daniel Sep 02 '13 at 15:42
  • Olivier, according to egreg's answer to my new question, it seems that there is a problem: The output format in the LaTeX log is in the respective font encoding (basically a stream of arbitrary bytes), so it is not valid to assume any specific encoding :-/ – Daniel Sep 03 '13 at 13:33
  • pydflatex now works even if the log is not encoded in utf-8. – Olivier Feb 24 '14 at 12:07
  • This is unmaintained, right? – Clément Jul 12 '21 at 04:22
10

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:

TeX error report through growl

diabonas
  • 25,784
Leo Liu
  • 5,445
  • Great. Do I have to install rubber to get this to work, or can I just \usepackage something? – Neil G Aug 06 '10 at 07: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 06 '10 at 07:53
  • 1
    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 06 '10 at 08: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 06 '10 at 08:09
  • 5
    I ignore macports entirely. – Leo Liu Aug 06 '10 at 08:24
  • @Leo: I didn't know the package, it looks great! I like Growl :-) – Arthur Reutenauer Aug 06 '10 at 13:10
  • @Arthur: thanks. I actually have emacs running as a server and the error is reported to emacs from another machine where a cron build script is watching over my git repo. Then emacs sends out the msg to growl. – Leo Liu Aug 19 '10 at 15:40
5

The modern solution is latexmk.

Neil G
  • 17,947
5

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
pulp a.log Configurable ? Configurable 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.


Looks like Pulp is not mentioned in the other answers. This is a quote from its README:

What is pulp?

Do you find LaTeX's output too voluminous? Do you wish it would get straight to the point and just tell you the errors and where they occurred? When you see this:

Underfull \hbox (badness 3679) in paragraph at lines 278--282
[]\OT1/cmr/m/n/12 Shin-Cheng Mu, Zhen-jiang Hu, and
 []

[278] Underfull \hbox (badness 10000) in paragraph at lines 318--323 []\OT1/cmr/m/n/12 Yingfei Xiong, []

) [279] (./paper.aux)

LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.

) ) (\end occurred when \iftrue on line 2 was incomplete) Here is how much of TeX's memory you used: 14398 strings out of 495035 257795 string characters out of 6181701 330613 words of memory out of 5000000 17235 multiletter control sequences out of 15000+600000 23715 words of font info for 95 fonts, out of 8000000 for 9000 14 hyphenation exceptions out of 8191 66i,21n,72p,680b,1562s stack positions out of 5000i,500n,10000p,200000b,80000s </usr/share/texlive/texmf- dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/share/texlive/texmf-dist/f onts/type1/public/amsfonts/cm/cmcsc10.pfb></usr/share/texlive/texmf-dist/fonts/ type1/public/amsfonts/cm/cmex10.pfb></usr/share/texlive/texmf-dist/fonts/type1/ public/amsfonts/cm/cmmi10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public /amsfonts/cm/cmmi12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfo nts/cm/cmmi6.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/ cmmi7.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi8.p fb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></us r/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr12.pfb></usr/share /texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr6.pfb></usr/share/texlive /texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb></usr/share/texlive/texmf-d ist/fonts/type1/public/amsfonts/cm/cmr8.pfb></usr/share/texlive/texmf-dist/font s/type1/public/amsfonts/cm/cmss10.pfb></usr/share/texlive/texmf-dist/fonts/type 1/public/amsfonts/cm/cmss12.pfb></usr/share/texlive/texmf-dist/fonts/type1/publ ic/amsfonts/cm/cmss8.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsf onts/cm/cmsy10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/c m/cmsy6.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy7 .pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy8.pfb></ usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmti10.pfb></usr/sh are/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmti12.pfb></usr/share/te xlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmti8.pfb></usr/share/texlive/t exmf-dist/fonts/type1/public/amsfonts/cm/cmtt12.pfb></usr/share/texlive/texmf-d ist/fonts/type1/public/amsfonts/symbols/msam10.pfb></usr/share/texlive/texmf-di st/fonts/type1/public/amsfonts/symbols/msbm10.pfb> Output written on paper.pdf (285 pages, 1369913 bytes). PDF statistics: 1660 PDF objects out of 1728 (max. 8388607) 1107 compressed objects within 12 object streams 0 named destinations out of 1000 (max. 500000) 224 words of extra memory for PDF output out of 10000 (max. 10000000)

...do your eyes automatically skip to the line about cross-references without conscious effort? Then you need pulp. Compare LaTeX's spew with what pulp has to say about that file:

./delta.tex:133-133: LaTeX warning: Float too large for page by 4.64713pt on input line 133.
./delta.tex:2649-2649: LaTeX warning: Float too large for page by 74.48848pt on input line 2649.
./delta.tex:3817-3817: LaTeX warning: Float too large for page by 99.13847pt on input line 3817.
./delta.tex:3923-3923: wrapfig warning: Collision between wrapping environments on input line 3923.
./delta.tex:3925-3925: wrapfig warning: Stationary wrapfigure forced to float on input line 3925.
./delta.tex:3951-3951: wrapfig warning: Collision between wrapping environments on input line 3951.
./delta.tex:3954-3954: wrapfig warning: Stationary wrapfigure forced to float on input line 3954.
./skeleton_dissertation.tex:36-?: LaTeX warning: Label(s) may have changed. Rerun to get cross-references right.
2-2: (\end occurred when \iftrue on line 2 was incomplete) 

Not only is the label warning more clearly highlighted, a number of other errors -- which were scrolled way the heck off the terminal ages ago if you were just using pdflatex -- are more clearly visible, together with information about which source file and line number caused the problem. (In fact, even messages which do not have a line number directly in them will have a "best guess" assigned to them by pulp to give you an idea of where in the file to start looking.)

user202729
  • 7,143
4

Having read the answers, I ended up with this lightweight solution:

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

user66081
  • 340
2

Consider also following tool:

Pretty Print LaTeX: pplatex

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

Based on the parser of kile.

Note about availability:
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.

Hotschke
  • 5,300
  • 5
  • 33
  • 63
2

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.

shevket
  • 147
  • 9
2

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.

Clément
  • 4,004
2

As mentioned in other answers, there are many tools that may help with this. I have recently uploaded texlogsieve to CTAN, which is my own attempt at a texlua script to filter the LaTeX log file. I like it :) . The main selling points are

  1. Lots of options to choose what to show/hide;
  2. Reliable line unwrapping;
  3. Multi-line messages are treated as a single entity.

Note that it does not treat error messages specially (they are just dumped to the output together with the other unfiltered messages). Still, calling texlogsieve -l unknown --no-page-delay --no-shipouts --no-summary LOGFILE should give you something very close to "only error messages".

Nelson Lago
  • 451
  • 3
  • 5
1

You can use ltx2any to compile your document. This will not only compile your document, but also produce a summary of errors and warnings:

enter image description here