I'm trying to reference a label's parent so it outputs something like "Section, Subsection" or "Section, Subsection, Subsubsection". I've come close with smartref by doing the following:


\newcommand{\breadref}[1]{\sectionref{#1}, \fullref{#1}}

but this unfortunately only outputs the number of the section and not the name of the section. The documentation of smartref alludes to a \byname option but doesn't seem to actually provide a working example of it, making it difficult to implement.

It seems like this should be an easy thing to do, and a useful thing at that, especially if subsections might move between sections making hard-coded references to parents a pain.

Any ideas would be appreciated.



Ideally, it would look like this:

sketch of desired output

  • I think you want to have a look at nameref and cleveref. – egreg Dec 10 '18 at 12:54
  • @egreg I had a look at these packages but couldn't find what I was looking for. Think you could point me in the right direction or put together an answer? – Mackey18 Dec 10 '18 at 12:55
  • Please, add a sketch of the expected output. – egreg Dec 10 '18 at 13:09
  • @egreg Added to main question – Mackey18 Dec 10 '18 at 13:55

With some tweaks!

However, you need to use \sectionlabel for sections and \subsectionlabel for subsections and not just \label, because we need to add functionality.



  \byname{\@nameuse{parent@#1}}, \byname{#1}~(\ref{#1})%


\section{My section}\sectionlabel{sec:mysection}

Some text.

\subsection{My subsection}\subsectionlabel{subsec:mysubsection}

Some text.

\section{Reference section}

This is a reference to the subsection:


enter image description here

  • Even though I don't really understand what's going on here, it worked perfectly. – Mackey18 Dec 11 '18 at 11:53

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.