Page LayoutReferencing suppressed section numbers

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
alastairandrew
Posts: 8
Joined: Sun Aug 31, 2008 10:08 pm

Referencing suppressed section numbers

Post by alastairandrew »

Hi,

I'd like to know if it's possible to reference the section numbers that have been repressed with the star (*) option. I've made a little example with two sections which are numbered, and several subsections which are not. If I use the \ref to point to labels within the subsections the references only display the most recent section numbers. Is that just a byproduct of hiding section numbers? I know I can get unreferenced sections to appear in a table of contents by explicitly adding them, is there a similar mechanism for getting their reference numbers

Code: Select all

\documentclass[12pt]{article}
\title{Section Labelling Test}
\begin{document}
  \maketitle 
  \section{First Section\label{sec:1}}
  I'm interest in looking at Subsection~\ref{sec:2.1} which I'd expect to be 2.1. I'm not interested in Subsections~\ref{sec:1.1} or \ref{sec:1.2} though they should be 1.1 and 1.2 respectively.
  \subsection*{First Subsection\label{sec:1.1}}
  Not interesting
  \subsection*{Second Subsection\label{sec:1.2}}  
  Irrelevant
  \section{Second Section\label{sec:2}}
     	Some facts
  	\subsection*{First Subsection of the Second Subsection\label{sec:2.1}}
		Subsection of interest!
\end{document}
Thanks,
Alastair

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Referencing suppressed section numbers

Post by Stefan Kottwitz »

Hi Alastair,

referencing with numbers to subsections that aren'nt numbered is fooling the reader. It's like having a table of contents with page numbers but no single page has a page number written on it.

Though it could be done with \refstepcounter, for example:

Code: Select all

\documentclass[12pt]{article}
\title{Section Labelling Test}
\begin{document}
  \maketitle
  \section{First Section\label{sec:1}}
  I'm interest in looking at Subsection~\ref{sec:2.1} which I'd expect to be 2.1. I'm not interested in Subsections~\ref{sec:1.1} or \ref{sec:1.2} though they should be 1.1 and 1.2 respectively.
  \refstepcounter{subsection}
  \subsection*{First Subsection\label{sec:1.1}}
  Not interesting
  \refstepcounter{subsection}
  \subsection*{Second Subsection\label{sec:1.2}} 
  Irrelevant
  \section{Second Section\label{sec:2}}
        Some facts
  \refstepcounter{subsection}
     \subsection*{First Subsection of the Second Subsection\label{sec:2.1}}
      Subsection of interest!
\end{document}
Stefan
LaTeX.org admin
alastairandrew
Posts: 8
Joined: Sun Aug 31, 2008 10:08 pm

Re: Referencing suppressed section numbers

Post by alastairandrew »

Thanks Stefan,

That's ideal, cheers for the suggestion. I do agree with you that I am misleading the readers by providing a reference number for a section that doesn't actually appear but I feel that's the best option for my requirements.

I'm currently writing my thesis and I have several subsections in some chapters (describing related components of a large software system) where I've suppressed the numbering because I think stylistically it looks better. However in a later chapter I want to refer to a specific unnumbered subsection. At present the reference is something just a plain integer (e.g. see Section 11) but this doesn't provide any context such as which chapter this section is actually in. I had toyed with using the zref package to provide the reference as the section name rather than a number but again this provides no chapter context, unless I do something like (see the Title Of Section section in Chapter chapter of section). My supervisor may make me change it all anyway!

Thanks for your help though,
Alastair
Post Reply