Centering LaTeX tabulars within enumeration/itemize

Viewed 1687

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!

2 Answers

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

Here, what I think is giving you the problem is the [t] parameter when you create the tabular statement. In this case, the [t] parameter is to indicate the position of the text inside of the table and can be (t for top, c for center, and b for bottom). But in this case, you don't need it, if the example stays like this. I tried the rest of the suggestions and none of them worked for me.

Here is the code I tried and the picture as well:

\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}{ | l | *{2}{ c | } } \hline
                a & b & c \\ \hline
                d & e & f \\ \hline
            \end{tabular}\end{center}
\end{enumerate}

\end{document}

enter image description here

Maybe there is a special reason why you have to use the [t] parameter, but right now I do not see it.

I hope this works for you. If not, post it and we'll try to help you.

Related