有沒有辦法解決 smartef 套件關於子浮點引用的限制?

有沒有辦法解決 smartef 套件關於子浮點引用的限制?

使用指令引用浮點數時\cref,有時可能會產生不正確的排版。當包含子浮點時尤其如此。

一個例子是當我們有 float 1 和兩個子 float 時;該範圍1a and 2 to 5將被誤認為是來自1a to 5。另外,如果1a和都1b包含在原始碼引用中,則應該提及原始程式碼中包含的所有子浮點,而不僅僅是其中之一(請參閱第 2 點)。排版輸出如下所示:

在此輸入影像描述

此輸出是使用以下原始程式碼產生的:

\documentclass[twocolumn]{report}

\usepackage{float}
\usepackage{subfloat}
\usepackage{caption}
\usepackage{cleveref}
\usepackage{paralist}



\begin{document}


    \begin{subfigures}

        % Subfigure 1
        \begin{figure}[H]

            \centering
            \fbox{\Huge Figure 1a}


            \caption{Caption 1}
            \label{fig1a}

        \end{figure}


        % Subfigure 2
        \begin{figure}[H]

            \centering
            \fbox{\Huge Figure 1b}


            \caption{Caption 1b}
            \label{fig1b}

        \end{figure}


    \end{subfigures}


    % Figure 2
    \begin{figure}[H]

        \centering
        \fbox{\Huge Figure 2}


        \caption{Caption 2}
        \label{fig2}

    \end{figure}


    % Figure 3
    \begin{figure}[H]

        \centering
        \fbox{\Huge Figure 3}


        \caption{Caption 3}
        \label{fig3}

    \end{figure}


    % Figure 4
    \begin{figure}[H]

        \centering
        \fbox{\Huge Figure 4}


        \caption{Caption 4}
        \label{fig4}

    \end{figure}


    % Figure 5
    \begin{figure}[H]

        \centering
        \fbox{\Huge Figure 5}


        \caption{Caption 5}
        \label{fig5}

    \end{figure}


    % Figure 6
    \begin{figure}[H]

        \centering
        \fbox{\Huge Figure 6}


        \caption{Caption 6}
        \label{fig6}

    \end{figure}



    \newpage
    Figures are correctly cited for different citation formats such as:

    \begin{enumerate}

        \item Multiple: \textbf{\cref{fig5,,fig3,,fig4,,fig2}}
        \item Range: \textbf{\cref{fig5,fig3,fig4}}
        \item Multiple and range: \textbf{\cref{fig2,fig4,fig3,fig6}}

    \end{enumerate}


    \vspace{5mm}
    But once subfigures are included, some citations formats do not work:

    \begin{enumerate}

    \item Multiple (works): \textbf{\cref{fig3,,fig4,,fig2,,fig1a}}
    \item Range: \textbf{\cref{fig1a,fig1b,fig5,fig3,fig4}} (the output should be \textbf{figs. 1a to 1b and 3 to 5})
    \item Multiple and range: \textbf{\cref{fig1a,fig2,fig4,fig3,fig6}} (the output should be \textbf{figs. 1a, 2 to 4 and 6})

    \end{enumerate}


\end{document}

我已經有了一個可以緩解問題的解決方案,但與上面的預期輸出不同。

答案1

在此輸入影像描述 我們可以定義新的浮點類型 ( subfig)cleveref

\crefformat{subfig}{fig. #1}
\crefrangeformat{subfig}{figs. #1 to #2}
\crefmultiformat{subfig}{figs. #1}{ and #1}{, #1}{ and #1}
\crefrangemultiformat{subfig}{figs. #1 to #2}{}{}{}

然後在序言中我們定義了一個新指令:

\newcommand{\labelsf}[1]{ \label[subfig]{#1} } % a new command for labeling subfigures

labelsf現在可用於標記子圖。

完整的原始碼如下所示:

\documentclass[twocolumn]{report}

\usepackage{float}
\usepackage{subfloat}
\usepackage{caption}
\usepackage{paralist}

\usepackage{cleveref}
\crefformat{subfig}{fig. #1}
\crefrangeformat{subfig}{figs. #1 to #2}
\crefmultiformat{subfig}{figs. #1}{ and #1}{, #1}{ and #1}
\crefrangemultiformat{subfig}{figs. #1 to #2}{}{}{}
\newcommand{\labelsf}[1]{ \label[subfig]{#1} } % a new command for labeling subfigures

\begin{document}


    \begin{subfigures}

        % Subfigure 1
        \begin{figure}[H]

            \centering
            \fbox{\Huge Figure 1a}


            \caption{Caption 1}
            \labelsf{fig1a}

        \end{figure}


        % Subfigure 2
        \begin{figure}[H]

            \centering
            \fbox{\Huge Figure 1b}


            \caption{Caption 1b}
            \labelsf{fig1b}

        \end{figure}


    \end{subfigures}


    % Figure 2
    \begin{figure}[H]

        \centering
        \fbox{\Huge Figure 2}


        \caption{Caption 2}
        \label{fig2}

    \end{figure}


    % Figure 3
    \begin{figure}[H]

        \centering
        \fbox{\Huge Figure 3}


        \caption{Caption 3}
        \label{fig3}

    \end{figure}


    % Figure 4
    \begin{figure}[H]

        \centering
        \fbox{\Huge Figure 4}


        \caption{Caption 4}
        \label{fig4}

    \end{figure}


    % Figure 5
    \begin{figure}[H]

        \centering
        \fbox{\Huge Figure 5}


        \caption{Caption 5}
        \label{fig5}

    \end{figure}


    % Figure 6
    \begin{figure}[H]

        \centering
        \fbox{\Huge Figure 6}


        \caption{Caption 6}
        \label{fig6}

    \end{figure}



    \newpage
    Figures are correctly cited for different citation formats such as:

    \begin{enumerate}

        \item Multiple: \textbf{\cref{fig5,,fig3,,fig4,,fig2}}
        \item Range: \textbf{\cref{fig5,fig3,fig4}}
        \item Multiple and range: \textbf{\cref{fig2,fig4,fig3,fig6}}

    \end{enumerate}


    \vspace{5mm}
    But once subfigures are included, some citations formats do not work:

    \begin{enumerate}

    \item Multiple (works): \textbf{\cref{fig3,,fig4,,fig2,,fig1a}}
    \item Range: \textbf{\cref{fig1a,fig1b,fig5,fig3,fig4}} (the output should be \textbf{figs. 1a to 1b and 3 to 5})
    \item Multiple and range: \textbf{\cref{fig1a,fig2,fig4,fig3,fig6}} (the output should be \textbf{figs. 1a, 2 to 4 and 6})

    \end{enumerate}


\end{document}

cref現在將正確引用子圖,但此解決方案的缺點是:

  • 雙擊標籤無法找到float的用法,點選標籤也找不到float源碼
  • 浮點數的名稱有時會重複兩次,這是多餘的

相關內容