带 xcolor 的背景颜色框

带 xcolor 的背景颜色框

实现这一目标的最佳方法是什么?我可以定义一个解决方案环境,该环境将以 \med skip 开始,然后为框着色,直到我结束解决方案吗?

例子

答案1

![在此处输入图片描述

\documentclass{article}
%\usepackage{geometry}

\usepackage{enumitem}
\usepackage{tcolorbox}
\newtcolorbox{solutionbox}{
        colframe=cyan!20!white,
        colback =cyan!20!white,
        top=0mm, bottom=0mm, left=0mm, right=0mm,
        arc=0mm,
%
        fontupper=\color{blue!70!black},
        fonttitle=\bfseries\color{blue!70!black},
        title=Solution:
                        }
\begin{document}
\begin{solutionbox}
    \begin{enumerate}[leftmargin=*, nosep, label=(\alph*)]
\item $A\cup B=\{0,1,2,3,4,5,6,7,8\}$
\item $A\smallsetminus C = \{0,6 \} $
\item $B\smallsetminus A = B $
\item $B\cap C = \varnothing$
\item $C\smallsetminus B = C$
    \end{enumerate}
\end{solutionbox}
\end{document}

答案2

这是一个简单的解决方案(!),使用framedntheorem

\documentclass[11pt]{article}
\usepackage{amsfonts, amssymb}
\usepackage{framed}
\usepackage[svgnames]{xcolor}%
\usepackage[inline]{enumitem}
\usepackage[framed,thmmarks,thref, hyperref]{ntheorem}

\theoremheaderfont{\bfseries}
\theorembodyfont{\normalfont}
\theoremseparator{.}
\newtheorem{example}{Example}[section]
\colorlet{shadecolor}{LightBlue!60}
\def\theoremframecommand{\colorbox{shadecolor}}
\theoreminframepreskip{0.5ex}
\theoreminframepostskip{0.4ex}
\theoremprework{\color{NavyBlue}}
\theoremseparator{:}
\newshadedtheorem{sol}{Solution}
\usepackage{hyperref}%

\begin{document}
\setcounter{section}{1}
\setcounter{example}{2}
\begin{example}
  Suppose $ A = \{0,2,4,6,8 \}$, $ B = \{1,3,5,7 \}$ and $ C = \{2,8,4 \}$. Find: \\
  \begin{enumerate*}[label=(\alph*)]
    \item $ A ∪ B$
    \item $ A\smallsetminus C $
    \item $ B\smallsetminus A $
    \item $ B ∩ C $
    \item $ C\smallsetminus B$.
  \end{enumerate*}
  %
\end{example}
\begin{sol}
  \begin{enumerate}[label=(\alph*), wide
      =0pt]

    \item $ A ∪ B = \{0, 1,2,3,4,5,6, 7,8 \} $
    \item $ A\smallsetminus C = \{0,6 \} $
    \item $ B\smallsetminus A = B $
    \item $ B ∩ C = ∅$
    \item $ C\smallsetminus B = C$.
  \end{enumerate}
\end{sol}

\end{document} 

在此处输入图片描述

相关内容