mdframed:设置全局环境

mdframed:设置全局环境

如何设置全球mdframed环境?

我会在序言中添加这样的内容吗:

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

但我希望能够通过以下方式添加标题

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

新的环境将会是这样的:

在此处输入图片描述

答案1

我不确定这是否是您所需要的,但您可以使用\newmdtheoremenv定义结构的可选参数:

\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}

在此处输入图片描述

如果不需要编号和特殊处理(如定理结构),那么可以说:

\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}

在此处输入图片描述

相关内容