This question is closely related to Command for switching exercise styles.
In the following problem the following code was deviced
\newcommand{\Problem}{
\refstepcounter{problem}
\vspace{3.25ex plus 1ex minus .2ex}\par
\noindent\makebox[0pt][r]{\protect\fbox{\UNIproblemnumber}\qquad}%
\par\vskip-\baselineskip\vskip-\parskip
}
Which removes the vertical spacing after the makebox command. Something like
\Problem
\lipsum[75]
Produces
Which is great. The problem arises when an enumerate environment directly follows
A way to remedy this is to insert \vspace{-\topsep}
manually between \Problem
and the enumerate
environment. However, using this globally messes us the spacing between \Problem
and normal paragraphs.
- Question: Is there a way to reduce the spacing between
\Problem
andenumerate
without effecting the spacing between\Problem
and normal paragraphs?
Code
\documentclass{article}
\usepackage{lipsum}
\usepackage{enumitem}
\usepackage{xcolor}
\newcounter{problem}
\newcommand{\UNIproblemnumberformat}{\bfseries\color{blue}}
\newcommand{\UNIproblemnumber}{\UNIproblemnumberformat\arabic{problem}}
\newcommand{\Problem}{
\refstepcounter{problem}
\vspace{3.25ex plus 1ex minus .2ex}\par
\noindent\makebox[0pt][r]{\protect\fbox{\UNIproblemnumber}\qquad}%
\par\vskip-\baselineskip\vskip-\parskip
}
\setlength\parindent{0pt}
\begin{document}
\Problem
\begin{enumerate}
\item
\end{enumerate}
\Problem
\lipsum[75]
\begin{enumerate}
\item Hi
\end{enumerate}
\lipsum[66]
\end{document}