LaTex Labels and custom counters in environment

3. December 2008

A counter should be named the same as the environment.

 

\newcounter{exercise}
\newenvironment{exercise}[1]%
{\refstepcounter{exercise}\vspace{10pt}\par\noindent
\textbf{Exercise \theexercise\ (#1)}
\begin{itshape}\par\noindent\vspace{10pt}}
%
{\end{itshape}\vspace{10pt}\par}

 

 

Example of use

Exercise~\ref{ex:simple} is a simple exercise.

\begin{exercise}{Simple Exercise}%
\label{ex:simple}%
This is a simple exercise.
\end{exercise}

 

Link

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Latex

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading