Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I was wondering if there was a way to modify the theorem environment so that it interacted with sections/subsections as follows:

\section{}
\subsection{}
\begin{ex} Whatever
\end{ex}

\begin{ex}Whatever
\end{ex}



\subsection{}

\begin{ex} Whatever

\end{ex}

Would output something like

1
1.1

Exercise 1.1.1


Exercise 1.1.2



1.2

Exercise 1.2.1

Where \begin{ex} is just an environment for an "exercise".

share|improve this question
2  
Sounds very doable :) could you turn your snippet into a complete MWE :) –  cmhughes Dec 20 '12 at 3:25
    
Related: tex.stackexchange.com/questions/28333/… –  lockstep Dec 20 '12 at 10:49

1 Answer 1

You can use the built-in feature for theorem numbering:

\documentclass{article}

\usepackage{amsthm} % not necessary

\newtheorem{ex}{Exercise}[subsection]

\begin{document}

\section{}

\subsection{}

\begin{ex}
Whatever
\end{ex}

\begin{ex}
Whatever
\end{ex}

\subsection{}

\begin{ex}
Whatever
\end{ex}

\end{document}
share|improve this answer
2  
This is a standard feature, not only of amsthm. –  egreg Dec 20 '12 at 8:37
    
@egreg And there exists \newtheorem without amsthm? –  tohecz Dec 20 '12 at 8:49
2  
Yes, of course; amsthm and the similar ntheorem just add to the kernel functionality. –  egreg Dec 20 '12 at 8:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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