Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

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

share|improve this answer
    
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
    
That is great thanks. –  dustin Jul 22 '13 at 18:28
    
@dustin You're welcome! –  Gonzalo Medina Jul 22 '13 at 18:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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