# Strange behavior Org-mode latex export label

Currently, I've experienced some strange behavior of latex labelling of org-mode exported file.

Normally, I use the label style like #+NAME: fig:name for figure and table labelling, which corresponds to the label in the LaTeX file as \label{fig:name}, and works fine with the org-ref reference style [[ref:fig:name]]. The sections I do not intentionally label will be added a label like \label{sec:1} in LaTeX file.

However, I found sometimes the org-mode exported file will generate a different label style like \label{sec:org76fd1b6}}, and the #+NAME: tag is not correctly translated to the label I want. Indeed, putting something like #+CAPTION: label:fig:name XXXX still works, but looks much uglier.

The question is: how is such behavior invoked and how to avoid it?

Tested system: OS X 10.11, Emacs 25.1, org-mode 20161102 and org-ref 20161101

• Does (setq org-latex-prefer-user-labels t) help? – VanLaser Nov 10 '16 at 19:45
• Interestingly I tried to evaluate this variable but seemed it did not exist. Do I need to require additional packages? – L.Zoeta Nov 12 '16 at 14:18
• The docline says that it's defined in ox-latex.el. You could probably use setq-default instead, or set it after loading ox-latex? But to see its doc, try to C-h v on it, after exporting from Org to LaTeX once. – VanLaser Nov 12 '16 at 15:23

The solution that has (so far) worked, is to reference the figure as [[fig:name]] in the text. The current Org-mode has been smart enough to translate this correctly. For sections etc, you could use a CUSTOM_ID and refer to [[#section_id]].
Alternatively, use the LaTeX-commands \label{fig:name} in your text and refer to it as \ref{fig:name}.