5

I am writing many exercise Sheets for a course in a university. The captions for every Problem is simply: “Problem 1”, “Problem 2” and so on… Now I came up with the idea, to generate this captions automatically via

\begin{enumerate}
\renewcommand{\labelenumi}{\textbf{Problem \arabic{enumi}}}
\setlength{\itemindent}{32pt}
\item Lorem ipsum…
\end{enumerate}

But my problem now is that “Lorem ipsum…” is not in a new line under the generated caption. \\ and \newline do not work. Has anybody an idea to handle this issue?

4
  • \let\olditem\item \def\item{\olditem\leavevmode\par}
    – yo'
    Oct 30, 2014 at 21:00
  • 1
    tex.stackexchange.com/questions/176263/… maybe this is a good idea? Else you could try \item ~\\ Lorem Oct 30, 2014 at 21:11
  • Thanks for the Link. Now I am using: \newcounter{problems} \def\Problem{\stepcounter{problems}\vspace{2em}\textbf{Problem \arabic{problems}}\\\\ }
    – Matthias
    Oct 30, 2014 at 21:27
  • Welcome to TeX.SE. Oct 30, 2014 at 21:45

1 Answer 1

5

Using the enumitem package you can define a custom alignment of the label so that it takes the full line width:

enter image description here

Notes:

  • The showframe package was used just to show the page margins. It is not needed in your actual use case.

Code:

\documentclass{article}
\usepackage{enumitem}
\usepackage{showframe}

\SetLabelAlign{LeftAlignFullWidth}{\makebox[\dimexpr\linewidth+\labelwidth\relax][l]{#1}}

\begin{document}
\begin{enumerate}[label={\bfseries Problem \arabic*}, align=LeftAlignFullWidth]
\item  Lorem ipsum one
\item  Lorem ipsum two
\end{enumerate}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .