1

I would like to parse the latex log to extract warnings from the refcheck package. These warnings look like this

Package refcheck Warning: Unused label `eq:my_equation_label' on input line 2
28.

The linebreak always appears after a given number of characters, and here it happens to break the line number. I have been trying to set up a working errorformat for a couple of hours but this was to no avail. Any idea how I could extract the correct error message and line number?

  • 2
    I'm not an expert of errorFormat but I think if you shared what you have done so far, maybe it could be easier for other users to point out what doesn't work with your expression. – statox Mar 15 at 22:14
1

Afaik 'efm' of vim cannot handle this situation, i.e. %l matches only a sequence of digits with no spaces or linebreaks between the digits. Vim help discusses in more detail a possible value of'efm' for LaTeX but does not answer this question:

:help errorformat-LaTeX

Maybe you can ask this on the issue tracker of vim or the vim_dev mailing list to get an official confirmation of this and possibly add a note to the vim help section.

However, there are two ways to handle it anyway:

  1. Change the line length of the log output of pdflatex to a high value. For example, set makeprg in vim as following:

    :set makeprg=max_print_line=10000\ pdflatex\ %
    

    Also the plugin vimtex does this for the default compilation method with latexmk and would show you also the message by default.

  2. Post-process the log file with an external tool, e.g. rubber-info correctly parses the splitted line number. The principle idea is

    :set mp=pdflatex\ %\ \\\|&\ error_filter
    

    For LaTeX log files quite a few tools exist. Following two are pre-installed under TeXLive 2018

    However, both struggle with the linebreak in the line number and report the wrong line number.

    I have tried following further tools

    • pplatex gets the line number correct but does not capture the full message. The warning

      Package refcheck Warning: Unused label `eq:your_equation_label' on input line 1
      7.
      

      is converted by pplatex to:

      ** Warning in ./demo-multine-efm.tex:
         (Package refcheck) your_equation_label' on input line 17.
      
    • rubber-info was successful

      WARNING:rubber.cmdline:demo-multine-efm.tex:17: [refcheck] Unused label `eq:your_equation_label'. (page 1)
      

    Other tools are


Demo file

\documentclass{article}
\usepackage{refcheck}

\begin{document}

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,
no sea takimata sanctus est Lorem ipsum dolor sit amet.

\begin{equation}
   a=b\label{eq:your_equation_label}
\end{equation}

\end{document}

Running latex returns a refcheck warning with a line number containing a linebreak (1\n2):

❯ latex log-msg-line-no-with-linebreak.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
(./log-msg-line-no-with-linebreak.tex
LaTeX2e <2018-12-01>
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2018/texmf-dist/tex/latex/refcheck/refcheck.sty)
No file log-msg-line-no-with-linebreak.aux.
Package: `refcheck' v1.9.1 <2013/02/14>
options: showrefs, showcites, msgs, chckunlbld

Package refcheck Warning: Unused label `eq:your_equation_label' on input line 1
2.

[1] (./log-msg-line-no-with-linebreak.aux)

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

 )
Output written on log-msg-line-no-with-linebreak.dvi (1 page, 816 bytes).
Transcript written on log-msg-line-no-with-linebreak.log.

With

:set efm=%+WPackage\ %s\ Warning:\ %m\ on\ input\ line\ %l

reading the log file manually :cfile log-msg-line-no-with-linebreak.log generates following warning:

|1 warning| Package refcheck Warning: Unused label `eq:your_equation_label' on input line 1

As you can see the warning is issued for line number 1 which is incorrect.


For the purpose of reference I want to add links to 'efm' settings for latex or external tools

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.