Resetting counter

You have to use \stepcounter or \refstepcounter to trigger the reset code. If you set the value in other ways then you need to reset the other counter to 0 explicitly.

If you get \endcsname errors that is another problem and probably needs another question. But if you ask a question please give people half a chance of answering it by providing a complete (small) document that produces the error.


I suppose you want to present multiple solutions to a problem? Then you could do it like this:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}

\newcounter{problem}[section]
\newcounter{solution}[problem]
\renewcommand{\thesolution}{\arabic{problem}.\arabic{solution}}


\begin{document}

\section{one}
\stepcounter{problem}problem \theproblem\\
\stepcounter{solution}solution \thesolution\\
\stepcounter{solution}solution \thesolution\\
\stepcounter{solution}solution \thesolution\\

\stepcounter{problem}problem \theproblem\\
\stepcounter{solution}solution \thesolution\\
\stepcounter{solution}solution \thesolution\\

\section{one}
\stepcounter{problem}problem \theproblem\\
\stepcounter{solution}solution \thesolution\\
\stepcounter{solution}solution \thesolution\\
\stepcounter{solution}solution \thesolution\\
\stepcounter{solution}solution \thesolution\\

\stepcounter{problem}problem \theproblem\\
\stepcounter{solution}solution \thesolution\\
\stepcounter{solution}solution \thesolution\\
\stepcounter{solution}solution \thesolution\\

\end{document}

enter image description here

Tags:

Counters