1

I would like to intersperse my text with some shaded assignments for the reader to try to do. I'd also like to enumerate these with numbers to keep track of them. My current code is as follows, but I don't like the indent that occurs as part of the enumerate package. I know I can reduce it using enumitem and \setlist[enumerate]{leftmargin=*}, but I don't quite like that either. It doesn't completely remove the enumerate.

I'd really like a way of numbering a series of assignments interspersed in the text, without interrupting the layout of the surrounding text.
Any thoughts?

\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{framed}
\usepackage[dvipsnames]{xcolor}
\definecolor{shadecolor}{gray}{0.75}
\begin{document}
\Blindtext
\begin{enumerate}
\begin{shaded}
\item This is an assigment.
\end{shaded}

\Blindtext

\begin{shaded}
\item This is a second assignment.
\end{shaded}
\Blindtext
\begin{shaded}
\item This is a third assignment
\end{shaded}
\end{enumerate}
\Blindtext
\end{document}
1

Here is a solution: I define an assignment environment, based on the snugshade* environment from framed.

\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{framed}
\usepackage[dvipsnames]{xcolor}
\colorlet{shadecolor}{lightgray!35!}
\newcounter{assignment}
\newenvironment{assignment}{%
\refstepcounter{assignment}\setlength\OuterFrameSep{2pt plus 1pt}\setlength\fboxsep{5pt}\begin{snugshade*}\hspace*{-\dimexpr\labelsep+\fboxsep\relax}\textbf{\theassignment.}}%
{\end{snugshade*}}

\begin{document}

\Blindtext[2][1]
\begin{assignment}
This is an assigment. \label{ass-a}
\end{assignment}

\begin{assignment}
This is an assignment. This is an assignment. This is an assignment. This is an assignment.
\end{assignment}

\Blindtext[1][1]
\begin{assignment}
This is another assignment,  different from assignment \ref{ass-a}. 
\end{assignment}
\Blindtext

\end{document} 

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.