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 have a LaTeX question that is bugging me. I have been trying to get a list environment to appear correctly inside the tabular environment. So far I have gotten everything to my liking except one thing: the top of the list does not align with other entries in the table, in fact it looks like it adds one line above the list... I would like to have these lists at the top. This is what I have, a custom list environment:

  \newenvironment{flushemize}{
    \begin{list}{$\bullet$}
    {\setlength{\itemsep}{1pt}
      \setlength{\parskip}{0pt}
      \setlength{\parsep}{0pt}
      \setlength{\partopsep}{0pt}
      \setlength{\topsep}{0pt}
      \setlength{\leftmargin}{12pt}}}{\end{list}}

Renamed ragged right:

\newcommand{\rr}{\raggedright}

and here is my table:

\begin{table}[H]\caption{Tank comparisons}\label{tab:tanks}
    \centering
    \rowcolors{2}{white}{tableShade}

    \begin{tabular}{p{1in}p{1.5in}p{1.5in}rr}

    \toprule

    {\bf Material} & {\bf Pros} & {\bf Cons} & {\bf Size} & {\bf Cost} \\

    \midrule

    \rr Reinforced concrete &\rr  \begin{flushemize}\item Strong \item Secure \end{flushemize}&\rr  \begin{flushemize}\item Prone to leaks \item Relatively expensive to install \item Heavy \end{flushemize} & 100,000 gal & \$299,400  \\

    \rr Steel & \begin{flushemize}\item Strong \item Secure \end{flushemize} & \begin{flushemize}\item Relatively expensive to install \item Heavy \item Require painting to prevent rusting \end{flushemize} & 100,000 gal & \$130,100  \\

    \rr Polypropylene & \begin{flushemize}\item Easy to install \item Mobile \item Inexpensive \item Prefabricated \end{flushemize} & \begin{flushemize}\item Relatively insecure \item Max size available 10,000 gal \end{flushemize} & 10,000 gal & \$5,000  \\

    \rr Wood & \begin{flushemize}\item Easy to install \item Mobile \item Cheap to install \end{flushemize} & \begin{flushemize}\item Prone to rot \item Must remain full once constructed \end{flushemize} & 100,000 gal &  \$86,300\\

    \bottomrule

    \end{tabular}
\end{table}

Thank you for any advice :)

share|improve this question
6  
Welcome Usagi! Have a look at the answers to these questions: Preventing itemize environment to insert initial vertical space and Including an itemized list within a tabular column using the paralist package. Those might solve your problem as well. –  Stefan Kottwitz Feb 11 '11 at 21:55
    
@StefanKottwitz, I'll take a look, thank you for the help :) –  Usagi Feb 11 '11 at 22:12
add comment

1 Answer

up vote 3 down vote accepted

Here the working code. Please also read the links Stefan Kottwitz posted above. I also changed a couple of other things. Please do not write {\bf ...} but \textbf{...}. Note the new columns types. Read the manual for array to learn about them.

\documentclass{article}

\usepackage{booktabs}
\usepackage{xcolor}
\usepackage{array}
% Define your own types for special columns:
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}
\makeatletter
\newcolumntype{F}[1]{>{\raggedright\arraybackslash\@minipagetrue\flushemize}p{#1}<{\endflushemize}}
\makeatother

\newenvironment{flushemize}{%
    % You should put this outside the `list`. The new environment will make them local anyway:
    \setlength{\itemsep}{1pt}%
    \setlength{\parskip}{0pt}%
    \setlength{\parsep}{0pt}%
    \setlength{\partopsep}{0pt}%
    \setlength{\topsep}{0pt}%
    \setlength{\leftmargin}{12pt}%
    % Use \list ... \endlist instead of \begin{list} ... \end{list} inside another environment
    \list{$\bullet$}\unskip}
    {\endlist}

\begin{document}


\begin{table}[H]% Please don't use 'H' or 'h'.
    \centering
    \setlength{\belowcaptionskip}{\abovecaptionskip}% Correct skip for caption on top
    \caption{Tank comparisons}
    \label{tab:tanks}% Yes! The \label comes after \caption, not before
    %\rowcolors{2}{white}{tableShade}% Always include all packages in your example

    \makebox[\textwidth][c]{% Centers an overwide tabular
    \begin{tabular}{P{1in}F{1.5in}F{1.5in}rr}
    \toprule
    \textbf{Material} & \multicolumn{1}{p{1.5in}}{\textbf{Pros}} & \multicolumn{1}{p{1.5in}}{\textbf{Cons}} & \textbf{Size} & \textbf{Cost} \\
    \midrule
    Reinforced concrete & \item Strong \item Secure & \item Prone to leaks \item Relatively expensive to install \item Heavy  & 100,000 gal & \$299,400  \\

    Steel & \item Strong \item Secure  & \item Relatively expensive to install \item Heavy \item Require painting to prevent rusting  & 100,000 gal & \$130,100  \\

    Polypropylene & \item Easy to install \item Mobile \item Inexpensive \item Prefabricated  & \item Relatively insecure \item Max size available 10,000 gal  & 10,000 gal & \$5,000  \\

    Wood & \item Easy to install \item Mobile \item Cheap to install  & \item Prone to rot \item Must remain full once constructed  & 100,000 gal &  \$86,300\\
    \bottomrule
    \end{tabular}%
    }
\end{table}

\end{document}
share|improve this answer
    
thank you. What's the difference between \textbf{} and {\bf }? –  Usagi Feb 11 '11 at 22:20
1  
@Usagi: \bf is outdated LaTeX2.09 syntax. It doesn't stack, e.g. {\bf\it Text} does not do bold italic text, but only italic, because the last command overwrites the earlier ones. However, \textbf{\textif{Text}} works. There are also \bfseries and \itshape as well as \ttfamily if you do not want a macro which takes an argument. –  Martin Scharrer Feb 11 '11 at 22:26
1  
Thanks for the help! –  Usagi Feb 13 '11 at 20:58
add 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.