29

I'm trying to 'reference' the \section*{Introduction} of my article. I can quite easily reference the \section{InsertSectionName} with a \label{} and a \ref{} (taking this as my definition of 'reference') but it doesn't appear to work this way for an un-numbered section.

Is there a way to do it, or to at least reference the first line of the \section*{Introduction}?

Note: I prefer to have the "Introduction" of my article as un-numbered and to start with (Section)"1" thereafter.

4 Answers 4

14

You have a logical issue: how would you refer to an unnumbered section? If by name, then you have (in theory) issues of how the name in the title should be typeset versus how it should be written as a label. One extraordinarily cheap way of doing things is to hijack the labeling mechanism:

\documentclass{article}
\newcounter{intro}
\renewcommand{\theintro}{Introduction}
\begin{document}
 \section*{Preface to the article}
 \refstepcounter{intro}
 \label{s:intro}


 \ref{s:intro}
\end{document}

The reference will print "Introduction" (i.e. regardless of what you call the section).

1
  • The issues you are referring to are handled by the nameref package, and others. See my answer.
    – krlmlr
    Jul 9, 2012 at 19:59
28

The hyperref bundle has the nameref package that has a \nameref command which solves your problem by using the section name as reference label.

\documentclass{article}
\pagestyle{empty}
\usepackage{nameref}

\begin{document}
  \section*{Test}
  \label{sec:test}
  \section{Other}
  \nameref{sec:test}
\end{document}

Compilation result

Other options include the titleref, zref or gettitlestring packages. JLDiaz has quoted the UK TeX FAQ that lists these and other packages.

17

You didn't mention this, but if what you are looking for is the hyperlink functionality provided by the hyperref package, you can simply use the \hyperref command to create a link to the section and provide the text of the link in the body of the document.

\documentclass{article}
\usepackage{hyperref}
\begin{document}
  \section*{Preface to the article}
  \label{s:intro}

  \hyperref[s:intro]{Introduction}
\end{document}
3
  • 3
    I believe you need to issue \phantomsection before the label, as a starred section won't actually count as a link target otherwise.
    – Ryan Reich
    Jul 9, 2012 at 18:24
  • Beginning with version 2009-11-25 of hyperref, unnumbered sections set anchors, so you don't need \phantomsection in this case. Jul 9, 2012 at 20:09
  • I guess you see how long it's been since I last tried to set up a hyperref-compatible labeling system :)
    – Ryan Reich
    Jul 10, 2012 at 3:52
6

Note that \ref{} expands to the number of the section, as for example "See section~\ref{sectionname}" produces "See section 2.1". What would you expect to get if the section has no number?

One option is to refer to the page in which the section appears. This is easy: "See the section starting in page~\pageref{sectionname}".

Another options is to refer to the section by its name. You can do it with a literal string: "See section ``Introduction''", or using some package which can store and extract the section names for reference purposes, such as the ones listed in this faq

Your Answer

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