5

I'm using the newtheorem macro in amsthm for example environments. Is there a way for a sub-example? I don't need anything fancy like indenting, just a new counter level would do. So that within say Example 4, a few sub-examples would be numbered as Example 4.1, Example 4.2, etc. Maybe I could just do something with the counter in that area of the document?

\documentclass[12pt]{article}
\usepackage{amsthm}
\newtheorem{example}{Example}
\begin{document}

\begin{example} first example \end{example}

\begin{example} second example. Here are situations where this occurs. \end{example}

%\begin{subexample} first sub-example of second example %\end{subexample}

%\begin{subexample} second sub-example of second example %\end{subexample}

\begin{example} third example \end{example}

\end{document}

kara890
  • 53

2 Answers2

6

You can specify this "sub-numbering" via a final/closing optional argument in \newtheorem{<theorem>}[<sibling counter>]{<title>}[<sub-counter>] (where the optional arguments are mutually exclusive; that is, you can't use both):

enter image description here

\documentclass{article}

\usepackage{amsthm}

\newtheorem{example}{Example} \newtheorem{subexample}{Example}[example]% subexample is a sub-counter to example

\begin{document}

\begin{example} first example \end{example}

\begin{example} second example. Here are situations where this occurs. \end{example}

\begin{subexample} first sub-example of second example \end{subexample}

\begin{subexample} second sub-example of second example \end{subexample}

\begin{example} third example \end{example}

\end{document}

Werner
  • 603,163
3

Define subexample using the amsthm commands as normal.

Afterwards, issue \counterwithin{subexample}{example}, which would make the counter for subexample subordinate to that for example.

Willie Wong
  • 24,733
  • 8
  • 74
  • 106