cleveref:“Fig”用于引用同一张图中的多个子图,但“Figs”用于引用不同图中的多个子图

cleveref:“Fig”用于引用同一张图中的多个子图,但“Figs”用于引用不同图中的多个子图

对于我们的一篇期刊投稿,编辑部向我们发送了以下评论:

引用同一图的面板时应使用单数“图”,例如“图 3A 和 3B”或“图 3A、3B、3C 和 3D”。引用不同图的面板时应使用复数“图”,例如“图 3A 和 4B”或“图 3A、4B、5C 和 5D”。

我们在文档中使用 cleveref,图中的“面板”是不同的子图。这是我们目前用来设置 cleveref 的内容:

\usepackage[capitalise]{cleveref}
\crefformat{figure}{#2Fig~#1#3}
\Crefformat{figure}{#2Fig~#1#3}
\crefmultiformat{figure}{Figs~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\Crefmultiformat{figure}{Figs~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\crefmultiformat{subfigure}{Fig~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\Crefmultiformat{subfigure}{Fig~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}

最后两个命令(“Fig”或“Figs”)中指定的任何内容都适用于所有子图列表,无论它们是否来自同一个图。有人知道是否可以实现出版商要求的惯例吗?我确实查看了 cleveref 文档,但无法弄清楚是否可以通过更新上面的 cleveref 配置来完成此操作。

这是MWE:

\documentclass{article}

\usepackage{csquotes}
\usepackage[aboveskip=1pt,labelfont=bf,labelsep=period,justification=raggedright,singlelinecheck=off]{caption}
\renewcommand{\figurename}{Fig}
\usepackage{subcaption}
\renewcommand{\thesubfigure}{\Alph{subfigure}}
\captionsetup[subfigure]{labelfont={sf,bf},labelsep=space,labelformat=simple,margin=-15pt,skip=-10pt,position=top}
\captionsetup[figure]{skip=5pt,labelfont={bf},position=bottom}
\usepackage[capitalise]{cleveref}
\crefformat{figure}{#2Fig~#1#3}
\Crefformat{figure}{#2Fig~#1#3}
\crefmultiformat{figure}{Figs~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\Crefmultiformat{figure}{Figs~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\crefmultiformat{subfigure}{Fig~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\Crefmultiformat{subfigure}{Fig~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\usepackage{graphicx}
\usepackage{mwe}


\begin{document}
\begin{figure}[!t]
  \centering
  \begin{subfigure}[c]{0.53\textwidth}
    \subcaption{}\label{fig:1a}%
    \includegraphics[width=\textwidth]{example-image}% Image from the mwe package
    \end{subfigure}\quad%
    \begin{subfigure}[c]{0.40\textwidth}
      \subcaption{}\label{fig:1b}%
      \includegraphics[width=\textwidth]{example-image}% Image from the mwe package
      \end{subfigure}
      \caption{Test figure 1}\label{fig:1}
\end{figure}

\begin{figure}[!t]
  \centering
  \begin{subfigure}[c]{0.53\textwidth}
    \subcaption{}\label{fig:2a}
    \includegraphics[width=\textwidth]{example-image}% Image from the mwe package
    \end{subfigure}\quad%
    \begin{subfigure}[c]{0.40\textwidth}
      \subcaption{}\label{fig:2b}%
      \includegraphics[width=\textwidth]{example-image}% Image from the mwe package
      \end{subfigure}\vspace{0.2cm}
      \caption{Test figure 2}\label{fig:2}
\end{figure}
\Cref{fig:1a,fig:1b} or \cref{fig:2a,fig:2b} should say \enquote{Fig} but \cref{fig:1a,fig:1b,fig:2a,fig:2b} should use \enquote{Figs}.

\end{document}

输出如下:

在此处输入图片描述

答案1

您可以定义两种语言,英语作为默认语言,另一种语言(我选择荷兰语),然后通过选择第二语言来更改标题。

b

添加到序言

%% ***************************************** added
\usepackage[dutch, english]{babel}
\makeatletter
\addto\captionsdutch{%
\crefmultiformat{subfigure}{Figs~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\Crefmultiformat{subfigure}{Figs~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
}
\addto\captionsenglish{%
\crefmultiformat{subfigure}{Fig~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\Crefmultiformat{subfigure}{Fig~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
}
\makeatother    

\newcommand{\crefx}[1]{% <<<<<<<<
    \selectlanguage{dutch}%
        \cref{#1}%
    \selectlanguage{english}% 
}
%% ***************************************** added

并使用命令\crefx

这是完整的代码。

\documentclass{article}

\usepackage{csquotes}
\usepackage[aboveskip=1pt,labelfont=bf,labelsep=period,justification=raggedright,singlelinecheck=off]{caption}
\renewcommand{\figurename}{Fig}
\usepackage{subcaption}
\renewcommand{\thesubfigure}{\Alph{subfigure}}
\captionsetup[subfigure]{labelfont={sf,bf},labelsep=space,labelformat=simple,margin=-15pt,skip=-10pt,position=top}
\captionsetup[figure]{skip=5pt,labelfont={bf},position=bottom}

\usepackage[capitalise, english]{cleveref}% <<<<<<<<<<<<<<

\crefformat{figure}{#2Fig~#1#3}
\Crefformat{figure}{#2Fig~#1#3}
\crefmultiformat{figure}{Figs~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\Crefmultiformat{figure}{Figs~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\crefmultiformat{subfigure}{Fig~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\Crefmultiformat{subfigure}{Fig~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}

\usepackage{graphicx}
\usepackage{mwe}

%% ***************************************** added
\usepackage[dutch, english]{babel}
\makeatletter
\addto\captionsdutch{%
\crefmultiformat{subfigure}{Figs~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\Crefmultiformat{subfigure}{Figs~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
}
\addto\captionsenglish{%
\crefmultiformat{subfigure}{Fig~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\Crefmultiformat{subfigure}{Fig~#2#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
}
\makeatother    

\newcommand{\crefx}[1]{% <<<<<<<<
    \selectlanguage{dutch}%
        \cref{#1}%
    \selectlanguage{english}% 
}
%% ***************************************** added

\begin{document}
\begin{figure}[!t]
    \centering
    \begin{subfigure}[c]{0.53\textwidth}
        \subcaption{}\label{fig:1a}%
        \includegraphics[width=\textwidth]{example-image}% Image from the mwe package
    \end{subfigure}\quad%
    \begin{subfigure}[c]{0.40\textwidth}
        \subcaption{}\label{fig:1b}%
        \includegraphics[width=\textwidth]{example-image}% Image from the mwe package
    \end{subfigure}
    \caption{Test figure 1}\label{fig:1}
\end{figure}

\begin{figure}[!t]
    \centering
    \begin{subfigure}[c]{0.53\textwidth}
        \subcaption{}\label{fig:2a}
        \includegraphics[width=\textwidth]{example-image}% Image from the mwe package
    \end{subfigure}\quad%
    \begin{subfigure}[c]{0.40\textwidth}
        \subcaption{}\label{fig:2b}%
        \includegraphics[width=\textwidth]{example-image}% Image from the mwe package
    \end{subfigure}\vspace{0.2cm}
    \caption{Test figure 2}\label{fig:2}
\end{figure}

\Cref{fig:1a,fig:1b} or \cref{fig:2a,fig:2b} should say \enquote{Fig}       

\crefx{fig:1a,fig:1b,fig:2a,fig:2b} should use \enquote{Figs}. % <<<<<<<<<<<<<< changed     

But not \enquote{Fig} like in  \cref{fig:1a,fig:1b,fig:2a,fig:2b}       
    
\end{document}

笔记 cleveref使用时需要告知默认语言babel

\usepackage[capitalise, english]{cleveref}%

相关内容