As shown by my MWE, I have two small issues that I'd like to get assistance with in fixing.
First off: When I start two problem
environments one after another without a blank space between the \end{problem}
and \begin{problem}
, my second problem goes in the right margin instead of beneath the previous one.
Secondly, I'd like it, if possible, to not have a blank space (as shown in the 4th problem) if I choose to omit a problem description. I'd like to do as in problem 5, but as it is now, the first letter shows up incorrectly as the problem title.
\documentclass{article}
\usepackage{environ}
\usepackage{array}
\newcounter{problem}
\setcounter{problem}{0}
\newlength{\mylen}
\settowidth{\mylen}{100}
\NewEnviron{problem}[1]{%
\stepcounter{problem}\noindent
\begin{tabular}{m{\mylen}p{\dimexpr\linewidth-\mylen-3\tabcolsep\relax}@{}}
\arabic{problem}. & \textbf{#1}\\[1mm]
& \BODY
\end{tabular}}%
\begin{document}
\begin{problem}{foobar}
test
\end{problem}
\begin{problem}
test
\end{problem}
\bigskip\bigskip\bigskip
\begin{problem}{foobar}
test
\end{problem}
\begin{problem}{}
test2
\end{problem}
\begin{problem}
test
\end{problem}
\end{document}