3

I'm trying to remove the vertical space above/below \itemize lists that appear in a \longtable. That is, I'd like these lists to all align to the top of their cells:

bad example

Answers to similar versions of this problem abound (see here, here, and here, for example). All the solutions involve editing the table by hand, adding various \vspace or other commands.

I am generating my table from a Markdown file with pandoc, though, have have no control over the table output, so modifying the resulting table isn't possible. Here's a MWE.

Given this Markdown file:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 

: Sample grid table.

+---------------+---------------+--------------------+
| Fruit         | Price         | Advantages         |
+===============+===============+====================+
| Bananas       | $1.34         | - built-in wrapper |
|               |               | - bright color     |
+---------------+---------------+--------------------+
| Oranges       | $2.10         | - cures scurvy     |
|               |               | - tasty            |
+---------------+---------------+--------------------+

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

- Don't
- mess
- with
- this
- list
- though

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.

… which gets converted to this TeX file with pandoc -s -V documentclass=memoir blah.md -o blah.tex:

\documentclass[]{memoir}

\usepackage{longtable,booktabs}

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua.

\begin{longtable}[c]{@{}lll@{}}
\caption{Sample grid table.}\tabularnewline
\toprule
\begin{minipage}[b]{0.20\columnwidth}\raggedright\strut
Fruit
\strut\end{minipage} &
\begin{minipage}[b]{0.20\columnwidth}\raggedright\strut
Price
\strut\end{minipage} &
\begin{minipage}[b]{0.27\columnwidth}\raggedright\strut
Advantages
\strut\end{minipage}\tabularnewline
\midrule
\endfirsthead
\toprule
\begin{minipage}[b]{0.20\columnwidth}\raggedright\strut
Fruit
\strut\end{minipage} &
\begin{minipage}[b]{0.20\columnwidth}\raggedright\strut
Price
\strut\end{minipage} &
\begin{minipage}[b]{0.27\columnwidth}\raggedright\strut
Advantages
\strut\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.20\columnwidth}\raggedright\strut
Bananas
\strut\end{minipage} &
\begin{minipage}[t]{0.20\columnwidth}\raggedright\strut
\$1.34
\strut\end{minipage} &
\begin{minipage}[t]{0.27\columnwidth}\raggedright\strut
\begin{itemize}
\tightlist
\item
  built-in wrapper
\item
  bright color
\end{itemize}
\strut\end{minipage}\tabularnewline
\begin{minipage}[t]{0.20\columnwidth}\raggedright\strut
Oranges
\strut\end{minipage} &
\begin{minipage}[t]{0.20\columnwidth}\raggedright\strut
\$2.10
\strut\end{minipage} &
\begin{minipage}[t]{0.27\columnwidth}\raggedright\strut
\begin{itemize}
\tightlist
\item
  cures scurvy
\item
  tasty
\end{itemize}
\strut\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi
ut aliquip ex ea commodo consequat.

\begin{itemize}
\tightlist
\item
  Don't
\item
  mess
\item
  with
\item
  this
\item
  list
\item
  though
\end{itemize}

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur.

\end{document}

And finally produces this document:

final document

I've found a couple possible solutions, but they don't work—the space remains:


So, in the end, how can I remove the space before and after itemize lists inside minipages that are inside longtables without directly modifying the table itself (i.e. only adding or modifying commands and macros in the preamble)

  • Is it an option for you to use an own column type for that purpose (removing some space from the top) or are that mixed-content columns? – TeXnician Feb 11 '17 at 7:04
  • For an own column type see here: tex.stackexchange.com/a/352597/124577 – TeXnician Feb 11 '17 at 7:06
  • What is the purpose of the 24 [!] instances of \strut? Without the struts, the spacing is just fine. – Mico Feb 11 '17 at 8:01
3

I must confess I don't understand the purpose of the 24 \strut directives. Without them, and without any changes to the itemize environment itself, the table looks like this -- which, I assume, is close to what you want. (Note that the code bloat isn't trimmed either.)

enter image description here

\documentclass[]{memoir}

\usepackage{longtable,booktabs}

\begin{document}
\hrule
\begin{longtable}[c]{@{}lll@{}}
\caption{Sample grid table.}\tabularnewline
\toprule
\begin{minipage}[b]{0.20\columnwidth}\raggedright
Fruit
\end{minipage} &
\begin{minipage}[b]{0.20\columnwidth}\raggedright
Price
\end{minipage} &
\begin{minipage}[b]{0.27\columnwidth}\raggedright
Advantages
\end{minipage}\tabularnewline
\midrule
\endfirsthead
\toprule
\begin{minipage}[b]{0.20\columnwidth}\raggedright
Fruit
\end{minipage} &
\begin{minipage}[b]{0.20\columnwidth}\raggedright
Price
\end{minipage} &
\begin{minipage}[b]{0.27\columnwidth}\raggedright
Advantages
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.20\columnwidth}\raggedright
Bananas
\end{minipage} &
\begin{minipage}[t]{0.20\columnwidth}\raggedright
\$1.34
\end{minipage} &
\begin{minipage}[t]{0.27\columnwidth}\raggedright
\begin{itemize}
\tightlist
\item
  built-in wrapper
\item
  bright color
\end{itemize}
\end{minipage}\tabularnewline
\begin{minipage}[t]{0.20\columnwidth}\raggedright
Oranges
\end{minipage} &
\begin{minipage}[t]{0.20\columnwidth}\raggedright
\$2.10
\end{minipage} &
\begin{minipage}[t]{0.27\columnwidth}\raggedright
\begin{itemize}
\tightlist
\item
  cures scurvy
\item
  tasty
\end{itemize}
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

\end{document}
  • Pandoc generates all the \struts automatically. I wonder if there's a way to redefine struts inside the minipage so they don't do anything to the spacing. Or maybe I just have to filter them out with sed or whatever before compiling the document… – Andrew Feb 11 '17 at 14:39
  • 1
    Unfortunately the \struts are all in there by design (see github.com/jgm/pandoc/pull/2913). So far the only solution I've found is to remove all \struts that precede \begin{itemize} with Perl: perl -0777 -pe 's/\\strut\n\\begin{itemize}/\n\\begin{itemize}/gm;' blah.tex. Not ideal, but it works. – Andrew Feb 11 '17 at 17:57
  • 1
    I opened an issue for this (github.com/jgm/pandoc/issues/3436) and the developers are looking at fixing it. In the meantime, killing all the \struts works great. Thanks! – Andrew Feb 16 '17 at 2:23
  • 1
    This has now been fixed in pandoc: github.com/jgm/pandoc/commit/… – Andrew Feb 24 '17 at 1:18
  • 1
    @Andrew - Wow, that's really good to know that pandoc's developers are so quick and competent. I read the entire trail of comments and back-and-forth deliberations at the github site -- congrats are also due to you, for posting a very clear and actionable initial report that gave the developers a lot to work with. Clearly, posting an MWE is helpful not only at TeX.SE! FWIW, your posting 11 days ago featured just such an MWE, and that's what made it straightforward to identify the underlying cause -- the surfeit of \strut directives. – Mico Feb 24 '17 at 5:32

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.