Math & Scienceamsthm example covered with box

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
libor
Posts: 1
Joined: Sat Mar 05, 2011 7:07 pm

amsthm example covered with box

Post by libor »

Hello,

I would like to ask you following question:

I would like to have example covered with box. I am using amsthm package, but inserting its example definition into \framebox is not possible. Do you know some way how to do this?

Thanks a lot.
Libor

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

amsthm example covered with box

Post by gmedina »

Hi,

you can use the ntheorem package instead of amsthm. There's a predefined framed theorem style if the heading and the body of the example should be boxed. If only the heading should be boxed, then you could easily define a new theorem style:

Code: Select all

\documentclass{article}
\usepackage{ntheorem}

\makeatletter
\newtheoremstyle{myframe}%
  {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
    \fbox{##1\ ##2}\theorem@separator}\hbox{\strut}}}]\normalfont}%
  {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
    \fbox{##1\ ##2\ (##3)}\theorem@separator}\hbox{\strut}}}]\normalfont}
\makeatother

\theoremstyle{myframe}
\newtheorem{exam}{Example}

\begin{document}

\begin{exam}
Test
\end{exam}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply