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}
  • 1
    If you dont mind, could you re-post it as two questions instead? Just for future usage :) – Raaja_is_at_topanswers.xyz Feb 08 '19 at 12:14
  • Might be useful: https://tex.stackexchange.com/questions/17489/change-caption-name-of-figures – Raaja_is_at_topanswers.xyz Feb 08 '19 at 12:16
  • 1
    you need to define a new float/captiontype. E.g. with the newfloat package. – Ulrike Fischer Feb 08 '19 at 12:18
  • 1
    And I don't think that your \notationon/\notationoff commands are doing anything sensible together with chessboard. – Ulrike Fischer Feb 08 '19 at 12:20
  • 1
    The package caption has \captionsetup with a lot of options... –  Feb 08 '19 at 12:34
  • @UlrikeFischer Hmmm … In the context of \fenboard I could have sworn they turn the file and rank labels on/off. But you are right, here they serve no purpose. So, out they will go. – Reinhard Neuwirth Feb 08 '19 at 12:55
  • 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. – Ulrike Fischer Feb 08 '19 at 12:59
  • @UlrikeFischer Got that. I did wonder though that I was using the \chessboard command without having to load the chessboard package. I suppose it too is loaded with xskak. – Reinhard Neuwirth Feb 08 '19 at 13:54
  • 1
    How about specifying new float types, one for Diagrams and another for Problems? The memoir class provides means of doing this, also for corresponding new "List of ...". – Peter Wilson Feb 09 '19 at 19:26
  • @Peter Wilson To my surprise I found that I can show my chessboards in the table environment just like they are shown in the figure environment, so this solved my problem for two floats. I'll the memoir class in mind though. – Reinhard Neuwirth Feb 10 '19 at 19:46

1 Answers1

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

  • Your code does not compile for me. – Reinhard Neuwirth Feb 08 '19 at 21:50
  • @Reinhard Neuwirth do u have a .log? Nevertheless, I would indeed accept that these macros are fragile. – Raaja_is_at_topanswers.xyz Feb 08 '19 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. – Reinhard Neuwirth Feb 08 '19 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. – Raaja_is_at_topanswers.xyz Feb 09 '19 at 03:04