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?

7 Answers7

16

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;
  • 3
    pplatex does not seem to be actively maintained; the current version is from 2010. – Jukka Suomela Aug 20 '12 at 07: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. – Patrick Häcker Sep 01 '12 at 19:00
  • 3
    Stefan Hepp has created the github project (https://github.com/stefanhepp/pplatex) and wants to keep improving the project. – Patrick Häcker Sep 05 '12 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 Aug 03 '15 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).

  • 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. – Jukka Suomela Aug 20 '12 at 07:46
  • 1
    I can back the issues with rubber-info mentioned by Jukka. As a consequence I have stopped using it. – Daniel Aug 20 '12 at 08:06
6

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

Neil
  • 367
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 $_; }
}
doncherry
  • 54,637
Martin Scharrer
  • 262,582
  • 2
    Otherwise write to the latexmk author, he is usually very open for suggestions – daleif Mar 10 '11 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 Aug 20 '12 at 08: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.

StrongBad
  • 20,495
  • 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. – Pepe Mandioca Jan 15 '20 at 20:26
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.

Jonas Stein
  • 8,909
T. Verron
  • 13,552
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?