I'm trying to write a collection of problems and their solutions for my course's textbook. I've created an exercise environment. I'm currently using the mdframed
package to create a leftbar that spans the exercise descriptions.
Here are some of my issues and questions:
- Is it possible to create an exercise environment like mine so that "Exercise ---" appears on the same line as the exercise description (so no line breaks)?
- Should the leftbar in my example be changed any? Does it go too far above/below the text? It seems like the bar goes farther above the text than it does below the text.
How would I change my example so that instead of a leftbar, the entire exercise environment (not including the solutions) is shaded a light gray?
\documentclass[11pt]{article} \usepackage{amsmath,amssymb,amsfonts} \usepackage{color, linegoal} \usepackage{amsthm,array} \usepackage[framemethod=tikz]{mdframed} \usepackage[margin=1.2in]{geometry} % Exercise environment \definecolor{ExerciseColor}{gray}{0.65} \newenvironment{exercise}[1] {\mdfsetup{ skipabove=\topsep, skipbelow=\topsep, innertopmargin=0pt, innerbottommargin=4pt, leftmargin=-13pt, splitbottomskip=0ex, splittopskip=0ex, topline=false, leftline=true, bottomline=false, rightline=false, innerrightmargin=0pt, innerlinewidth=2pt, font=\normalfont, frametitle={\textbf{Exercise #1.}}, linecolor=ExerciseColor, } \begin{mdframed}% } {\end{mdframed}} % Solution environment \newenvironment{solution}{\begin{proof}[\itshape Solution]}{\end{proof}} \begin{document} \title{Title} \author{Author} \date{\today} \maketitle \section*{\centering \bfseries \S 1.3 Exercises} \begin{exercise}{1.3.1} Here is an exercise. Here is an exercise. Here is an exercise. Here is an exercise. Here is an exercise. Here is an equation: \[ a + b = c. \] Here is an exercise. \end{exercise} \begin{solution} Here is my solution. Here is an equation: \[ 1+2 = 3. \] Here is my solution. \end{solution} \begin{exercise}{1.3.5} Here is an exercise. Here is an exercise. Here is an exercise. Here is an exercise. Here is an exercise. Here is an equation: \[ a + b = c. \] Here is an exercise. \end{exercise} \begin{solution} Here is my solution. \end{solution} \end{document}