2

When I try to place a table in a list, like:

\begin{enumerate}
\item  

\begin{table}[htb!]
\centering
\begin{tabular}{c|c|c||c|c}
$P$ & $Q$ & $R$ & $P\wedge (Q\vee R)$ & $(P\wedge Q)\vee (P\wedge R)$\\
\hline
T & T & T & T & T\\
T & T & F & T & T\\
T & F & T & T & T\\
T & F & F & F & F\\
F & T & T & F & F\\
F & T & F & F & F\\
F & F & T & F & F\\
F & F & F & F & F\\
\end{tabular}
\end{table}
\end{enumerate}

The table always shows up above the item number. Is there any way to fix this?

b_pcakes
  • 237

2 Answers2

3

Yes. You don't need to place a tabular inside a table. You can just set it as-is:

enter image description here

\documentclass{article}
\begin{document}

\begin{enumerate}
  \item % Top
  \begin{tabular}[t]{ *{5}{c} }
    \\[\dimexpr-\normalbaselineskip-.4pt]
    \hline
    A & B & C & D & E \\
    \hline
    1 & 2 & 3 & 4 & 5 \\
    a & b & c & d & e \\
    \hline
  \end{tabular}

  \item % Center (default)
  \begin{tabular}{ *{5}{c} }
    \hline
    A & B & C & D & E \\
    \hline
    1 & 2 & 3 & 4 & 5 \\
    a & b & c & d & e \\
    \hline
  \end{tabular}

  \item % Bottom
  \begin{tabular}[b]{ *{5}{c} }
    \hline
    A & B & C & D & E \\
    \hline
    1 & 2 & 3 & 4 & 5 \\
    a & b & c & d & e \\
    \hline
    \\[\dimexpr-1.4\normalbaselineskip+.4pt] % rough estimate
  \end{tabular}

\end{enumerate}

\end{document}

I've tried to align the tabular with the enumerate \items. However, that's not necessary. Perhaps, if you want a centered tabular, just place it in a center environment after \item. Be aware of possible problems with page breaks separating the content from the enumeration.

Werner
  • 603,163
1

If for same reason you like to have table in list ... than add to \item invisible character ~:

\documentclass{article}
\begin{document}

\begin{enumerate} \item ~ % <---- added ~

\begin{table}[h] \centering \begin{tabular}{c|c|c||c|c} $P$ & $Q$ & $R$ & $P\wedge (Q\vee R)$ & $(P\wedge Q)\vee (P\wedge R)$\ \hline T & T & T & T & T\ T & T & F & T & T\ T & F & T & T & T\ T & F & F & F & F\ F & T & T & F & F\ F & T & F & F & F\ F & F & T & F & F\ F & F & F & F & F\ \end{tabular} \end{table}

\end{enumerate} \end{document}

enter image description here

If you like that table appear after complete list (on bottom of page (this also can be concluded from your question}, than select for table option b: \begin{table}[b]

Zarko
  • 296,517