2

I have applied in combination of following two solutions. How to make figure and listing share their counter and How to change listing caption?. I was able to combine them and make it work but I just want to remove : after the Figure.

The template I am using does not put : after the Figure N caption. Here is it possible to change the format of caption, where in Figure 1: Descriptive Caption Text can where remove the semicolon?

my code:

\documentclass[AMA,LATO1COL]{WileyNJD-v2} % \documentclass{article}
\usepackage{listings}% http://ctan.org/pkg/listings
\renewcommand{\lstlistingname}{\textbf{Figure}}% Listing -> Algorithm
\renewcommand{\lstlistlistingname}{List of \lstlistingname s}% List of Listings -> List of Algorithms
\makeatletter
\AtBeginDocument{%
    \let\c@figure\c@lstlisting
    \let\thefigure\thelstlisting
    \let\ftype@lstlisting\ftype@figure % give the floats the same precedence
}
\makeatother

\begin{document} \begin{figure} \centering \includegraphics[width=8cm,height=5cm]{myPictureName.png}% \caption{My Picture} \end{figure}

\begin{lstlisting}[caption={Descriptive Caption Text},label=DescriptiveLabel] for i:=maxint to 0 do ... done \end{lstlisting}

\end{document}

or from overleaf-link.


output of the corresponding part:

enter image description here

In the wanted Figure I want Figure 2 to be same as templated Figure N format I believe it is defined as just bold \textbf{Figure 2} Descriptive Caption Text.

enter image description here

alper
  • 1,389

1 Answers1

2

The class loads caption which allows you to add

\captionsetup[lstlisting]{
  labelfont=bf,
  labelsep=space
}

somewhere in the preamble (after loading listings). This provides the formatting you're after (that matches that of the figure float/environment).

Here's a complete minimal example:

enter image description here

\documentclass[AMA,LATO1COL]{WileyNJD-v2} % \documentclass{article}

\usepackage{listings}% http://ctan.org/pkg/listings

\renewcommand{\lstlistingname}{\textbf{Figure}}% Listing -> Algorithm \renewcommand{\lstlistlistingname}{List of \lstlistingname s}% List of Listings -> List of Algorithms \makeatletter \AtBeginDocument{% \let\c@figure\c@lstlisting \let\thefigure\thelstlisting \let\ftype@lstlisting\ftype@figure % give the floats the same precedence } \makeatother

\captionsetup[lstlisting]{ labelfont=bf, labelsep=space }

\begin{document} \begin{figure} \centering \caption{My Picture} \end{figure}

\begin{lstlisting}[caption={Descriptive Caption Text},label=DescriptiveLabel] for i:=maxint to 0 do ... done \end{lstlisting}

\end{document}

Werner
  • 603,163