4

I sat down tonight to try to define a simple list that looks something like this:

1:23
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
  commodo ligula eget dolor. Aenean massa. Cum sociis natoque
  penatibus et magnis dis parturient montes, nascetur ridiculus
  mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,
  sem.

  Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
  aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
  imperdiet a, venenatis vitae, justo.

So you can see the requirements are fairly simple. The item label should not be indented at all, but should start precisely at the left margin. It should be followed by a line break. After the line break comes the item body. This shall be indented - the entire paragraph that is - and all following paragraphs by the same amount. However, there should be no paragraph commencing indent, all paragraphs should start on a blank line. In the example, the indentation is two spaces, but I think a quad would do nicely.

As possible complications, my document as a whole follows the above paragraphing style, with a blank line between paragraphs and no initial indentation. Secondly, I would like to format the item label in typewriter text.

So, clearly, I thought, I need a list environment.

\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}

\begin{document}

\begin{list}{}{}
  \item[1:23]
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
  commodo ligula eget dolor. Aenean massa. Cum sociis natoque
  penatibus et magnis dis parturient montes, nascetur ridiculus
  mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,
  sem.

  Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
  aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
  imperdiet a, venenatis vitae, justo.
\end{list}

\end{document}

But I got totally bamboozled trying to work out what to put as the second argument because the actual indentation of the label doesn't seem to be defined itself. Instead the \leftmargin is defined, with the item label shunted along relative to it by other relevant parameters which I couldn't decipher how to tweak.

Any additional explanation would be much appreciated.

  • 1
    You should have a look on the enumitem package, in my point of view – user31729 Jun 9 '16 at 19:46
3

You do want a list.

\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper,showframe} % showframe just for the example
\usepackage[parfill]{parskip}

\newenvironment{points}
 {\begin{list}{}{\leftmargin=1em\labelwidth=\leftmargin\labelsep=0pt}%
  \newcommand{\point}[1]{\item[##1]\mbox{}\\*\ignorespaces}}
 {\end{list}}

\begin{document}

\begin{points}

\point{1:23}
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
  commodo ligula eget dolor. Aenean massa. Cum sociis natoque
  penatibus et magnis dis parturient montes, nascetur ridiculus
  mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,
  sem.

  Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
  aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
  imperdiet a, venenatis vitae, justo.

\point{22:333}
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
  commodo ligula eget dolor. Aenean massa. Cum sociis natoque
  penatibus et magnis dis parturient montes, nascetur ridiculus
  mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,
  sem.

\end{points}

\end{document}

enter image description here

  • This seems like a really good answer! Is it possible to make the item labels typewriter text? (looks like it should be fairly easy, but I don't usually get as deep as needing two ##s so I'm not too sure! – Au101 Jun 12 '16 at 22:46
  • 1
    \newcommand{\point}[1]{\item[\texttt{##1}]\mbox{}\\*\ignorespaces} – egreg Jun 12 '16 at 23:00
3

This seems to be fairly close to what you want:

\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[a4paper,margin=1.8cm]{geometry}
\usepackage{enumitem}
\usepackage{lipsum}
\usepackage{showframe}

\newlist{simple}{description}{1}
\setlist[simple]{leftmargin=4mm,   % indentation of paragraphs
                 font=\texttt,     % typewritter text for labels
                 style=nextline,   % start new line for "wide" labels
                 labelindent=0pt,  % the remaining settings make the
                 itemindent=-1.5mm,% width of the labels, with a small hack
                                   % to drag the label back to the margin
                 listparindent=0pt,
                 labelwidth=0pt,
}

\begin{document}

   \begin{simple}
     \item[1:23]\lipsum[1-2]
     \item[1:24]\lipsum[1-2]
   \end{simple}

\end{document}

I have used showframe to show where the margins are. Note the small hack using itemindent=-1.5mm which for some reason is needed to get the label back to the margin.

enter image description here

0

In the end I gave up on using a list environment, and instead defined a new command using boxes. This works for me, but feels hack-y.

\newlength{\currentparskip}
\setlength{\currentparskip}{\parskip}
\newcommand{\point}[2]{\texttt{#1} \\
  \makebox[1em]{}\begin{minipage}[t]{\dimexpr\textwidth-1em}%
    \setlength{\parskip}{\currentparskip}%
    #2%
  \end{minipage}%
}

I found using a 1em wide box before the minipage necessary, because \hfill didn't seem to do anything.

It seems to do the job, though:

\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{showframe}

\newlength{\currentparskip}
\setlength{\currentparskip}{\parskip}
\newcommand{\point}[2]{\texttt{#1} \\
  \makebox[1em]{}\begin{minipage}[t]{\dimexpr\textwidth-1em}%
    \setlength{\parskip}{\currentparskip}%
    #2%
  \end{minipage}%
}

\begin{document}

\point{1:23}{%
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
  commodo ligula eget dolor. Aenean massa. Cum sociis natoque
  penatibus et magnis dis parturient montes, nascetur ridiculus
  mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,
  sem.

  Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
  aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
  imperdiet a, venenatis vitae, justo.
}

\point{1:24}{%
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean
  commodo ligula eget dolor. Aenean massa. Cum sociis natoque
  penatibus et magnis dis parturient montes, nascetur ridiculus
  mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis,
  sem.

  Nulla consequat massa quis enim. Donec pede justo, fringilla vel,
  aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut,
  imperdiet a, venenatis vitae, justo.
}

\end{document}

enter image description here

Mind you, I do get

Overfull \hbox (30.0pt too wide) in paragraph at lines 29--30

warnings.

  • I prefer the enumitem approach:) Although, I notice that the showframe shows a small indentation of the labels Not sure why this happens. – Andrew Jun 12 '16 at 21:48
  • @Andrew It has to be said, this produces erratically bad vertical spacing. In the end, I just relaxed my requirement for the item body to begin on the line below and went with \newcommand{\tstamp}[1]{\texttt{#1}} \newcommand{\point}[2]{\tstamp{#1}% \begin{list}{}{\setlength{\leftmargin}{1em}}% \item #2% \end{list}% } (sorry, I know that will look ugly in the comments). This allows me better control over the left margin and means the list item is not indented (or scarcely). One way or another, it ended up giving the output I most preferred anyway – Au101 Jun 12 '16 at 21:54
  • @Andrew P.S. I've already upvoted and I'm very grateful for the help. I'm gonna leave the question officially unsolved though, if that's okay, because you didn't quite meet all the requirements and neither did I, and if anybody can I'd be very interested to see (and probably use) their efforts – Au101 Jun 12 '16 at 21:56
  • I've just adjusted my solution to place the label on the margin. Have only just seen your comment about the bad vertical spacing.Not sure what to do about this, although nor can I reproduce it... – Andrew Jun 12 '16 at 22:01
  • @Andrew Sorry I meant the bad vertical spacing was with my attempted solution, hence my decision to just tweak the requirements – Au101 Jun 12 '16 at 22:43

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.