如何以theo
这种方式改变环境,使得内部mdframed
不会继承的风格theo
?
\documentclass[parskip=false,english,11pt]{ltxmdf}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{calc}
\usepackage{fourier-orns}
\usepackage{extarrows}
\usepackage{xcolor}
\usepackage{stmaryrd}
\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
\newcounter{examplecount}
\setcounter{examplecount}{0}
\renewcommand\thesubsection{}
\newcounter{theo}[section]
\newenvironment{theo}[1][]{%
\stepcounter{theo}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=red!20]
{\strut Aufgabe~\thetheo};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=red!20]
{\strut Exercise~\thetheo:~#1};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=red!20,%
linewidth=2pt,topline=true,
frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
\begin{mdframed}[]\relax%
}{\end{mdframed}}
\begin{document}
\begin{theo}[Header]
Outerframe
\begin{mdframed}[backgroundcolor=gray!20,roundcorner=1pt]
Innerframe
\end{mdframed}
\end{theo}
\end{document}
答案1
您必须单独定义一个样式并将其应用于内部框,例如
\mdfdefinestyle{style2}{frametitle={},innertopmargin=5pt,linecolor=blue!20,%
linewidth=2pt,topline=true,}
进而
\begin{mdframed}[style=style2,backgroundcolor=gray!20,roundcorner=1pt]
Innerframe
\end{mdframed}
代码:
\documentclass[parskip=false,english,11pt]{ltxmdf}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{calc}
\usepackage{fourier-orns}
\usepackage{extarrows}
\usepackage{xcolor}
\usepackage{stmaryrd}
\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
\mdfdefinestyle{style1}{innertopmargin=10pt,linecolor=red!20,%
linewidth=2pt,topline=true,
frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
\mdfdefinestyle{style2}{frametitle={},innertopmargin=5pt,linecolor=blue!20,%
linewidth=2pt,topline=true,}
\newcounter{examplecount}
\setcounter{examplecount}{0}
\renewcommand\thesubsection{}
\newcounter{theo}[section]
\newenvironment{theo}[1][]{%
\stepcounter{theo}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=red!20]
{\strut Aufgabe~\thetheo};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=red!20]
{\strut Exercise~\thetheo:~#1};}}%
}%
\begin{mdframed}[style=style1]\relax%
}{\end{mdframed}}
\begin{document}
\begin{theo}[Header]
Outerframe
\begin{mdframed}[style=style2,backgroundcolor=gray!20,roundcorner=1pt]
Innerframe
\end{mdframed}
\end{theo}
\end{document}
答案2
我也有同样的问题。事实证明,您只需将其作为第一个选项添加default
到内部 mdframed 的所有其他选项之前,如下所示:
\begin{mdframed}[default,backgroundcolor=gray!20,roundcorner=1pt]
Innerframe
\end{mdframed}
文档提到default
但没有提到您可以在之后添加其他选项。显然选项是相继应用的。