[Tex/LaTex] Box with dashed border

boxesmdframed

How can I modify the definition below to get an unfilled box with thick dashed lines around it and rounded corners? I don't want it to be numbered either.

\newmdtheoremenv[outerlinewidth=2,leftmargin=40,rightmargin=40,%
backgroundcolor=gray!30,outerlinecolor=black,innertopmargin=0pt,%
splittopskip=\topskip,skipbelow=\baselineskip,%
skipabove=\baselineskip,ntheorem,roundcorner=5pt]{case}{Case}[section]

Best Answer

  • To get rounded corner you need to load the package mdframed with parameter framemethod=tikz.

  • To get unfilled box you just have to omit the backgroundcolor parameter.

  • The way i found to get a dahsed line is by using tikzsetting, you can also customize the dashed style the way you want with dash pattern prameter, for making the line ticker you simply increase the value of the parameter line width related to tikzsetting.

  • To get unumbered theorem environment as explianed in this answer you need to add the command \theoremstyle{nonumberplain} before \newmdtheoremenv definition.

output

Here is the code:

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

\theoremstyle{nonumberplain}

\newmdtheoremenv[linewidth= 1pt,linecolor= white,%
leftmargin=40,rightmargin=40,innertopmargin=5pt,%
tikzsetting = { draw=blue, line width = 3pt,dashed,%
dash pattern = on 4pt off 3pt},%
splittopskip=\topskip,skipbelow=\baselineskip,%
skipabove=\baselineskip,ntheorem,roundcorner=5pt]{Cases}{Cases}[section]

\begin{document}
Some text.

\begin{Cases}
A theorem.
\end{Cases}
\end{document}

If you are defining several theorem environments which have some common parameters, you can setup default parameter using the command \mdfsetup{...} in the preamble and dont worry about duplicate definition of a parameter because the default one (the one in \mdfsetup{...}) will be overrided by the one in \newmdtheoremenv[...], at the same time default parameters that they weren't defined in the theorem definition will be inherited.

Here's an example:

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

\theoremstyle{nonumberplain}

%default parameters
\mdfsetup{linewidth= 2pt,linecolor= black,%
leftmargin=40,rightmargin=10,innertopmargin=5pt}

\newmdtheoremenv{theoremA}{theoremA}[section]

\newmdtheoremenv[linecolor= blue]{theoremB}{theoremB}[section]

\begin{document}
\begin{theoremA}
Using default parameters.
\end{theoremA}

\begin{theoremB}
Using default parameters but with a \textcolor{blue}{blue} line color.
\end{theoremB}
\end{document}

output example

Related Question