Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org-mode export to Latex — suppress generation of labels

I'm using org-mode to write a report which I then export to LaTeX. I have a few different .org files (one per chapter), which I export as "headless" LaTeX and then combine in a master .tex file. This works nicely, except that the generated .tex files contain labels with conflicting numbers. So both a.tex and b.tex contain \label{sec-1}, for example.

As long as I never actually use these references then it's not much of a problem I think, although the warnings do annoy me. Is there any way to turn off the generation of these labels? It should be simple but I cannot find anything about this in the documentation.

like image 288
John J. Camilleri Avatar asked Aug 06 '13 09:08

John J. Camilleri


1 Answers

I have written a bit of Lisp which will remove said labels after the export to LaTeX, which looks like this:

(defun remove-orgmode-latex-labels ()
  "Remove labels generated by org-mode"
  (interactive)
  (let ((case-fold-search nil))
   (goto-char 1)
   (replace-regexp "\\\\label{sec-[0-9][^}]*}" "")
   )
)
(add-hook 'org-export-latex-final-hook 'remove-orgmode-latex-labels)

This seems to do the job without removing my own custom labels.

like image 141
John J. Camilleri Avatar answered Nov 15 '22 08:11

John J. Camilleri