Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using itemize and tables like the following

\begin{tabularx}{\textwidth}{>{\ttfamily}llX}
 \toprule
 \textbf{\rmfamily Operator} & \textbf{Typen} & \textbf{Regel} \\
 \midrule
 = & Alle Typen &
  \begin{itemize}
   \item This is how we roll
   \item Maybe we can talk?
  \end{itemize} \\
 \bottomrule
\end{tabularx}

But it keeps inserting a vertical space before the itemized list. How can I prevent it from doing so?

share|improve this question
add comment

1 Answer 1

up vote 21 down vote accepted

Lists like itemize act differently if they are used within a minipage environment. Specifically, they don't insert that vertical space before. So, you could use a minipage environment inside the table cell for the itemize list. There's a trick which is more handy - define this command:

\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother

Now just use \compress before \begin{itemize}. You could even use it within the column definition, if you also load the array package:

\usepackage{array}
...
\begin{tabularx}{\textwidth}{>{\ttfamily}ll>{\compress}X}

Output of your example using this command:

alt text

The vertical space before itemize is gone. If you would like to compress the lists even more, have a look at

  • the paralist package, which offers a compactitem environment for that purpose, or

  • the enumitem package which allows easy customization of list environments, for example \begin{itemize}[itemsep=0pt], it even provides global configuration commands for lists.

But even with \begin{itemize}[itemsep=0pt,topsep=0pt] I would additionally use \compress.

share|improve this answer
    
Ohh i see. Any idea why it adds that space by default? Is that so one doesn't have to issue a ` \\ ` in the normal usecase before the lists? Where can one find information such as \@minipagetrue? Is that listed in some manual somewhere? What other stuff is affected by that special "magic" command? I'm trying to avoid a minipage, because I generally don't know the width of the X column of the table, but I would need to know it for the minipage. –  Johannes Schaub - litb Dec 4 '10 at 3:13
1  
\begin{itemize}[itemsep=0pt,topsep=0pt] was the first thing I tried. It had a smaller amount of space, but it was still there. I didn't look into why. Do you have any idea why? –  TH. Dec 4 '10 at 6:59
    
@TH.: Lists use \addvspace. This command doesn't add vertical space if @minipage is true. This way the minipage environment avoids extra vertical space at the top. We do the same here for lists - so \topsep and perhaps other values used at the beginning of the list don't matter any more. –  Stefan Kottwitz Dec 4 '10 at 13:54
1  
@Johannes: In source2e.pdf, 16.5 Vertical spacing, you can find the information regarding \addvspace and @minipage. List items then set \@minipage to false using \everypar. –  Stefan Kottwitz Dec 4 '10 at 13:58
1  
Ah, thanks. I'm not sure I understand the rationale behind that design. As this question shows, there are situations other than minipages one might wish to not have such space. –  TH. Dec 4 '10 at 22:14
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.