在使用圖、表時,我們大多會採用浮動圖表的方式
%浮動圖
\begin{figure}[h]
\centering
\includegraphics[width=0.8\textwidth]{pic.eps}
\caption{圖標題}
\label{figurelabel}
\end{figure}
%浮動表
\begin{table}[h]
\centering
\caption{表標題}
\label{tablelabel}
……
\end{table}
\begin{figure}[h]
\centering
\includegraphics[width=0.8\textwidth]{pic.eps}
\caption{圖標題}
\label{figurelabel}
\end{figure}
%浮動表
\begin{table}[h]
\centering
\caption{表標題}
\label{tablelabel}
……
\end{table}
但有的時候,我們並不希望圖、表是浮動的
因此我們會拿掉 \begin{figure}、\begin{table}
但這會造成無法出現在圖、表的目錄當中
也沒辦法使用標題 \caption{} 及置中 \centering
為了解決這個問題,就要進行改寫
%加入這段語法
\makeatletter
\newcommand{\figcaption}{\def\@captype{figure}\caption}
\newcommand{\tabcaption}{\def\@captype{table}\caption}
\makeatother
\makeatletter
\newcommand{\figcaption}{\def\@captype{figure}\caption}
\newcommand{\tabcaption}{\def\@captype{table}\caption}
\makeatother
並且原來的語法改成下面這樣
%非浮動圖
\begin{center}
\includegraphics[width=0.8\textwidth]{pic.eps}
%圖標題改成 figcaption,而不是原來的 caption
\figcaption{圖標題}
\label{figurelabel}
\end{center}
%非浮動表格
\begin{center}
%表標題改成 tabcaption,而不是原來的 caption
\tabcaption{表標題}
\label{tablelabel}
……
\end{center}
\begin{center}
\includegraphics[width=0.8\textwidth]{pic.eps}
%圖標題改成 figcaption,而不是原來的 caption
\figcaption{圖標題}
\label{figurelabel}
\end{center}
%非浮動表格
\begin{center}
%表標題改成 tabcaption,而不是原來的 caption
\tabcaption{表標題}
\label{tablelabel}
……
\end{center}
全站熱搜