Search code examples
latexalignmenttabularenumerate

Centering LaTeX tabulars within enumeration/itemize


New to stack overflow, forgive me if I forget to include something...

What I'm trying to do is get rid of this space above my centered Table (tabular environment). The problem is that if I do not insert a blank line after the \item, the label gets aligned centrally.

Some people seem to recommend to use \begin{tabular}[t]{args}, however positions the letters very oddly.

Here are the different ways I have tried to solve the issue. What I am trying to get is something similar to the first example, but without the extra blank line above the table.

\documentclass[12pt, a4paper]{article}
\usepackage{array}
\usepackage{enumerate}

\begin{document}
    \begin{enumerate}[a)]
        \item \ \begin{center}\begin{tabular}{ | l | *{2}{ c | } } \hline
                    a & b & c \\ \hline
                    d & e & f \\ \hline
                \end{tabular}\end{center}
    \end{enumerate}

    \begin{enumerate}[a)]
        \item \begin{center}\begin{tabular}{ | l | *{2}{ c | } } \hline
                    a & b & c \\ \hline
                    d & e & f \\ \hline
                \end{tabular}\end{center}
    \end{enumerate}

    \begin{enumerate}[a)]
        \item \begin{center}\begin{tabular}[t]{ | l | *{2}{ c | } } \hline
                    a & b & c \\ \hline
                    d & e & f \\ \hline
                \end{tabular}\end{center}
    \end{enumerate}

\end{document}

Output of the above:

Here is the white space I am trying to get rid of:

If I don't have the extra space here's what happens:

Here is the output with [t]:

Thanks for the Help!


Solution

  • With \firsthline you can align the enumerate number with the first line:

    \documentclass[12pt, a4paper]{article}
    \usepackage{array}
    \usepackage{enumerate}
    
    \begin{document}
      \begin{enumerate}[a)]
        \item 
        \hfill
        \begin{tabular}[t]{|l|*{2}{c|}}
          \firsthline
          a & b & c \\ \hline
          d & e & f \\ \hline
        \end{tabular}\hfill\mbox{}
      \end{enumerate}
    \end{document}
    

    enter image description here