设置图标标题样式需要导入\caption和\subcaption 包,可以改变caption和label的字体、编码样式、对齐方式、格式等
代码如下
\begin{figure}
\centering
\begin{subfigure}[t]{1in}
\centering
\includegraphics[width=1in]{placeholder}
\caption{Caption 1}\label{fig:1a}
\end{subfigure}
\quad
\begin{subfigure}[t]{1in}
\centering
\includegraphics[width=1in]{placeholder}
\caption{Caption 2}\label{fig:1b}
\end{subfigure}
\caption{Main figure caption}\label{fig:1}
\end{figure}
代码类似
\begin{table}
\centering
\begin{subtable}[t]{2in}
\centering
\begin{tabular}{|l|l|l|}
\hline
100 & 200 & 300\\
\hline
400 & 500 & 600\\
\hline
\end{tabular}
\caption{Caption 1}\label{table:1a}
\end{subtable}
\quad
\begin{subtable}[t]{2in}
\centering
\begin{tabular}{|l|l|l|}
\hline
100 & 200 & 300\\
\hline
400 & 500 & 600\\
\hline
\end{tabular}
\caption{Caption 2}\label{table:1b}
\end{subtable}
\caption{Main table caption}\label{table:1}
\end{table}
可以用\columnwidth
代替\width
% change the style of the caption numbering.
\renewcommand{\thetable}{\alph{table}}
\renewcommand{\thefigure}{\Alph{table}}
\renewcommand{\thesubtable}{\Roman{subtable}}
\renewcommand{\thesubfigure}{\arabic{subfigure}}
Counter style | Code | Example |
---|---|---|
Arabic numerals | \arabic{counter} | 1, 2 |
Lower case letters | \alph{counter} | a, b |
Upper case letters | \Alph{counter} | A, B |
Lower case Roman | numerals \roman{counter} | i, ii |
Upper case Roman | numerals \Roman{counter} | I, II |
将其中的counter用table或者subtable代替就得到了想要的编号样式
示例:
\renewcommand{\thefigure}{\Roman{figure}}
\renewcommand{\thesubfigure}{\arabic{subfigure}}
\begin{figure}
\centering
\begin{subfigure}[t]{1in}
\centering
\includegraphics[width=1in]{placeholder}
\caption{Arabic numerals}\label{fig:1a}
\end{subfigure}
\quad
\begin{subfigure}[t]{1in}
\centering
\includegraphics[width=1in]{placeholder}
\caption{Arabic numerals}\label{fig:1b}
\end{subfigure}
\caption{Capital Roman numerals}\label{fig:1}
\end{figure}
类似,代码如下
% This applies if you have chapters
\renewcommand{\thefigure}{\thechapter.\Alph{figure}} % set caption label style to 1.A
\renewcommand{\thesubfigure}{\arabic{subfigure}}
\begin{figure}
\centering
\begin{subfigure}[t]{1in}
\centering
\includegraphics[width=1in]{placeholder}
\caption{Arabic numerals}\label{fig:1a}
\end{subfigure}
\quad
\begin{subfigure}[t]{1in}
\centering
\includegraphics[width=1in]{placeholder}
\caption{Arabic numerals}\label{fig:1b}
\end{subfigure}
\caption{Chapter number dot figure letter}\label{fig:1}
\end{figure}
导入宏包的时候可以直接设置全局样式,即所有的caption样式都变化,示例如下:
% options apply to all captions
\usepackage[OPTIONS]{caption}
% applies to all subfigure and subtable captions
\usepackage[OPTIONS]{subcaption}
% will apply to all captions
\usepackage[labelfont=it,textfont={bf,it}]{caption}
% will apply to all subcaptions
\usepackage[labelfont=bf,textfont=normalfont,singlelinecheck=off,justification=raggedright]{subcaption}
也可以使用\captionsetup
设置标题样式,这样后面所有的标题样式都是根据\captionsetup
重新设置的,示例代码如下:
\captionsetup[FLOAT_TYPE]{OPTIONS}
FLOAT_TYPE
可以是table、subtable、figure、subfigure
等,下面的代码展示了label font、text font
的设置以及子标题的对齐方式的设置:
% for figures: caption label is italic, the caption text is bold / italic
\captionsetup[figure]{labelfont=it,textfont={bf,it}}
% for subfigures: caption label is bold, the caption text normal.
% justification is raggedright (i.e. left aligned)
% singlelinecheck=off means that the justification setting is used even when the caption is only a single line long.
% if singlelinecheck=on, then caption is always centered when the caption is only one line.
\captionsetup[subfigure]{labelfont=bf,textfont=normalfont,singlelinecheck=off,justification=raggedright}
\begin{figure}
\centering
\begin{subfigure}[t]{1in}
\centering
\includegraphics[width=1in]{placeholder}
\caption{Caption}\label{fig:1a}
\end{subfigure}
\quad
\begin{subfigure}[t]{1in}
\centering
\includegraphics[width=1in]{placeholder}
\caption{Caption}\label{fig:1b}
\end{subfigure}
\caption{Main figure caption.}\label{fig:1}
\end{figure}
运行效果如下
其中singlelinecheck=off
是设置即使是一行的标题也采用justification的设置,否则默认居中。
标题大小设置如下
\captionsetup{font={scriptsize}}
其他尺寸参见http://blog.csdn.net/wkd22775/article/details/51784770