# Changing frame size in mdframed

I am trying to place a box around a definition. Using the package mdframed, I have managed to do so. However, the box is too large, in particular too tall, and it is covering up text appearing above and below the definition. I am using

\newenvironment{bdefn}
{\begin{mdframed}\begin{defn}}
{\end{defn}\end{mdframed}}


to create the "boxed definition" environment, and then I am using

\begin{bdefn}
(text)
\end{bdefn}


for the definition itself.

I have tried to manually create a new mdframed style to use which has smaller margins, using something like

\mdfdefinestyle{style1}{leftmargin=1cm,rightmargin=1cm,skipbelow=1cm,skipabove=1cm}.


The command \mdfdefinestyle and this format are both taken from the documentation for mdframed. However, when I place this line into my document's preamble, I receive the error message

"Undefined control sequence: \mdfdefinestyle{stlye1}{..."


Can anyone tell me why the command \mdfdefinestyle is not being recognized? Or, can anyone suggest a different way to make an as-small-as-possible box around my definition?

• Please give a complete document that demonstrates the error, and show the full error message from the log from ! to ? you have only shown part of the error, which does not show which command is undefined (the last command on the second line of the message) – David Carlisle Feb 10 '15 at 23:44
• Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. – Martin Schröder Feb 10 '15 at 23:46

You have to use the style like style=style1 (not just style1). Speaking further, you can use \surroundwithmdframed[<options>]{environment} to surround an existing environment with a mdframed frame. So to cover defn with frame, you need

\surroundwithmdframed[style=style1]{defn}


Here is a sample.

\documentclass{article}
\usepackage{amsthm}
\newtheorem{defn}{Definition}
\usepackage[framemethod=TikZ]{mdframed}
\mdfdefinestyle{style1}{leftmargin=1cm,rightmargin=1cm,skipbelow=1cm,skipabove=1cm,
innertopmargin=0pt}
\surroundwithmdframed[style=style1]{defn}
\begin{document}
\begin{defn}%
(text)
\end{defn}
\end{document}