Jump to next missing reference using auctex
Asked Answered
E

2

7

I'm using emacs + auctex for all my TeXing needs and I'm very satisfied with the workflow. However, there's one thing bothering me. Whenver I compile a document (possible consisting of multiple files) and there's a missing reference auctex prints this annoying message

LaTeX Warning: Reference `fig:MyMissingLabel' on page 42 undefined on input line 37.

and that's it. No shortcut for jumping to the missing reference, nada!
I'm aware that I could enable debugging of warnings, however, this is not really suitable in case the document produces other warnings which I don't want to debug¹.

I'd like to have a defun which cycles the point to the locations of the missing references. Thus I have not found anything online, maybe one of you guys can help?

Thanks in advance!

elemakil

[1] E.g. some packages report warnings when not loaded with a version number or something. I don't want to debug this. I'd like to correct my references!

Enneastyle answered 26/7, 2012 at 17:11 Comment(1)
Note that it states the error is on input line 37, so you can jump there with M-g M-g 37.Sidewinder
K
1

The shorcuts in AUCTeX allow you to jump to an error. The missing references are warnings. You can activate your desired behavior by treating warnings as errors with TeX-toggle-debug-warnings which is bound to C-c C-t C-w.

Knighthead answered 26/7, 2012 at 18:15 Comment(1)
As stated above this bears the problem that it cycles all warnings, not only the ones due to a missing reference.Enneastyle
P
0

This question is old, but here's my take. First, define the function

(defun my-ignore-TeX-warnings (type file line text &rest more)
  (setq ref "LaTeX Warning: Reference")
  (not (string-match-p ref text)))

Then customize the two variables TeX-ignore-warnings and TeX-suppress-ignored-warnings - e.g.,

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(TeX-ignore-warnings 'my-ignore-TeX-warnings)
 '(TeX-suppress-ignored-warnings t))

Note: heed the warning above - i.e., you should only have one custom-set-variables.

Put the code into your ~/.emacs or similar file. Then, enable TeX-toggle-debug-warnings or through the menu Command->TeXing options->Debug warnings.

Cycling through errors with C-` will include undefined references. One could extend the code above to also select undefined citations.

Yours,

Christian

Pm answered 2/1, 2021 at 19:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.