mdframed 还是 mdframed 内部有阴影?

mdframed 还是 mdframed 内部有阴影?

我有一个mdframed环境,我想要另一个框架,只有背景颜色,在里面,但我不希望继承上述标题。

这就是我使用阴影环境的原因。我的问题是我无法将内shaded框与外框的内线对齐。

有没有一种方法可以让我完美地容纳两个盒子,并且没有空白并且一个盒子不会重叠?

\documentclass[9pt,twoside,openright,showtrims]{memoir} 
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{mathspec,xltxtra}
\usepackage{color, colortbl}
\usepackage[framemethod=TikZ]{mdframed}
\colorlet{shadecolor}{gray!10}

\newcounter{solved}[chapter]
\renewcommand{\thesolved}{\thechapter.\arabic{solved}}
\newenvironment{solved}[1][]{%
\refstepcounter{solved}
\begin{mdframed}[%
    frametitle={\textbf{\Large{SOLVED EXAMPLE} \thesolved}\ \\ #1},
    frametitlerule=true,
    frametitlerulewidth=1pt,
    frametitlerulecolor=black,
    innertopmargin=-0.7em,%
    innerleftmargin=0.4em,%,
    hidealllines=true,leftline=true,
    %frametitlebackgroundcolor=gray!70,
    linewidth=10pt,
    linecolor=gray!80,
    %fontcolor=white,%
    %backgroundcolor=gray!10
]%
}{%
\end{mdframed}
}

\begin{document}
\begin{solved}[Lorem ipsum dolor sit amet]
\begin{shaded}
Solve this one

\begin{enumerate}
 \item
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.  
 \item
 Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
\item
Velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
\end{enumerate}
\end{shaded}

\b{\Large{SOLUTION}}

\noindent
Velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
\end{solved}
\end{document}

答案1

您可以使用另一个样式mdframed来表示内部阴影区域。为此,定义如下样式

\mdfdefinestyle{style2}{frametitle={},innertopmargin=5pt,linecolor=blue!20,%
             linewidth=2pt,hidealllines=true,topline=true,backgroundcolor=gray!20}

并将其运用到内部mdframed环境中。

\documentclass[9pt,twoside,openright,showtrims]{memoir}
\usepackage{amsmath,amssymb,amsfonts}
%\usepackage{mathspec,xltxtra}
\usepackage{color, colortbl}
\usepackage[framemethod=TikZ]{mdframed}
\colorlet{shadecolor}{gray!10}

\newcounter{solved}[chapter]
\renewcommand{\thesolved}{\thechapter.\arabic{solved}}
\newenvironment{solved}[1][]{%
\refstepcounter{solved}
\begin{mdframed}[%
    frametitle={\hspace{0.5em}\textbf{\Large SOLVED EXAMPLE \thesolved}\ \\ \hspace*{0.5em}#1},
    frametitlerule=true,
    frametitlerulewidth=1pt,
    frametitlerulecolor=black,
    innertopmargin=0em,%
    innerleftmargin=0em,%,
    innerrightmargin=0em,
    hidealllines=true,leftline=true,
    %frametitlebackgroundcolor=gray!70,
    linewidth=10pt,
    linecolor=gray!80,
    %fontcolor=white,%
    %backgroundcolor=gray!10
]%
}{%
\end{mdframed}
}

\mdfdefinestyle{style1}{frametitle={},innertopmargin=0pt,
             linewidth=0.5em,linecolor=white,hidealllines=true,rightline=true,leftline=true,
             }
\mdfdefinestyle{style2}{frametitle={},innertopmargin=5pt,innerrightmargin=0.5em,%
             linewidth=2pt,linecolor=gray!20,hidealllines=true,topline=true,leftline=true,
             linewidth=0.4em,backgroundcolor=gray!20}

\begin{document}
\begin{solved}[Lorem ipsum dolor sit amet]
\begin{mdframed}[style=style2]
Solve this one

\begin{enumerate}
 \item
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
 \item
 Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
\item
Velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
\end{enumerate}
\end{mdframed}

\begin{mdframed}[style=style1]
{\bfseries\Large{SOLUTION}}

\noindent
Velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
\end{mdframed}
\end{solved}
\end{document}

在此处输入图片描述

相关内容