Text Formattingintroduce example

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
rayman
Posts: 24
Joined: Thu Feb 24, 2011 11:53 am

introduce example

Post by rayman »

I need to introduce an example in the text I am writting (in the same way as we introduce definitions, theorems and so on)
I have tried \begin{example} but such function did not work.
How do I do it that so that the example will be numberized as well (in the same way as for definitions)?
Thank you!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

introduce example

Post by shadgrind »

This is explained in the documentation for the amsthm package:

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\newtheorem{example}{Example}
\begin{document}
\begin{example}
 For example, this is an example.
\end{example}
\end{document}
If you want the examples to be numbered by section you'd use

Code: Select all

\newtheorem{example}{Example}[section]
in the preamble.
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
rayman
Posts: 24
Joined: Thu Feb 24, 2011 11:53 am

Re: introduce example

Post by rayman »

thank you!
Post Reply