My question is very similar to this, However, I would like to only change the name of Caption for a specific figure, instead of all figures. Is it even possible and if so, then how?
2 Answers
IFF your document is really similar to the linked question, then you could do this:
\documentclass{article}
%\renewcommand{\figurename}{Fig.}
\usepackage[labelsep=endash]{caption}
\begin{document}
\begin{figure}
\centering
\rule{1cm}{1cm}
\caption{This is a figure}
\end{figure}
\begin{figure}
\renewcommand{\figurename}{Fig.}%
\centering
\rule{1cm}{1cm}
\caption{This is a figure}
\end{figure}
\begin{figure}
\centering
\rule{1cm}{1cm}
\caption{This is a figure}
\end{figure}
\end{document}
However, depending on what your real document looks like --- which is why an MWE is almost always advisable --- you may need to do something rather different.
-
Yea, I was about to post same answer, I realized moving that command under any figure will change the caption name.– lonesomeJun 23, 2016 at 1:09
-
It's actually about keeping the redefinition in a group (here, the
\begin{<environment>} ... \end{<environment>}
.– jonJun 23, 2016 at 1:17 -
-
And can you tell me how to reset numbering for the particular figure with redefined caption name?– lonesomeJun 23, 2016 at 1:36
-
@lonesome -- When do you want to reset the numbering? Normally, the counter is incremented in relation to other counters (such as those triggered by
\chapter
and/or\section
, e.g.).– jonJun 24, 2016 at 2:21
This is more of an answer to a comment, but it was too long to write there. It is based on the code in jon's answer.
It creates a new counter. I am sure this can be done in one of the existing packages, but this works without any.
A new environment is created (figCaption
), mostly not to keep writing the same thing for every figure. Within it, it just copies and replaces the existing counter for the figure, and resets it afterwards, so that the normal figure will keep counting Also, it replaces the figure-name, in the same way jon did, in his code.
Output
Code
\documentclass{article}
\usepackage[labelsep=endash]{caption}
\newcounter{Figcount}
\newcounter{tempFigure}
\newenvironment{figCaption}{%
\renewcommand{\figurename}{Fig.}
\setcounter{tempFigure}{\thefigure}
\setcounter{figure}{\theFigcount}
}{%
\setcounter{figure}{\thetempFigure}
\stepcounter{Figcount}
}
\begin{document}
\begin{figure}
\centering
\rule{1cm}{1cm}
\caption{This is a figure}
\end{figure}
\begin{figure}
\begin{figCaption}
\centering
\rule{1cm}{1cm}
\caption{This is a figure}
\end{figCaption}
\end{figure}
\begin{figure}
\centering
\rule{1cm}{1cm}
\caption{This is a figure}
\end{figure}
\begin{figure}
\begin{figCaption}
\centering
\rule{1cm}{1cm}
\caption{This is a figure}
\end{figCaption}
\end{figure}
\begin{figure}
\centering
\rule{1cm}{1cm}
\caption{This is a figure}
\end{figure}
\end{document}