我正在尝试设置标题的名称和文本的样式,以便名称(“图形”,“表格”等)以粗体显示,而标题文本(例如“一张猫的图片”)以斜体显示。遵循我使用的回忆录手册:
\captiontitlefont{\small\itshape}
\captionnamefont{\small\bfseries}
因此,使用 memoir (由 lyx 制作) 进行以下工作:
%% LyX 2.0.3 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[11pt,a4paper,oneside,english,oldfontcommands,justified,a4paper]{memoir}
\usepackage{mathpazo}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\pagestyle{plain}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\captiontitlefont{\small\itshape}
\captionnamefont{\small\bfseries}
\makeatother
\usepackage{babel}
\begin{document}
\begin{figure}
\caption{A picture of a cat.}
但是,一旦我添加子图,标题就不再具有样式。这不起作用:
%% LyX 2.0.3 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[11pt,a4paper,oneside,english,oldfontcommands,justified,a4paper]{memoir}
\usepackage{mathpazo}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\pagestyle{plain}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\captiontitlefont{\small\itshape}
\captionnamefont{\small\bfseries}
\@ifundefined{showcaptionsetup}{}{%
\PassOptionsToPackage{caption=false}{subfig}}
\usepackage{subfig}
\makeatother
\usepackage{babel}
\begin{document}
\begin{figure}
\subfloat[My first cat.]{
}\caption{A picture of some cats.}
\end{figure}
\end{document}
我也尝试过使用:
\renewcommand{\fnum@figure}[1]{\textbf{\figurename~\thefigure} : }
但是当加载 subfig 包时这又不起作用了。
(我用法语写作,使用 babel,它也可以设置样式,例如将 FIGURE 改为大写,但这似乎是一个单独的问题)。
使用子图时如何设置标题样式?
答案1
您可以将caption
包与subfig
包一起使用。我已将您的代码修改如下:
\documentclass[11pt,a4paper,oneside,english,oldfontcommands,justified,a4paper]{memoir}
\usepackage{mathpazo}
\usepackage[demo]{graphicx} %----------- remove [demo] in your file
\usepackage{subfig} %---------------- for subfigures
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\pagestyle{plain}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{caption}%----------------------- added newly
%\captionsetup{labelfont={sc,bf}}%----------------------- added newly
\captionsetup[figure]{labelfont={bf,small,sc},textfont={it,small}}%----------------------- added newly
\captionsetup[subfloat]{labelfont={bf,small},textfont={it,small}}%----------------------- added newly
%
\usepackage{babel}
\begin{document}
%=========================
\begin{figure}
\includegraphics[width=1\textwidth]{my figure}\\
\caption{My single cat}\label{singlecat}
\end{figure}
%=========================
\begin{figure}[!h]
\centering
\subfloat[My first cat.]{\label{fig:cat1}{\includegraphics[width=0.4\textwidth]{my figure}}}\hfil
\subfloat[My second cat.]{\label{fig:cat2}{\includegraphics[width=0.4\textwidth]{my figure}}}
\caption{My two big cats}
\label{fig:cats}
\end{figure}
%===========================
\end{document}
我还用 SC 字母标注了 FIGURE。
答案2
而不是建议的代码
\@ifundefined{showcaptionsetup}{}{%
\PassOptionsToPackage{caption=false}{subfig}}
\usepackage{subfig}
声明一个新的 subfloat 类型
\newsubfloat{figure}
进而
\begin{figure}
\subbottom[My first cat.]{<a picture>}
\caption{A picture of some cats.}
\end{figure}
如果要使用\subfloat
,请添加
\newcommand{\subfloat}{\subbottom}
后\newsubfloat{figure}
。