3

How do I set up a global mdframed environment?

Would I add something like this in the preamble:

\newtheorem{laws}
\mdfsetup{%
  background = blue!30,%
  roundcorner = 5pt
}
}

but then I want to be able to add the title by doing

\begin{mdframed}{title}
  information
\end{mdframed}

The new environment would then look like:

enter image description here

4

I am not sure if this is what you need, but you could use \newmdtheoremenv and the optional argument for the defined structure:

\documentclass[a4paper]{article}
\usepackage[framemethod=tikz]{mdframed}

\newmdtheoremenv[
  backgroundcolor = blue!30,
  roundcorner = 5pt,
]{laws}{Law}

\begin{document}

\begin{laws}[Newton's First Law]
Every body persists in its state of being at rest or of moving uniformly straight forward, except insofar as it is compelled to change its state by force impressed.
\end{laws}

\end{document}

enter image description here

If no numbering and no special treatment (as in theorem-like structure) is needed, then one could say something like:

\documentclass[a4paper]{article}
\usepackage[framemethod=tikz]{mdframed}

\newmdenv[
  backgroundcolor = blue!30,
  roundcorner = 5pt,
]{lw}
\newenvironment{laws}[1]
  {\begin{lw}[frametitle=#1]}
  {\end{lw}}

\begin{document}

\begin{laws}{Newton's First Law}
Every body persists in its state of being at rest or of moving uniformly straight forward, except insofar as it is compelled to change its state by force impressed.
\end{laws}

\end{document}

enter image description here

  • Could the word law and the indexing be removed? – dustin Jul 22 '13 at 18:21
  • I added a picture to demonstrate what I mean. – dustin Jul 22 '13 at 18:26
  • @dustin please see my updated answer. – Gonzalo Medina Jul 22 '13 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.