I am creating teaching notes with examples and solutions. At the begining of the course, I provide to the students the lecture notes with the examples but blank solutions so they can fill the box during class as I do the example in class. After the class I upload the examples with solutions.
I am planing to do that with the mdframed
package. I define my mdframed
and write the exercise question, then I add a solution (exsolution) environment within the mdframed
which I set the color to be white when I do not want the students to see the solutions or black when I want them to see the solutions.
The problem comes with page breaks where the color in the solution does not follow after the page break. Any feedback?
I am adding an example when I set the solution color \ColourOfSolutions
to be white:
\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[framemethod=TikZ]{mdframed}
\setlength\parskip{\baselineskip}
\usepackage{lipsum}% just to generate text for the example
\newcounter{example}
\renewcommand{\theexample}{\arabic{example}}
\newcommand{\ColourOfSolutions}{white}
\mdfdefinestyle{example}{%
linecolor=black,
outerlinewidth=1.5pt,
%bottomline=false,
%leftline=false,rightline=false,
skipabove=\baselineskip,
skipbelow=\baselineskip,
frametitle=\mbox{},
fontcolor=black
}
\newmdenv[%
style=example,
settings={\global\refstepcounter{example}},
frametitlefont={\bfseries Example~\theexample\quad},
]{example}
\newenvironment{exsolution}{\color{\ColourOfSolutions}}
\begin{document}
\lipsum[1]
\begin{example}
\lipsum[3]
\begin{exsolution}
\lipsum[4]
\lipsum[5]
\end{exsolution}
\end{example}
\end{document}
Please find here the image of what I get. Please check that the solution is white, does not appear, in the first page but appears again (the last part of the solution) in the second page. changing the \ColourOfSolutions
to black would illustrate this better:
I have seen many cases of people working with examples and solutions but I have not seen anything similar.
lualatex
, you could use\usepackage{luacolor}
and the colour stack will be maintained during pagebreakings – user31729 Sep 22 '15 at 15:18pdfcol
package, but it does not work (I'll try to figure out) – user31729 Sep 22 '15 at 15:27lualatex
would also be nice – Denis Sep 22 '15 at 16:07mdframed
? – 71GA Dec 3 '16 at 18:11