Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm currently writing a report in org-mode. I have a couple of sections which have the same names, with the section names appearing both as a subsection of the background section, and as a section in themselves. The following example should show the issue that I'm coming across. In the document below, I want to refer to the two sections with duplicate names in the introduction. To refer to a section the [[Section Name]] syntax is used. A brief description of the usage is found in the org manual.

#+TITLE: Musings about Sections
#+AUTHOR: R. Chapter
#+OPTIONS:   H:3 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+INFOJS_OPT: view:nil toc:t ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
#+LATEX_CLASS: article
#+LATEX_CLASS_OPTIONS: [a4paper,11pt]
* Introduction
In section [[The Use of Sections]], we speak about how sections are used. In section
[[How Sections Work]] we briefly introduce the implementation of sections. In
section [[How Sections Work]] we go into more detail about the inner workings of sections.
* Background
** The Use of Sections
** How Sections Work
* How Sections Work

Exporting this file to latex results in the first section with the duplicate name being referenced twice, where in fact the first section reference to "How Sections Work" should be to sec-2-2, and the second to sec-3.

\title{Musings about Sections}
\author{R. Chapter}
\date{\today}
\begin{document}

\maketitle

\section{Introduction}
\label{sec-1}

In section \ref{sec-2-1}, we speak about how sections are used. In section
\ref{sec-2-2} we briefly introduce the implementation of sections. In
section \ref{sec-2-2} we go into more detail about the inner workings of sections.
\section{Background}
\label{sec-2}
\subsection{The Use of Sections}
\label{sec-2-1}
\subsection{How Sections Work}
\label{sec-2-2}
\section{How Sections Work}
\label{sec-3}

Is there any way that I can refer to a specific section from within org-mode, given that I don't know what section reference it will be given when I export it?

share|improve this question

migrated from stackoverflow.com Mar 21 '13 at 19:24

This question came from our site for professional and enthusiast programmers.

    
This is not possible in orgmode at present - the labels for sections and subsections are hard-coded into the exporter function. I suggest you submit a feature-request to the orgmode list. –  Tyler May 3 '13 at 18:17
1  
This is really a question about org-mode, not about LaTeX. Why was it migrated? –  Seamus May 18 '13 at 9:59

1 Answer 1

up vote 4 down vote accepted

You can get what you want with the CUSTOM_ID property

#+TITLE: Musings about Sections
#+AUTHOR: R. Chapter
#+OPTIONS:   H:3 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS:   TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+INFOJS_OPT: view:nil toc:t ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
#+LATEX_CLASS: article
#+LATEX_CLASS_OPTIONS: [a4paper,11pt]
* Introduction
In section [[The Use of Sections]], we speak about how sections are used.
In section  [[#background-how]] we briefly introduce the implementation
of sections. In section [[#detail-how]] we go into more detail about
the inner workings of sections.
* Background
** The Use of Sections
** How Sections Work
:PROPERTIES:
:CUSTOM_ID: background-how
:END:
* How Sections Work
:PROPERTIES:
:CUSTOM_ID: detail-how
:END:

Exporting this to latex creates a second label for each section

\documentclass[a4paper,11pt]{article}
\usepackage{hyperref}
\title{Musings about Sections}
\author{R. Chapter}
\date{\today}
\hypersetup{
  pdfkeywords={},
  pdfsubject={},
  pdfcreator={Emacs Org-mode version 7.8.11}}

\begin{document}

\maketitle

\section{Introduction}
\label{sec-1}

In section \hyperref[sec-2-1]{The Use of Sections}, we speak
about how sections are used. In section  \ref{background-how} we
briefly introduce the implementation of sections. In section \ref{detail-how}
we go into more detail about the inner workings of sections.
\section{Background}
\label{sec-2}
\subsection{The Use of Sections}
\label{sec-2-1}
\subsection{How Sections Work}
\label{sec-2-2}
\label{background-how}
\section{How Sections Work}
\label{sec-3}
\label{detail-how}

\end{document}

Other folks reading this might need to

(setq org-export-latex-hyperref-format "\\ref{%s}")

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.