9

I want to change the border color of the mdframe box. By default it take black.

\documentclass{article}
\usepackage{xcolor}
\usepackage{mdframed}
\newtheorem{mdtheorem}{Theorem}
 \newenvironment{theorem}%
 {\begin{mdframed}[backgroundcolor=lightgray]\begin{mdtheorem}}%
 {\end{mdtheorem}\end{mdframed}}
 \begin{document}
 \begin{theorem}
Sample
\end{theorem}
 \end{document} 
  1. My Default output is, enter image description here

  2. My Expected output is, enter image description here

Any one suggest me the correct. I am new to LaTeX.

Torbjørn T.
  • 206,688
PSK
  • 1,032

1 Answers1

18

The correct way to define a new theorem environment with mdframed is through the \newmdtheoremenv command.

The option to change the color of the frame border is linecolor. If you also want to change the width of the border, use the option linewidth.

If you then want to show only the bottom of the border, set to false the options topline, rightline, and leftline.

Here is a MWE:

\documentclass{article}
\usepackage{xcolor}
\usepackage{mdframed}

\newmdtheoremenv[%
  backgroundcolor=lightgray,
  linecolor=red!60!black,
  linewidth=2pt,
  topline=false,
  rightline=false,
  leftline=false]{theorem}{Theorem}

\begin{document}
\begin{theorem}
Sample
\end{theorem}
\end{document} 

Output:

enter image description here

karlkoeller
  • 124,410