LaTeX table in minipage: Not in outer par mode

minipagetables

I try to use a table in a minipage like this:

\begin{center}
    \begin{minipage}[t]{.48\textwidth}
        \subsection{My Title}

        Some text

        \begin{table}[h!]
            \begin{tabular}{ l c l }
                \hline
                Quality            & Abbr. & Frequency \\
                \hline
                Uncirqulated       & UNC   &           \\
                \hline
            \end{tabular}
        \end{table}

    \end{minipage}\quad
    \begin{minipage}[t]{.48\textwidth}
        ...

    \end{minipage}
\end{center}

And I get this error on the line \begin{table}[h!]:

Not in outer par mode.
LaTeX

Undefined control sequence.
\latex@xfloat ...vf \fi \global \setbox \@currbox 
LaTeX

Missing number, treated as zero.
<to be read again> 
LaTeX

What did I wrong or what I miss?

Best Answer

To have a table (a floating environment, to add a caption?) inside a minipage (non floating environment) can be done using the package float.

a

\documentclass[12pt,a4paper]{article}

\usepackage{float}% added <<<<<<<<<<

\begin{document}
        
\begin{center}
        \begin{minipage}[t]{.48\textwidth}
            \subsection{My Title}       
            Some text
            
            \begin{table}[H] % changed <<<<<
                \begin{tabular}{ l c l }
                    \hline
                    Quality            & Abbr. & Frequency \\
                    \hline
                    Uncirqulated       & UNC   &           \\
                    \hline
                \end{tabular}
            \caption{First table}
            \end{table}     
        \end{minipage} \hfill
        \begin{minipage}[t]{.48\textwidth}
            \subsection{My Title}       
            Some text
            
            \begin{table}[H]
                \begin{tabular}{ l c l }
                    \hline
                    Quality            & Abbr. & Frequency \\
                    \hline
                    Uncirqulated       & UNC   &           \\
                    \hline
                \end{tabular}
                \caption{Second table}
            \end{table}     
        \end{minipage}
\end{center}

    
\end{document}

Alternative

b

\documentclass[12pt,a4paper]{article}

\usepackage{float}% added <<<<<<<<<<    
\begin{document}
    
    
\section{My Title}      
        
\begin{center}
        \begin{minipage}[t]{.48\textwidth}
            Some text   
            
            \begin{table}[H] % changed <<<<<
                \begin{tabular}{ l c l }
                    \hline
                    Quality            & Abbr. & Frequency \\
                    \hline
                    Uncirqulated       & UNC   &           \\
                    \hline
                \end{tabular}
            \caption{First table}
            \end{table} 
        \smallskip
        Some more text      
        \end{minipage}
\end{center}    
    
\end{document}
Related Question