0

When compiling the following code with pdflatex

\documentclass{scrartcl}

\begin{document}
\hbox{\begin{itemize}
\item Lorem Ipsum
\end{itemize}}
\end{document}

I get the error

! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                 
l.5 \item L
           orem Ipsum

What is the reason for this? Can this be solved such that it sets in the expected manner? I already figured out that wrapping a minipage around the itemize inside the hbox works but it depends on being able to determine the correct width of the minipage – which would be \textwidth in the MWE but not in my actual usecase.

1
  • 4
    You can't use itemize in a \hbox, itemize needs to be able to enter vertical mode, which it can't in a horizontal box, you have to use it in a minipage or \parbox. But you could fake an itemize like appearance with a tabular rather easily. – Skillmon Jul 1 '20 at 19:25
3

I'm not sure what your aim is, but you can perhaps use varwidth.

\documentclass{scrartcl}
\usepackage{varwidth}

\begin{document}

\fbox{% just to show that this grows up to what's needed
\begin{varwidth}{\textwidth}
Some text
\begin{itemize}
\item Lorem Ipsum
\item Some longer lorem
\end{itemize}
\end{varwidth}%<--- just because we're in an \fbox
}

\end{document}

The \fbox around the varwidth is just to show the boundaries of the built box; varwidth builds a minipage.

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.