# Table inside description list

I'm trying to put a table inside a list environment but without success. I'd like to have the table inside the item (matching \linewidth) and not floating in the next page.

\begin{description}
\item[Lorem ipsum] \hfill \\
Lorem ipsum dolor sit amet...
\item[Lorem ipsum] \hfill \\
\begin{table}[h]
\centering
\caption{Foobar}
\label{tab:foobar}
\begin{tabular}{@{}ll@{}}
\toprule
\textbf{foo} & \textbf{bar} \\
\midrule
Lorem ipsum & foo \\
Lorem ipsum & bar \\
\bottomrule
\end{tabular}
\end{table}
\end{description}

How can this be achieved?

• Remove the table environment. – Peter Grill Feb 11 '14 at 0:17
• Well, it is difficulty to help you without the code to produce the error. Also if there is no space enough to insert the table, no way, it will be inserted after. – Sigur Feb 11 '14 at 0:17

If you really want to leave the table as is, inside the description environment, you can avoid it to float simply replacing the floating specifier h with the H provided by the the float package.

MWE:

\documentclass{article}
\usepackage{booktabs}
\usepackage{float} % defines the H specifier

\begin{document}
\begin{description}
\item[Lorem ipsum] \hfill \\
Lorem ipsum dolor sit amet...
\item[Lorem ipsum] \hfill \\
\begin{table}[H]
\centering
\caption{Foobar}
\label{tab:foobar}
\begin{tabular}{@{}ll@{}}
\toprule
\textbf{foo} & \textbf{bar} \\
\midrule
Lorem ipsum & foo \\
Lorem ipsum & bar \\
\bottomrule
\end{tabular}
\end{table}
\end{description}
\end{document}

Output:

• The specifier H did the trick! Thanks. – Renato Rodrigues Feb 11 '14 at 9:23

You don't want table to float. Then remove the table environment. You can have the caption with the help of \captionof macro from either caption or capt-of packages.

\documentclass{article}
\usepackage{capt-of,booktabs}
\begin{document}
\begin{description}
\item[Lorem ipsum] \hfill \\
Lorem ipsum dolor sit amet...
\item[Lorem ipsum] \hfill \\
\begin{minipage}{\linewidth}
\centering
\captionof{table}{Foobar}
\label{tab:foobar}
\begin{tabular}{@{}ll@{}}
\toprule
\textbf{foo} & \textbf{bar} \\
\midrule
Lorem ipsum & foo \\
Lorem ipsum & bar \\
\bottomrule
\end{tabular}
\end{minipage}
\end{description}
\end{document}

• I've tried your method before and it has some faults: caption is not aligned with the table; can't control table width; vertical space between caption and the table is non existent. – Renato Rodrigues Feb 11 '14 at 9:21
• @RenatoRodrigues My method works too ;) See the edited answer. – user11232 Feb 11 '14 at 10:06