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}

在此輸入影像描述

相關內容