3

I am trying to export an .org buffer with the following contents:

#+CAPTION: My subgraph.
#+NAME: fig:subgraph
[[/tmp/image-4383FmT.png]]

The following latex output is produced:

% Created 2018-01-30 Tue 09:32
% Intended LaTeX compiler: pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\author{meir}
\date{\today}
\title{}
\hypersetup{
 pdfauthor={meir},
 pdftitle={},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 24.5.1 (Org mode 9.1.4)}, 
 pdflang={English}}
\begin{document}

\tableofcontents

\begin{figure}[htbp]
\centering
\includegraphics[width=.9\linewidth]{/tmp/image-4383FmT.png}
\caption{\label{fig:org39390dd}
My subgraph.}
\end{figure}
\end{document}

The #+NAME: command was ignored. It works properly when I start Emacs with emacs -q. In the search for the guilty line in my configuration, I commented out lines in init.el until nothing remained, but the problem persists. What is going on? What is the difference between -q and empty init file? (I compared the *Messages* buffer after starting Emacs both ways and did not find any difference)

  • 1
    Try again with emacs -Q this also doesn't run the system configuration files for emacs. – Tobias Jan 30 '18 at 9:22
  • It works with either emacs -q or emacs -Q. – AlwaysLearning Jan 30 '18 at 12:52
5

There is a bit of differences between emacs -q and emacs with no init.el. See "Summary: Sequence of Actions at Startup".

Do you happen to have Emacs 25.2.2 with Org mode 8.2.10? Because that's what I have on my Debian System. When you run emacs -q, do you run that older version of org mode? Post the good output if you don't know what you are running.

Org version 8.3 or later introduced org-latex-prefer-user-labels, which is nil as a default. With this variable set to non-nil, you can use your custom ID, which is taken from #+NAME.

C-h v org-latex-prefer-user-labels to see more detail.

Here is the one I got from Org 8.2.10:

\begin{figure}[htb]
\centering
\includegraphics[width=.9\linewidth]{/tmp/image-4383FmT.png}
\caption{\label{fig:subgraph}My subgraph.}
\end{figure}
% Emacs 25.2.2 (Org mode 8.2.10)

And with default Org 9.1.6:

\begin{figure}[htbp]
\centering
\includegraphics[width=.9\linewidth]{/tmp/image-4383FmT.png}
\caption{\label{fig:org15c1279}
My subgraph.}
\end{figure}

And this is Org 9.1.6 with org-latex-prefer-user-labels set to t:

\begin{figure}[htbp]
\centering
\includegraphics[width=.9\linewidth]{/tmp/image-4383FmT.png}
\caption{\label{fig:subgraph}
My subgraph.}
\end{figure}
\end{document}
  • The output that I posted indicates: Emacs 24.5.1 (Org mode 9.1.4). When Emacs starts, there is no variable org-latex-prefer-user-labels. It appears only after an export. Nonetheless, setting it to t resolves the problem. Thanks! – AlwaysLearning Jan 30 '18 at 13:08
  • @AlwaysLearning , you said emacs -q works. What is the version of your emacs -q? Plus, please fix the question title, it's not about -q or init.el. – Yasushi Shoji Jan 30 '18 at 14:36
  • emacs -q --version gives GNU Emacs 24.5.1. Now that I am thinking about it: why does it work with -q? – AlwaysLearning Jan 30 '18 at 20:40
  • And Org's veresion is? – Yasushi Shoji Jan 31 '18 at 0:59
  • 1
    With -q, org-version gives 8.2.10. I guess this explains it! – AlwaysLearning Jan 31 '18 at 6:50

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.