3

I have created the following custom sectioning using the titlesec package.

% in the preamble

\newcounter{phase}
\titleclass{\phase}{straight}[\section]
\titleformat{\phase}{\bfseries\sffamily}{Phase~\thephase:}{1mm}{}
\renewcommand{\thephase}{\arabic{phase}}

\newcounter{task}[phase]
\titleclass{\task}{straight}[\phase]
\titleformat{\task}{\bfseries\itshape}{Task~\thephase.\thetask:}{1mm}{}
\renewcommand{\thetask}{\arabic{task}}


% within the document

\phase{Target selection and testbed preparation} % outputs Phase 1: Target selection and testbed preparation
\label{sec:phase-selection}

...

\task{Identification of target systems} % outputs Task 1.1: Identification of target systems
\label{sec:phase-selection:task-identification}


% later on in the document (ISSUE!)

Task~\ref{sec:phase-selection:task-identification} % outputs Task 1 rather than Task 1.1

Why doesn't the label contain the correct counter?

1 Answer 1

4

I think you need to say:

\renewcommand{\thetask}{\thephase.\arabic{task}}
3
  • ... of course, the titleformat for task will also have to be changed to reflect that. Commented Oct 12, 2010 at 23:18
  • \titleformat{\task}{\bfseries\itshape}{Task~\thetask:}{1mm}{} \renewcommand{\thetask}{\arabic{task}} - worked like a charm - thanks.
    – phretor
    Commented Oct 13, 2010 at 10:29
  • 1
    @phretor: if the answer solved your problem, it would be nice of you if you mark the answer as "accepted" by clicking on the checkmark on the left of the question.
    – Stefan Kottwitz
    Commented Nov 25, 2010 at 19:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .