You can use \captionsetup
to provide different options for table
and figure
:
\documentclass{elsarticle}
\usepackage[labelfont=bf,justification=raggedright,singlelinecheck=false]{caption}
\captionsetup[figure]{name=Fig. ,labelsep=period}
\captionsetup[table]{labelsep=newline,font=footnotesize}
\begin{document}
\begin{table}[!ht]
\caption{A test table caption}
\end{table}
\begin{figure}[!ht]
\caption{A test figure caption}
\end{figure}
\end{document}
You should take into account the warning you get from using caption
with elsarticle
class:
Package caption Warning: Unsupported document class (or package)
detected, (caption) usage of the caption package is not
recommended. See the caption package documentation for explanation.
The elsarticle
document class redefines the \thesection
macro in a quick and unfortunately rather dirty way when \appendix
is executed:
\gdef\thesection{\appendixname\@Alph\c@section}
[Update mid-2020: The instruction in the most recent version of elsarticle.cls
is
\gdef\thesection{\appendixname~\@Alph\c@section}
The only difference, relative to the code in the original form of my answer, is the insertion of an unbreakable space after \appendixname
.]
This prefixes the word "Appendix" to the (Alpha-stye) section "number" (A, B, C, etc.) That's what's causing the cross-reference call-outs generated by cleveref
to contain the string "Appendix" twice.
A quick fix consists of using the instruction \labelcref
instead of \cref
when making cross-references to sections located in the appendix part of the document.
A more elaborate fix, i.e., one which lets you continue to use \Cref
and \cref
to cross-reference sections in the appendix, involves inserting the following code block immediately after the \appendix
instruction:
\gdef\thesection{\Alph{section}} % corrected redefinition of "\thesection"
\makeatletter
\renewcommand\@seccntformat[1]{\appendixname\ \csname the#1\endcsname.\hspace{0.5em}}
\makeatother
A separate comment: The preamble of your document is, to put it delicately, not organized all that well. For instance, you provide the option times
to the \documentclass
instruction; this option tells LaTeX to load the "Times Roman" font. Later, you load the lmodern
font package, which loads the "Latin Modern" font family, followed by a loading of the kpfonts
font package, which loads a clone of the "Palatino" font family. Which font family do you want? You may want to go through the preamble and determine which packages are really needed.
Here's an MWE that illustrates the workings of the "more elaborate fix" shown above. (I've simplified the preamble and the body of your test document in order to focus on the essentials.)
\documentclass[letterpaper,12pt]{elsarticle}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{geometry}
\usepackage[colorlinks]{hyperref}
\usepackage[nameinlink]{cleveref}
\begin{document}
\section{Introduction}
We prove Result A in \Cref{regsol} and we prove Result B in \Cref{regsolB}.
\appendix
%% now insert the new code block
\gdef\thesection{\Alph{section}}
\makeatletter
\renewcommand\@seccntformat[1]{\appendixname\ \csname the#1\endcsname.\hspace{0.5em}}
\makeatother
\section{Proof of Result A}\label{regsol}
We show that \dots
\section{Proof of Result B}\label{regsolB}
We show that \dots
\end{document}
Best Answer
Edit without cleveref (redefining
\ref
but usingxstring
):Output:
Old Answer with cleveref:
Here is an answer for you to check because I have not the cls file:
The idea is to use
cleveref
package that provides\cref
command. And I redefined this command to print everything in blue. (The colorlinks)