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 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.

share|improve this question
add comment

4 Answers

up vote 7 down vote accepted

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).

share|improve this answer
    
This works! Thanks, Ryan. –  user16307 Jul 9 '12 at 17:04
    
The issues you are referring to are handled by the nameref package, and others. See my answer. –  krlmlr Jul 9 '12 at 19:59
add comment

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.

share|improve this answer
add comment

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}
share|improve this answer
1  
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 '12 at 18:24
    
Beginning with version 2009-11-25 of hyperref, unnumbered sections set anchors, so you don't need \phantomsection in this case. –  Nathan Grigg Jul 9 '12 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 '12 at 3:52
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

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