Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm processing a large document, using Latexmk in a Bash environment. It would be very helpful if error and warning messages were somehow highlighted or coloured, in order to facilitate spotting them. Specially when dealing with Biber and Biblatex, catching the warnings on time is important, as they won't normally stop the compilation process when something comes out.

Until recently, I was using the LateX bundle in TextMate, which helped showing only the most important messages (errors, warnings, inputs, includes, etc.) See here:

TextMate compiling

But I became deceptioned by that bundle and now I am compiling everything directly in the shell (Bash in Linux or Os X), as it gives me better control.

(Of course I could open the .log file, and configure the editor to search for/highlight these items, but I was thinking of "in the fly" highlighting/colouring.)

Is it possible to colour-code the stdout of latexmk (or in general of the *Tex bins)?

share|improve this question
    
I use a few different scripts to help with my compiling; the answer I gave here focuses on a vim implementation, but it can easily port to other editors –  cmhughes Nov 26 '12 at 1:03

2 Answers 2

up vote 7 down vote accepted

You can always pipe the output through something that does colour, one simple example produces

enter image description here

From running the command

  pdflatex tb67 2>&1 | grep --color=auto  "LaTeX Warning"

on a file with a ref{jjj} undefined reference which I inserted for demonstration purposes.

share|improve this answer
    
And is there another way of bashing the output so as to show all messages in the default colour, plus the errors/warnings in red only? The grep function is great, but is filters everything else out. –  NVaughan Nov 27 '12 at 15:17
    
add -C1000 to get up to a 1000 lines of context (ie non-matching lines) around the coloured lines –  David Carlisle Nov 27 '12 at 15:36
    
Unfortunatedly it doesn't work well with latexmk. I don't know why, but I have to press return for each pass to proceed. –  NVaughan Nov 27 '12 at 17:07
    
Is it picking up the exit status from grep rather then pdftex grep --help says Exit status is 0 if any line is selected, 1 otherwise; sorry never used latexmk (and i'm on cygwin not a real *x operating system so can't really test too well:-) –  David Carlisle Nov 27 '12 at 17:14
    
Nevermind. Thanks anyway! –  NVaughan Nov 27 '12 at 17:36

I use the following line in my make files:

pdflatex filename.tex 2>&1 | grep --color -E "Warning|Missing|$"

This should highlight "Warning"s and show all other lines as well, since "|$" part of pattern means "Or end of a line".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.