2

I am writing a tex file of homework problems and the counter in the code below starts from $1$. How can I set the counter to start from $5$?

\setcounter{secnumdepth}{0}
\newcommand{\homeworkProblemName}{}%
\newcounter{homeworkProblemCounter}%
\newenvironment{homeworkProblem}[1][Problem     \arabic{homeworkProblemCounter}]%
{\stepcounter{homeworkProblemCounter}%
\renewcommand{\homeworkProblemName}{#1}%
\section{\homeworkProblemName}%
\enterProblemHeader{\homeworkProblemName}}%
{\exitProblemHeader{\homeworkProblemName}}%
2
\setcounter{homeworkProblemCounter}{4}
4
  • In which line do I put this piece of code? Dec 12 '16 at 3:46
  • 1
    @failexam Right after \newcounter{homeworkProblemCounter}
    – siracusa
    Dec 12 '16 at 4:15
  • @siracusa Or anywhere after that before you first use the environment, in fact.
    – cfr
    Dec 12 '16 at 4:21
  • @failexam After the new counter is created and before you use the environment. Right after making the counter is a good place as siracusa suggests.
    – cfr
    Dec 12 '16 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.