I've created a \newcommand which is similar to the \section and \subsection as it contains a counter and a 'sub-counter' (e.g. 2.4).
The only thing that I couldn't figure out yet is how to properly refer to the counters. I read that if one uses \refsetcounter, the counter number should be accessible by the \ref command, but this somehow does not seem to work very well, as illustrated in the example below...
Code: Select all
\documentclass{article}
\setlength{\parindent}{0mm}
\newcounter{thephase} \setcounter{thephase}{0}
\newcounter{thesubphase}[thephase] \setcounter{thesubphase}{0}
\newcommand{\phase}[1]{\noindent%
\refstepcounter{thephase}\textbf{Phase \arabic{thephase}} --- \texttt{#1}\\%
}
\newcommand{\subphase}[1]{\noindent%
\dots\refstepcounter{thesubphase}\textbf{Phase \arabic{thephase}.\arabic{thesubphase}} --- \texttt{#1}\\%
}
\begin{document}
\phase{Bla bla bla}
\phase{A Phase}
This is just some random text\dots\\
\subphase{A Sub-Phase (with label)\label{pha: mysubphase}}
And some more random text. But this time, I'd like to refer to this phase by setting a label.\\
\subphase{A Sub-Phase}
\phase{The Last Phase (with label)\label{pha: last phase}}
\vspace{1cm}
In this paragraph, I'd like to refer to the label I've set in the first sub-phase and the last phase;\\
Phase \ref{pha: mysubphase} and \ref{pha: last phase} contains\dots\\
\textbf{However, it should print:}\\
Phase 2.1 and 3 contains\dots
\end{document}
Cheers