[Tex/LaTex] Tabstop and line wrap inside itemize

itemizeline-breakingliststabbing

What I am trying to achieve:

some list:
- some text
- Def.:  Some long text which should both automatically wrap to a new line
         and be tabbed as displayed here.
- some sublist
  * with the new counter
  * Def.:  same as above, but note that the counter matches the list level

This answer comes closest, but if used inside some other list, the counter (I mean the bullet point symbol) doesn't match, and the spacing before/after is larger. Also, I do not need the tabbing to work across multiple bullet points (as opposed to the original question), which might simplify things.

I hope my question is clear. Please let me know if not! It's not that I'm too lazy for a MWE, I just couldn't get anywhere close to what I want (other than a simple itemize). Thanks!

(Just to clarify: I do not want to specify any bullet point styles myself, it's just that they change with increasing list levels.)

Best Answer

I am not sure you have specified all requirements, but here are three ways to tackle this. The first is based on a tabular enviornment and will not allow new paragrahps in the indented text. The second uses minipage and the indented text may now be broken into paragraphs. The third is a suggestion of @egreg to use the enumitem package and a description list; this will break over pages, but does not generalise to further tabstops if you need them.

First the first two solutions:

Sample output

\documentclass{article}

\newcommand*{\tabulardef}[3]{\begin{tabular}[t]{@{}lp{\dimexpr\linewidth-#1}@{}}
    #2&#3
  \end{tabular}}

\newlength{\standardparindent}
\setlength{\standardparindent}{\parindent}
\newenvironment{minipdef}[2]{\makebox[#1]{#2\ \hfill}%
  \begin{minipage}[t]{\dimexpr\linewidth-#1}%
  \setlength{\parindent}{\standardparindent}\noindent\ignorespaces}%
{\end{minipage}}

\begin{document}

\subsection*{Tabular example}

Some list:
\begin{itemize}
\item Some text which is long and wraps on to the next line as usual
  as this is demonstrating
\item \tabulardef{2cm}{Definition}{Some long text which should both
  automatically wrap to a new line and be tabbed as displayed here.}
\item Some sublist
  \begin{itemize}
  \item with the new counter and some text which is long and wraps on
    to the next line as usual as this is demonstrating
  \item \tabulardef{2cm}{Definition}{Some long text which should both
    automatically wrap to a new line and be tabbed as displayed here.}
  \end{itemize}
\end{itemize}

\subsection*{Minipage example}

Some list:
\begin{itemize}
\item Some text which is long and wraps on to the next line as usual
  as this is demonstrating
\item \begin{minipdef}{2cm}{Definition}
    Some long text which should both automatically wrap to
    a new line and be tabbed as displayed here.

    This also contains new paragraphs with long text for demonstration
    purposes.
  \end{minipdef}
\item Some sublist
  \begin{itemize}
  \item with the new counter and some text which is long and wraps on
    to the next line as usual as this is demonstrating.
\item \begin{minipdef}{2cm}{Definition}
    Some long text which should both automatically wrap to
    a new line and be tabbed as displayed here.

    This also contains new paragraphs with long text for demonstration
    purposes.
  \end{minipdef}
  \end{itemize}
\end{itemize}

\end{document}

In the tabular case, there is a first column that is left aligned to contain the heading, and the subsequent text is in a p column. Extra spacing before the first and after the last columns has been removed with @{} specifications.

The minipage case, sets the heading in a box first and then starts a minipage. I have set things up so that subsequent paragraphs have the standard paragraph indent of the main text; without some indents it is hard to see where they begin.

Now the third solution with enumitem:

Sample enumitem output

\documentclass{article}

\usepackage{enumitem}

\newlist{deflist}{description}{2}
\setlist[deflist]{labelwidth=2cm,leftmargin=!,font=\normalfont}

\begin{document}
Some list:
\begin{itemize}
\item Some text which is long and wraps on to the next line as usual
  as this is demonstrating
\item
  \begin{deflist}
  \item[Definition]Some long text which should both automatically wrap
    to a new line and be tabbed as displayed here.
  \end{deflist}
\item Some sublist
  \begin{itemize}
  \item with the new counter and some text which is long and wraps on
    to the next line as usual as this is demonstrating
  \item
    \begin{deflist}
    \item[Definition]Some long text which should both automatically
      wrap to a new line and be tabbed as displayed here.

      This also contains new paragraphs with long text for
      demonstration purposes.
    \end{deflist}
  \end{itemize}
\end{itemize}

\end{document}