3

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.)

  • How do you want to format long items that are not definitions? – Andrew Swann Jun 27 '13 at 16:26
  • @AndrewSwann I was planning on leaving them just as plain items in an itemize environment, i.e. with automatic line wrapping, some inline math, etc. Does that answer your question? – Bernd Jun 27 '13 at 16:32
5

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}
| improve this answer | |
  • 1
    Why not using a nested list for the definition? With enumitem it should be simple. – egreg Jun 28 '13 at 9:18
  • @egreg Such a solution added, but it doesn't extend to multiple tabstops. Image upload seems to be broken at the moment. Will fix the image soon. – Andrew Swann Jun 28 '13 at 9:42
  • 1
    I don't understand what "multiple tab stops" should be. I'm afraid the OP is too much influenced by “other systems”. ;-) – egreg Jun 28 '13 at 9:44
  • Sorry for not having made my requirements sufficiently clear, and @egreg I didn't mean to ask for a "MS Word-like behaviour of TeX"... The third solution looks precisely like what I was looking for (no need for multiple tab stops), yet with simple code. Thanks so much for this! – Bernd Jul 1 '13 at 7:17
  • Also I have to add that it's only through this solution that I just learned about the description environment... So thanks again! – Bernd Jul 1 '13 at 7:45

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.