latex中使用表格(tabular)并且需要对表格添加标题(caption)以便进行引用时,一般需要将表格放在table环境下。但此时表格在文档中的位置会受到多种因素的影响而浮动,不太方便控制。而单独使用tabular时表格会放置在当前位置。那可不可以仅使用tabular表格,同时添加标题呢?
capt-of宏包可以解决这个问题,具体用法是:
先在导言区添加宏包:\usepackage{capt-of},然后
\begin{center} \captionof{table}{Caption text goes here} \label{table1} % for use in \ref{table1} if you want to refer to the table number \begin{tabular}{|c|c|c|c|c|c|} % etc. \end{tabular} \end{center}
参考文献:http://stackoverflow.com/questions/803463/caption-outside-table