General[Solved] Force a linebreak in label of item / list envir...

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Reset
Posts: 11
Joined: Thu Apr 26, 2007 1:20 pm

[Solved] Force a linebreak in label of item / list envir...

Post by Reset »

I have no clue how to force a line break in the item label of an itemize / list / description environment or a proper workaround for getting the same result, hopefully somebody has. What I wanna do:

\begin{list}
\item[forcehere a \\ linebreak] Some text right of the label
\item[another label] Some other text

\end{list}

Latex just ignores all kind of unproper behaviour in a list environment like \\ or \linebreak.


Thanks a lot for help!
Last edited by Reset on Fri Jan 02, 2009 12:23 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

[Solved] Force a linebreak in label of item / list envir...

Post by Juanjo »

The optional argument of \item is typeset in horizontal mode, so ignoring line breaks. It happens the same thing, for example, inside \mbox or \makebox. Try: \mbox{force here a \\ linebreak}

Consequently, you have to put the argument of \item inside a \parbox, which admits line breaks:

Code: Select all

\begin{description}
  \item[{\parbox[t]{0.2\linewidth}{force here \\ a linebreak}}] Some text right of the label
  \item[another label] Some other text
\end{description}

Adapt the width of \parbox to your needs. Observe that, whenever you use the first optional argument of \parbox ([t] in this case), you have to enclose \parbox in braces. Remember that, inside an optional argument, brackets cannot directly appear, but "protected" by braces, that is, instead of \item[... [...]...], one has to write \item[{...[...]...}]
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Reset
Posts: 11
Joined: Thu Apr 26, 2007 1:20 pm

Re: Force a linebreak in label of item / list environment

Post by Reset »

Thanks dude,

your example works!

One addition: I have to write the item content also in a parbox, or the linebreak in the item-label affects also the item content.

For example:

\item[{\parbox[t]{0.2\linewidth}{force here \\ a linebreak}}] \parbox[t]{1\linewidth}{Some text right of the label}
Post Reply