I have document with 30 math examples. How do I number these examples automatically? Without using the list
\begin{enumerate} ... \end{enumerate}
like
Example 1
blah blah
Example 2
blah blah
and so on?
I have document with 30 math examples. How do I number these examples automatically? Without using the list
\begin{enumerate} ... \end{enumerate}
like
Example 1
blah blah
Example 2
blah blah
and so on?
Something like this:
\newcounter{xmpl}
\newenvironment{example}
{\noindent
\refstepcouter{xmpl}
\textbf{Example \thexmpl }
}{\par\noindent%
\ignorespacesafterend}
and then use as:
\begin{example}
< content of the example>
\end{example}
Addendum:
More simpler and straightforward solution is consider Christian Hupfer comment below: use of newtheorem.
amsthm\newtheorem{example}{Example}More details and concise description about theorems like environments you can find in Wikibook LaTeX/Theorems. Sorry, because I didn't recall for this usual approach before.
Addedndum 2:
You can also use enumerate environment. Package enumitem offer simple redefinition of labels:
\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum}
\begin{document}
\begin{enumerate}[label=Exercise \arabic*]
\item \lipsum*[11]
\[
c = \sqrt{a^2 + b^2}
\]
\item blah blah
\[
a = \sqrt{c^2 - b^2}
\]
\item blah blah
\end{enumerate}
\end{document}
For other possibilities for formatting of enumerate environment see package documentation.
Of course this recent solution has sense if examples are organised as list, i.e. examples follow one after another.
\newtheorem approach, \newtheorem{example}{Example}, for example (pun intented ;-))
–
May 06 '17 at 06:49
\begin{equation}1=0\end{equation}will number the equation as 1,2,... – David Carlisle May 05 '17 at 22:40