When writing my question about various approaches to creating loops, I stumbled across the following anomaly


\foreach \x in {apples, oranges,pears,,peaches}
  { \item \x }


which results in:

enter image description here

This is can be duplicated by just writing:

  \item apples
  \item oranges
  \item pears
  {\item }
  \item peaches

I cannot think of a reason why you would want to write {\item }. But, since I'm a teacher writing exams and quizzes, I often may want to use an \item with no following text.

What's happening here that the grouping is causing the \item not to render the bullet?


A list item is set in a way similar to an inline heading. The item text is set in a box which is inserted as part of the \everypar handling of the following paragraph text. If you insert a group around the item the box containing the label is discarded at the group end before it is used.

| improve this answer | |
  • I'm still a bit baffled. If I understand what you're saying, I would think that there should also not be any space left between pears and peaches. – A.Ellett Oct 27 '13 at 17:47
  • So, I could get around this issue by adding a \strut immediately after \item in the pgffor loop. Are there any reasons why this might not be an ideal solution? – A.Ellett Oct 27 '13 at 17:50
  • @A.Ellett \mbox{} should be sufficient. Or a loop that doesn't group. – egreg Oct 27 '13 at 20:06
  • You'd have to trace exactly what happens but basically the vertical space is added as the inter-item space are set at the beginning of the list so the settings are not lost by the group, but the item text is set locally each time in case it is set as \item[zzz] and the group means the box with the label is empty by the time it is used. – David Carlisle Oct 27 '13 at 23:36

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.