Why Isn’t topsep Working for itemize in a longtable?
At a glance
- 1. Use a paragraph column
Put the list in a p-type column, such as p{width}; ordinary l, c, and r columns are not for multi-line content.
- 2. Set the list spacing
Use enumitem’s topsep for space around the list, and partopsep for extra space when it starts a new paragraph.
- 3. Check the right gap
Use itemsep between items; table row spacing and cell padding are separate controls.
- 4. Handle cell edges
For exact padding at a cell boundary, set that space explicitly rather than relying on list glue.
topsep is the list parameter for vertical space before and after an itemize environment. In a longtable, it can be hard to tell whether that space is taking effect because table rows, cell padding, and list spacing are separate things.
The usual fix is to put the list in a paragraph-style column and set the list parameters with enumitem. Then check whether the space you want is around the list, between its items, or between the cell content and the table rule.
Use a paragraph-style column
A list needs room to form paragraphs and break lines. Use a p{...} column (or another paragraph-capable column), not l, c, or r. Those ordinary columns are meant for single-line cell content and can produce confusing layout when given a list.
This complete example sets topsep explicitly and also specifies the other common list-spacing parameters:
\documentclass{article}
\usepackage{longtable}
\usepackage{enumitem}
\begin{document}
\begin{longtable}{|p{0.8\linewidth}|}
\hline
Introductory text in the cell.
\begin{itemize}[
leftmargin=*,
topsep=8pt,
partopsep=0pt,
itemsep=2pt,
parsep=0pt
]
\item First item.
\item Second item, which may wrap onto another line.
\end{itemize}
Text after the list.\\
\hline
\end{longtable}
\end{document}
Here, topsep=8pt requests space above and below the list. Because the list is between paragraphs, those gaps are easier to distinguish from the table boundary. Change the value to adjust the list’s surrounding space.
Check which spacing you mean
These parameters control different parts of the layout:
| Parameter | What it controls |
|---|---|
topsep | Space above and below the list |
partopsep | Additional space when a list starts after a paragraph break |
itemsep | Space between list items |
parsep | Space between paragraphs within an item |
\arraystretch | Height of table rows; it does not set list spacing |
\tabcolsep | Horizontal padding at the sides of table cells |
For example, if the items are too far apart but the list’s outer margins look right, reduce itemsep, not topsep. If you want less vertical space between table rows, adjust the table layout separately; changing topsep is not a reliable way to do that.
You can set defaults for every itemize list with \setlist[itemize]{...} in the preamble, or set options on one list as in the example. Per-list options are useful for testing whether a global setting is being overridden.
When the list begins at the top of a cell
If the list is the first material in a cell, its top margin is right at the cell boundary. The row’s height, strut, or a nearby rule can make the result look as though topsep had no effect. For precise padding at that boundary, set it explicitly and avoid counting the same space twice. For example, set topsep=0pt and partopsep=0pt for that list, then put \vspace{6pt} before it in the cell to request 6 pt of top padding. Setting partopsep to zero prevents its additional contribution if the list follows a paragraph break. The starred form of \vspace is for preserving space at a page break; it is not generally needed just because the material is at a cell boundary.
Likewise, space after the list at the bottom of a cell may be affected by the row boundary. Add explicit bottom padding if that is the gap you need, and check how the following row or rule is formed. The exact adjustment depends on whether the list is the first or last content in the cell.
Common mistakes
- Using
itemsepto change the space around the whole list. It changes the gaps between items, not the list’s outer spacing. - Using an
l,c, orrcolumn for a multi-line list. Switch to ap{...}column so the cell can contain paragraph material. - Changing
\arraystretchto fix list margins. It affects table row height, notenumitem’stopsepsetting. - Setting both
topsepand manual padding without checking the total. The resulting gap includes both contributions, so it may be larger than intended. - Assuming a global setting must be the one in effect. A local list option or another list configuration may override it; test with explicit options on the affected list.
Start by setting topsep, partopsep, itemsep, and parsep explicitly on the list. Then adjust table padding only if the remaining problem is at a cell or row boundary.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.