有没有办法调整figure environment
,以便它能用一些文本作为标题的前缀,而不是Figure
后面跟着自动编号?为了便于讨论,有 (1) 两种类型的标题前缀,Diagram
和Problem
,(2) 每种都有自己的自动编号。所以有两个问题。
\documentclass{article}
% RN. 8 Feb 2019
%=======================
\usepackage{xparse}
\usepackage{xskak}
\begin{document}
\begin{figure}
\centering
\notationon
\chessboard[showmover=false,setfen={rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w - - 0 1}]
\notationoff
\caption{Starting Position}
\label{}
\end{figure}
\begin{figure}
\centering
\notationon
\chessboard[showmover=false,setfen={4k3/8/4b3/r7/7p/8/8/2K1Q2n b - - 0 1}]
\notationoff
\caption{}
\label{}
\end{figure}
\begin{figure}
\centering
\notationon
\chessboard[showmover=false,setfen={2K4Q/5R2/8/3b1N2/5kN1/8/P7/b7 b - - 0 1}]
\notationoff
\caption{}
\label{}
\end{figure}
\end{document}
答案1
可能是类似这个宏的东西?
\documentclass{article}
\usepackage{graphicx}
\newcounter{example1}
\setcounter{example1}{1}
\newcounter{example2}
\setcounter{example2}{1}
\makeatletter
\newcommand\diagram[4]{%
\protect\includegraphics[height=#2 in, keepaspectratio]{#3}\vskip \flushleft{Diagram \@nameuse{the#1}: #4.\vskip\stepcounter{example1}}}
\makeatother
\makeatletter
\newcommand\Problem[4]{%
\protect\includegraphics[height=#2 in, keepaspectratio]{#3}\vskip \flushleft{Problem \@nameuse{the#1}: #4.\vskip\stepcounter{example2}}}
\makeatother
\begin{document}
\noindent \diagram{example1}{2}{example-image-a}{A caption}
\diagram{example1}{2}{example-image-b}{A caption}
\Problem{example2}{2}{example-image-c}{A caption}
\Problem{example2}{2}{example-image-duck}{Duck never gives a problem}
\end{document}
这将给你: