GeneralBox around customized example

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
darkmoor
Posts: 1
Joined: Tue Jan 12, 2010 10:45 am

Box around customized example

Post by darkmoor »

Hi,

I new to this forum, but hope that I have put my problem in the right place?

I have made a \newtheorem as below.

Code: Select all

\newtheorem{example}{Example}[subsection]
which works as it should. But I would like to customise it a bit more. What I would like to do; is to put at box around the example and make the margins in the example smaller than the rest of the document. But how do I do this? I have tried looking around using google but without any succes.

\Emil

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Box around customized example

Post by gmedina »

Hi,

you could define a new environment with the help of the the framed environment provided by the framed package (documentation in the file framed.sty itself). Take a look at the following simple example:

Code: Select all

\documentclass{article}
\usepackage{framed}
\usepackage{amsthm}
\usepackage{lipsum}% just to generate some text

\newtheorem{example}{Example}[subsection]
\newenvironment{myexample}
  {\begin{framed}\begin{example}}
  {\end{example}\end{framed}}

\begin{document}

\lipsum[1]
\begin{myexample}
\lipsum[1]
\end{myexample}
\lipsum[1]

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Box around customized example

Post by frabjous »

You could also try the \theoremindent and \newframedtheorem commands from the ntheorem package (with the framed option).
Post Reply