[Tex/LaTex] List environment inside the tabular environment: extra line at top preventing alignment

listsspacingtablesvertical alignment

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 🙂

Best Answer

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}