39

I am usually using latexmk in a split shell with my code on the left and latexmk in -pvc mode on the right.

When using some packages which themselves load a lot of other packages (think beamer) the log file contains tens or even hundreds of lines of messages from the packages being loaded (also spelling files, fonts, etc.).

I would like to prune the output to just the warnings, the errors, and latexmk’s own messages so these do not get lost.

Any ideas?

6
  • 9
    I think this is a very important question — something that bothers me every time I am using Latex. I am offering a bounty to draw more attention to this question, and in particular to see if anyone is aware of more recent developments regarding Latex log file filters. Commented Aug 20, 2012 at 7:40
  • @JukkaSuomela I thougt that this question has been answered by Neil tex.stackexchange.com/a/18088/4736 , see below. What's the obstacle to use the silcence package?
    – Keks Dose
    Commented Aug 20, 2012 at 11:33
  • 2
    @KeksDose: I do not see how I should use the silence package so that I automatically get just the relevant warnings and errors, and nothing else (cf. what rubber-info tries to do). If you have a fully working example how to set it up, please post an answer! Commented Aug 20, 2012 at 11:38
  • Also of interest is the logreq package. Commented Aug 20, 2012 at 21:51
  • 1

7 Answers 7

16
+100

You can use pplatex to filter errors, warnings and badboxes: http://www.stefant.org/web/projects/software/pplatex.html

(the compilation of http://dl.dropbox.com/u/12697903/pplatex/pplatex-1.0-rc1-src.tar.gz needs an additional #include in src/outputfilter.cpp)

If you then have ppdflatex in the path, you can create a ~/.latexmkrc file like the following to have a great workflow (with KDE, but it should be easily adaptable):

$pdf_mode = 1;
$pdflatex = 'ppdflatex -- -interaction=nonstopmode -shell-escape -synctex=1';
$pdf_previewer = "start okular";
$pdf_update_method = 0;
$recorder = 1;
$preview_continuous_mode = 1;
$sleep_time = 1;
4
  • 3
    pplatex does not seem to be actively maintained; the current version is from 2010. Commented Aug 20, 2012 at 7:59
  • 1
    The last release is some time ago. I am in contact with it's author from time to time fixing something. He planned to put the source code on github, to open up development. Commented Sep 1, 2012 at 19:00
  • 3
    Stefan Hepp has created the github project (github.com/stefanhepp/pplatex) and wants to keep improving the project. Commented Sep 5, 2012 at 18:05
  • pplatex can be installed via brew install homebrew/tex/pplatex (osx homebrew or linuxbrew). Unfortunately currently the formula does not work.
    – Hotschke
    Commented Aug 3, 2015 at 12:44
12

I just remembered that rubber has log filtering. It turns out there is a program in the rubber package called rubber-info which is solely for parsing the log file.

Because latexmk acts as tee (writing the to the logfile and printing to stdout and stderr, we can run rubber-info after latexmk is finished.

So I put this in a shell script:

#! /bin/bash

latexmk --pdf $1 > /dev/null 2>&1
rubber-info --check $1
rubber-info --boxes $1

and set makeprg in vim to

:set makeprg=latexmake\ %:h

And now I have only the errors and warnings (including overfull boxes).

2
  • 3
    Unfortunately, rubber's output parser is not really fool-proof: it may occasionally produce an empty output even if there were errors. This kind of two-step approach makes it even more risky — if latexmk fails, and rubber-info produces no output, you may easily miss major issues. A common scenario is that pdflatex runs OK, but bibtex then fails, yet rubber-info does not find any problems in the bibtex log file. Commented Aug 20, 2012 at 7:46
  • 1
    I can back the issues with rubber-info mentioned by Jukka. As a consequence I have stopped using it.
    – Daniel
    Commented Aug 20, 2012 at 8:06
6

Try the silence package, it can filter a variety of errors, warnings, and messages.

1
  • apparently no support for underfull or overfull messages
    – Hotschke
    Commented Aug 3, 2015 at 12:41
2

If you don't edit your preamble very often, you can also precompile it, it will also make you gain time with each compilation.

You can find details in this page, but essentially, you have to

  • separate the fixed preamble from the document, paste it into a file named preamble.tex
  • run latex -ini -job-name="main" "&latex preamble.tex\dump" or if you prefer pdflatex run pdflatex -ini -job-name="main" "&latex preamble.tex\dump"

  • add %&main.fmt at the beginning of your file and remove \input{preamble}

  • add -parse-first-line to latex/pdflatex's flags.

I believe you can add a latexmk rule to recompile the preamble if you edit it, also.

1
  • 2
    Precompiling the preamble is essentially broken for LuaLaTeX with fontspec. Commented Aug 20, 2012 at 21:44
2

You need to write a small script which filters the log file. Either a Perl, Python or similar scripting language of you choice or a longer egrep line (if you under a *nix system) should do it.

Before I knew latexmk I wrote my own minimalistic version of it (actually of texify) which does such filtering. Here the filter code on its own as an example. It is a Perl script which still needs adjustments to include latexmk's own messages.

#!/usr/bin/env perl
use strict;
use warnings;
my $nobox = 0; # Should box warning be excluded
my $nextlines = 0;
while (<>) {
    if ($nextlines > 0) { $nextlines--; print STDERR $_; }
    elsif (/^(!\s+)?LaTeX (?:Warning|Error)/i) { print STDERR $_; }
    elsif (/^! Undefined control sequence\./i) { chomp; print STDERR $_, ": "; $nextlines = 1; }
    elsif (/^! Use of .* doesn't match its definition\./i) { print STDERR $_; $nextlines = 3; }
    elsif (/^!/i) { print STDERR $_; }
    elsif (!$nobox && /(overfull|underfull|badbox)/i) { print STDERR $_; }
}
2
  • 2
    Otherwise write to the latexmk author, he is usually very open for suggestions
    – daleif
    Commented Mar 10, 2011 at 11:45
  • @John Collins, the latexmk author, also is pretty active here on tex.se. So we probably will here from him soon :-)
    – Daniel
    Commented Aug 20, 2012 at 8:12
2

I asked a similar question a while back (but much after this question was originally asked) about filtering the log file with arara: Arara rule for log file scraping. While the details of the answer are arara specific, the underlying program used is texloganalyser. It should be possible to work that into whatever build system you are using.

1
  • I just wanted to mention that texloganalyzer does not show errors, only warnings. I was running texloganalyzer with latexmk's $success_cmd and $failure_cmd. However, not showing errors for me is a dealbreaker, that's the main reason I'd like a parser. Commented Jan 15, 2020 at 20:26
0

Though it would miss TeX warnings, showing only LaTeX ones, you could patch LaTeX's error and warning commands to write the warnings and errors additionally to another separate log file. This log file would then only contain errors and warnings. Latexmk could then cat this file at the end of the run.

I would be willing to have a go at this if anyone thinks it useful, but at the moment I think the missing of TeX's messages would be a deal-breaker. Perhaps if using LuaTeX, one can hook into TeX's messages too?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .