I'm trying to add a counter to subsection titles. For example:
Design tests
1.1 Test 1. A test
1.2 Test 2. Another test
Functional tests
2.1 Test 3. Yet another test
The problem is, since the counter is also increased in the table of contents, table of contents will show:
1.1 Test 1. A test (and the other two tests will be 2 and 3)
but then the section in the document will be:
1.1 Test 4. A test (and the other two tests will be 5 and 6)
How could I skip the table of contents from using the counter?
Here is a sample code:
\documentclass{article}
\newcounter{test}
\DeclareRobustCommand{\newtest}[1]{
\refstepcounter{test} \label{test:#1}
Test \thetest #1
}
\begin{document}
\title{Test example}
\maketitle
\clearpage
\tableofcontents
\clearpage
\section{Design tests}
\subsection{\newtest{A test}}
\subsection{\newtest{Another test}}
\section{Functional tests}
\subsection{\newtest{Yet another test}}
\end{document}