我尝试在小页面中使用表格,如下所示:
\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}
我收到此错误\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
我做错了什么或者错过了什么?
答案1
想要在小页面(非浮动环境)内放置一个表格(浮动环境,添加标题?),可以使用包来实现float
。
\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}
选择
\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}
答案2
为了在两个特定段落之间放置一些表格材料,您不需要或table
环境minipage
。如果您想为表格材料指定标题,我建议您加载caption
包并使用其\captionof
宏。
\documentclass[twocolumn]{article}
\usepackage{caption} % for '\captionof' macro
\usepackage{lipsum} % filler text
\begin{document}
\lipsum[2]
\begin{center}
%\begin{minipage}[t]{\columnwidth}
%%\subsection{My Title}
\centering
\captionof{table}{My title}
%%\begin{table}[h!]
\begin{tabular}{ l c l }
\hline
Quality & Abbr. & Frequency \\
\hline
Uncirculated & UNC & \\
\hline
\end{tabular}
%%\end{table}
%\end{minipage}
\end{center}
\lipsum[2]
\end{document}