2

Is there a way to tweak the figure environment so that it will prefix captions with some text other than Figure followed by auto-numbering? For argument's sake have (1) two types of caption prefixes, Diagram and Problem, (2) each with their own auto-numbering. So there are two questions.

\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}
10
  • 1
    If you dont mind, could you re-post it as two questions instead? Just for future usage :) Feb 8, 2019 at 12:14
  • 1
    you need to define a new float/captiontype. E.g. with the newfloat package. Feb 8, 2019 at 12:18
  • 1
    And I don't think that your \notationon/\notationoff commands are doing anything sensible together with chessboard. Feb 8, 2019 at 12:20
  • 1
    The package caption has \captionsetup with a lot of options...
    – user31729
    Feb 8, 2019 at 12:34
  • 1
    \fenboard, \notationon, \showboard are commands from skak (loaded by xskak). \chessboard is from the chessboard package. It has its own options to configure labels. Feb 8, 2019 at 12:59

1 Answer 1

1

May be something like this macro?

\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}

which would give you:

enter image description here

enter image description here

4
  • Your code does not compile for me. Feb 8, 2019 at 21:50
  • @Reinhard Neuwirth do u have a .log? Nevertheless, I would indeed accept that these macros are fragile. Feb 8, 2019 at 22:15
  • It looks like the key to answering my problem is the caption package and its \captionsetup command` as suggested by @Christian Hupfer. Configuring caption names was the easy part, I am experimenting at the moment to associate individual numbering with different names. Feb 8, 2019 at 23:09
  • @Reinhard Neuwirth if it's only one environment then it's fairly straightforward. Else it is a little bit tricky. I agree with you on your comment, nevertheless. This is just a lazy alternative. One thing to do (for me) is to put-in the \tag. Feb 9, 2019 at 3:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .