3

What is the best way to achieve this? Could I define a solution environment that will start with a \med skip and then color the box until I end the solution?

Example

1
  • 2
    package tcolorbox?
    – Zarko
    Commented May 29, 2017 at 22:49

2 Answers 2

7

![enter image description here

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

Here is an easy solution (!) with framed and ntheorem:

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

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .