Is there a script or arara rule that does log file scraping for messages about bad boxes, warnings, and obvious rerun messages and outputs this to stdout? It doesn't need to be perfect. I am looking to replace what Kile does at the end of "build" operations since I am using the arara clean rule to delete the log file which prevents Kile from scraping it.

  • 1
    I have an idea, I'll try to write an answer tomorrow. :) – Paulo Cereda Sep 6 '13 at 0:16
  • @PauloCereda is it tomorrow yet? – StrongBad Sep 12 '13 at 11:50
  • I was travelling these days, I'm writing an answer right now. :) – Paulo Cereda Sep 12 '13 at 12:02
  • 1
    @DanielE.Shub In Brazilian Portuguese, tomorrow means "the next week". ;-) – egreg Sep 12 '13 at 12:52
  • @egreg: Hey, I'll write a proper defense... "tomorrow". :) – Paulo Cereda Sep 12 '13 at 12:56

As always, egreg has a great alternative solution for my crazy idea (kept at the bottom of this update, for historical reasons). :)

There's a tool named texloganalyser Rule Britannia! (gotta love the spelling!) which might help us. It's shipped in TeX Live, so a quick texdoc texloganalyser (which redirects us to a perldoc texloganalyser) gives us all the flags we need:

-e: displays the end of the log, about the TeX's memory.
-f: outputs the LaTeX Font Infos warnings and calculations.
-h: outputs only warnings about horizontal boxes.
-i: displays 'images' (pdf, [e]ps, png, jpg) used.
-o: outputs only warnings about overfull boxes.
-p: outputs the LaTeX Packages infos and warnings.
-r: displays warnings about references (missing or
-s: displays .sty and .cls files used.
-t: displays .tex files used. This option is very useful when you parse
logs of master files, to know in which file to look to correct
-u: outputs only warnings about underfull boxes.
-v: outputs only warnings about vertical boxes.
-w: displays all TeX, LaTeX and font Warnings.

So it's actually a matter of wrapping texloganalyser as an arara rule!

identifier: texloganalyser
name: TeX Log Analyser
- <arara> texloganalyser @{ overfull } @{ underfull } "@{ getBasename(file) }.log"
- identifier: overfull
  flag: <arara> @{ isTrue(parameters.overfull, "-o") }
- identifier: underfull
  flag: <arara> @{ isTrue(parameters.underfull, "-o") }

So we can have:

% arara: texloganalyser
% arara: texloganalyser: { overfull: yes }
% arara: texloganalyser: { underfull: yes }
% arara: texloganalyser: { overfull: yes, underfull: yes }

Again, untested. :)

I'm not sure if the following solution is actually good, but it's the only one I could think of. :) Sadly, arara per se has no built-in features for file scrapping, so I think we might need to do some dirty trick in the terminal.

This wacky idea of mine is based on using bash scripts in arara (cf. Is it possible to write an arara rule which uses a bash script?). Sadly we have a OS-specific trick, and I have no idea how to mimic such behaviour on Windows. Anyway.

I was thinking of a script like this one:

function lookuplog() {
    output=$(grep "$text" "$log")
    if [ $status -eq 0 ]
        echo "$output"
        echo "Nothing suspicious found."

I thought at first, "Hey, let's use grep directly", but since its exit code is tied with the number of occurrences found, we might have some problems! That's why I decided to tie grep inside of a script which ensures the exit code is always zero and it won't interfere in arara's workflow.

The script we just wrote checks occurrences of certain keywords in the .log file. For example,

I like ducks!\bye

If we run lookuplog on the generated .log file looking for underfull boxes, this is our output:

paulo@alexandria ~$ lookuplog ducks.log "Underfull"
Nothing suspicious found.

Now, let's check this file, courtesy of David Carlisle:

\hbox to 3in{a}\bye

If we run our script, things are quite different:

paulo@alexandria ~$ lookuplog mallard.log "Underfull"
Underfull \hbox (badness 10000) detected at line 1

Yay! Wait a minute, we had an underfull box. :)

Now, it's just a matter of wrapping this script inside an arara rule. :)

identifier: lookup
name: LookUp
- <arara> bash -i -c lookuplog "@{ getBasename(file) }.log" "Underfull"
- <arara> bash -i -c lookuplog "@{ getBasename(file) }.log" "Overfull"
arguments: []

Of course, we need to go on verbose mode in order to see what's going on. :)

If bad boxes are unacceptable, we could change the script to actually return a non-zero value if they are found - that way, arara will stop at a mere sign of a bad box. :)

You could wrap all these commands in a single rule, or even create additional rules for overfull or underfull boxes. In fact, note that the lookuplog file is just grep under the hood, so you can search everything. :)

There we go, totally untested, so I'm hoping for the best. :)

| improve this answer | |
  • I am very impressed but wouldn't it probably be easier to have a peek in the .log file with an editor? – Yiannis Lazarides Sep 12 '13 at 12:44
  • @Yiannis: Agreed. :) But we do love to complicate things, don't we? :) – Paulo Cereda Sep 12 '13 at 12:51
  • @YiannisLazarides I disagree. It is much easier for the computer search the log file for a particular term than it is to read the log file (especially if someone has already written the rule). – StrongBad Sep 12 '13 at 13:02
  • It was really texloganalyser that I was looking for, but your arara rule is a lot cleaner than mine would have been. – StrongBad Sep 12 '13 at 13:06
  • +1 awesome Paulo! will this be part of the next arara release? :) – cmhughes Sep 13 '13 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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