3

When you create a new section within AUCTeX (using C-c C-s) and give the section a name, RefTeX will prompt you for a title, insert the section, and then prompt you for a label. This label is auto-populated with a reasonable default:

\section{Mathematical Definitions}
\label{sec:math-defin}

This happens for all header commands:

\subsection{Graphs}
\label{sec:graphs}

When you only go one level deep in the hierarchy or have a shorter or more diverse paper, these defaults are perfectly fine. However, in writing the first draft for my undergrad thesis, I'm finding myself using the same subheadings again under different headings:

\section{Implementation}
\label{sec:implementation}

\subsection{Graphs}
\label{sec:graphs-1}

How can I have the secondary headings' labels, sec:graphs and sec:graphs-1, as below?

\section{Mathematical Definitions}
\label{sec:math-defin}

\subsection{Graphs}
\label{sec:math-defin:graphs}

\section{Implementation}
\label{sec:implementation}

\subsection{Graphs}
\label{sec:implementation:graphs}

Ideally, I'd like this behavior to be consistent:

\section{Graphs}
\label{sec:graphs}
\label{fig:graphs:diagram}

\section{Math}
\label{sec:math}
\subsection{Contrived}
\label{sec:math:contrived}
\begin{example} % an environment AUCTeX doesn't know about
  \label{ex:math:contrived:example}
  ...
\end{example}
  • Do you use RefTeX? – giordano Dec 28 '13 at 9:47
  • 1
    Assuming you use RefTeX (AUCTeX hasn't any smart label creation feature), it doesn't seem an easy task without redefining the function reftex-label (but I don't recommend to redefine it). If you really want to redefine (or advise) the function you have to change the default variable. – giordano Dec 28 '13 at 10:48
  • @giordano I should have noticed it was RefTeX—I'll take a look at the default variable and see what I can come up with. It's not a particularly easy task, especially since (to my knowledge) no structure tree is being kept; it would have to be generated on reftex-parse-all or the like. – Sean Allred Dec 28 '13 at 13:05
  • There is reftex-toc, but you're right, a structure tree would be much more useful for your task. I don't know how one could parse the output of reftex-toc to achieve what you're seeking. – giordano Jan 4 '14 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.