1

When inserting an equation with C-c C-e in Emacs, by default AUCTeX (probably in collaboration with RefTeX) also produces an autonumbered simple label for it of the form \label{eq:1}, and so on. There's obviously some incremented counter in the backend that determines the number to be inserted, but I can't find anything in the documentation about how to read it and alter it.

For example, this is obviously an issue when joining together files that were written separately, in order to avoid multiply-defined references, or if a document is split across files: to continue automatically inserting equation labels consistently, one has to adjust the counter manually. Can anyone explain how to do this?

(This is of course different from what is actually displayed in the document, and appears to be purely a RefTeX feature.)

  • Check the documentation of RefTeX, section Creating Labels. – Arash Esbati Apr 1 '16 at 17:43
  • @ArashEsbati I looked there: the only part that appears to be relevant is "If derive is nil, the default label will consist of the prefix and a unique number, like ‘eq:23’.", which doesn't explain how and where this "unique number" is obtained. – Chappers Apr 1 '16 at 18:07
  • Does reftex-renumber-simple-labels to renumber labels? – giordano Apr 1 '16 at 18:26
  • 1
    @Chappers If you're writing a single document split over multiple files and all files have the TeX-master variable correctly set, then automatic label numbering of RefTeX provides unique labels in the whole document, not on a per-file basis, avoiding the label clash you're claiming. That's only true if you merge different documents together. – giordano Apr 2 '16 at 9:02
  • 1
    @Chappers - RefTeX should work just fine on multi-file documents, as mentioned by @giordano. Another approach for you could be altering the eq: prefix and not the unique number. Check the docstring of reftex-label-alist (C-h v reftex-label-alist RET) or the manual for label-prefix. You could append the file name to eq: with (setq reftex-label-alist '((nil ?e "eq:%f:" nil nil (regexp "equations?" "eqs?\\." "eqn\\." "Gleichung\\(en\\)?" "Gl\\.")))). (Note that %f:). – Arash Esbati Apr 4 '16 at 17:08
2

If I'm understanding your question correctly, it seems to be more about getting RefTeX to see all the files associated with the project and treat them as one big project instead of disjointed files. To do that, you must let AUCTeX and RefTeX know which is the master file.

Add (setq-default TeX-master nil)to your emacs init file. This will query for the master file when you open the document. You will want to point your subfiles to the master file. If your version of AUCTeX was not installed from ELPA, you will also want to add (setq TeX-parse-self t) and (setq TeX-auto-save t), otherwise it is no longer necessary; this will parse the document and let AUCTeX know what the contents of the project are, like equation labels, in your case.

Once this is done, every time you add a new label in one of the files, it will do it incrementally as you move around from file to file.

1

To avoid a misunderstanding: The eq or the item counter of the labeling mechanism of AUCTeX is not printed! It is just a label to which you refer with the \ref command.

You can change this manually to your hearts content, e.g. write \label{eg:root-from--1}.

If you'd like to have the counter to work differently, e.g. write eq:7-3 for the third equation in the seventh chapter, please describe what you are trying to do.

  • I am aware of this; I've clarified the question. – Chappers Apr 1 '16 at 18:05

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.