[Tex/LaTex] Aligning top row of a table with the item label in a list

liststablesvertical alignment

I have used the enumerate environment to create a list
in which every item contains a table, created using
the tabular environment. The first row of each table
should be aligned with the item label, (a), (b), etc.
This is not the the case if the table starts with an
\hline. How can I fix the alignment in such a case?

\documentclass{article}
\usepackage{enumerate} 
\begin{document}
\begin{enumerate}[(a)]
\item 
   \begin{tabular}[t]{|c|c|}
     a & b \\  \hline c & d  \\ \hline
   \end{tabular}
\item 
   \begin{tabular}[t]{|c|c|} 
     \hline e & f \\ \hline g & h \\ \hline
   \end{tabular}
\end{enumerate}
\end{document}

MWE

Best Answer

I just had to solve this problem, and "The LaTeX Companion" (second edition) has the answer on page 280. The [t] option aligns the tabular to the \hline instead of the baseline of the text. The array package has the command \firsthline which corrects this:

\documentclass{article}
\usepackage{enumerate,array} 
\begin{document}
\begin{enumerate}[(a)]
\item 
   \begin{tabular}[t]{|c|c|}
     a & b \\  \hline c & d  \\ \hline
   \end{tabular}
\item 
   \begin{tabular}[t]{|c|c|} 
     \firsthline e & f \\ \hline g & h \\ \hline
   \end{tabular}
\end{enumerate}
\end{document}

This is the result:

firsthline fix