0

It does not seem that cref works with enotez. The output refers to the chapter number rather than the number of the end note.

I had similar issue in this question: Why does not cross-referencing of exercises work with exsheets? . It seems that the solution for exsheets does not work for enotez, because question is an environment while \endnote is a command

enter image description here

My source code

\documentclass{book}
\usepackage[x11names]{xcolor}

\usepackage{hyperref}
\hypersetup{linkbordercolor=DodgerBlue3, linkcolor=DodgerBlue3, colorlinks=true}

\usepackage{enotez}
% This package allows for the use of end notes

    \setenotez{mark-format=\tiny, list-name=End Notes of Chapter \thechapter,backref}
    \renewcommand{\theendnote}{\thechapter.\alph{endnote}}

    \DeclareInstance{enotez-list}{custom}{paragraph}{
        heading=\chapter*{#1},
        % Spacing
        notes-sep=0.5\baselineskip,
    %
        % Styling of the printed end notes
    %
            % Notes
            format=\normalfont,
    %       
            % Numbering
            number-format=\normalfont,
    %
        % Notes numbering
        number=#1\hspace{3mm}
                                                    }


\usepackage{cleveref}
\crefformat{endnote}{End Note #2#1#3}
\crefrangeformat{endnote}{End Notes #3#1#4 to #5#2#6}
\crefmultiformat{endnote}{End Notes #2#1#3}{ and #2#1#3}{, #2#1#3}{ and #2#1#3}
\crefrangemultiformat{endnote}{End Notes #3#1#4 to #5#2#6}{ and #3#1#4 to #5#2#6}{, #3#1#4 to #5#2#6}{ and #3#1#4 to #5#2#6}

\newcommand{\sampletext}{\noindent This is a sample text for testing purposes}

\begin{document}

    \chapter{My Chapter}

    \sampletext \endnote{My End Note 1 \label[endnote]{en:endnote1}}

    \sampletext \endnote{My End Note 2 \label[endnote]{en:endnote2}}

    \sampletext \endnote{My End Note 3 \label[endnote]{en:endnote3}}

    \sampletext \endnote{My End Note 4 \label[endnote]{en:endnote4}}

    \sampletext \endnote{My End Note 5 \label[endnote]{en:endnote5}}

    \sampletext \endnote{My End Note 6 \label[endnote]{en:endnote6}}

    \sampletext \endnote{My End Note 7 \label[endnote]{en:endnote7}}

    \sampletext \endnote{My End Note 8 \label[endnote]{en:endnote8}}

    \sampletext \endnote{My End Note 9 \label[endnote]{en:endnote9}}

    \vspace{\baselineskip}



    \cref{en:endnote1,en:endnote2,en:endnote3}

    \cref{en:endnote4,,en:endnote5,,en:endnote6}

    \cref{en:endnote1,en:endnote2,en:endnote3,en:endnote5,en:endnote6,en:endnote9}

    \cref{en:endnote2,en:endnote3,en:endnote5,en:endnote6,en:endnote7,en:endnote8,,en:endnote9}

    \cref{en:endnote1,en:endnote2,en:endnote3,en:endnote5,en:endnote6,en:endnote7,en:endnote8,en:endnote9}


    \printendnotes[custom]

\end{document}
0

enter image description here

I found the in Cleveref won't work with enotez

    \ExplSyntaxOn
    \cs_set_protected:Npn \enotez_endnote_mark:n #1
      {
        \int_gincr:N \g__enotez_endnote_id_int
        \quark_if_no_value:nTF {#1}
          {
            \refstepcounter {endnote}
            % \show \theendnote
            % \cs_gset:cpx {@currentlabel} {\theendnote}
            \enotez_write_mark:xn
              { \int_use:N \g__enotez_endnote_id_int }
              { \theendnote }
          }
          {
            \cs_gset:cpn {@currentlabel} {#1}
            % \cs_gset_eq:NN \theendnote \@currentlabel
            \enotez_write_mark:xn { \int_use:N \g__enotez_endnote_id_int } {#1}
          }
        \bool_if:NT \l__enotez_disable_bool
          {
            \int_gdecr:N \g__enotez_endnote_id_int
            \addtocounter {endnote} {-1}
          }
      }
    \ExplSyntaxOff


Full code

\documentclass{book}
\usepackage[x11names]{xcolor}

\usepackage{hyperref}
\hypersetup{linkbordercolor=DodgerBlue3, linkcolor=DodgerBlue3, colorlinks=true}

    \usepackage{enotez}

            \renewcommand{\theendnote}{\thechapter.\alph{endnote}}
            \setenotez{list-name=End Notes of Chapter \thechapter}
            \setenotez{backref=true}

        \DeclareInstance{enotez-list}{custom}{paragraph}{
            heading=\chapter*{#1},
            % Spacing
            notes-sep=0.5\baselineskip,
                % Default=0.5\baselineskip
        %
            % Styling of the printed end notes
        %
                % Notes
                format=\normalfont,
        %       
                % Numbering
                number-format=\normalfont,
        %
            % Notes numbering
            number=#1\hspace{3mm}
                                                        }



        \ExplSyntaxOn
        \cs_set_protected:Npn \enotez_endnote_mark:n #1
        {
            \int_gincr:N \g__enotez_endnote_id_int
            \quark_if_no_value:nTF {#1}
            {
                \refstepcounter {endnote}
                % \show \theendnote
                % \cs_gset:cpx {@currentlabel} {\theendnote}
                \enotez_write_mark:xn
                { \int_use:N \g__enotez_endnote_id_int }
                { \theendnote }
            }
            {
                \cs_gset:cpn {@currentlabel} {#1}
                % \cs_gset_eq:NN \theendnote \@currentlabel
                \enotez_write_mark:xn { \int_use:N \g__enotez_endnote_id_int } {#1}
            }
            \bool_if:NT \l__enotez_disable_bool
            {
                \int_gdecr:N \g__enotez_endnote_id_int
                \addtocounter {endnote} {-1}
            }
        }
        \ExplSyntaxOff

\usepackage{cleveref}
\crefformat{endnote}{End Note #2#1#3}
\crefrangeformat{endnote}{End Notes #3#1#4 to #5#2#6}
\crefmultiformat{endnote}{End Notes #2#1#3}{ and #2#1#3}{, #2#1#3}{ and #2#1#3}
\crefrangemultiformat{endnote}{End Notes #3#1#4 to #5#2#6}{ and #3#1#4 to #5#2#6}{, #3#1#4 to #5#2#6}{ and #3#1#4 to #5#2#6}

\newcommand{\sampletext}{\noindent This is a sample text for testing purposes}

\begin{document}

    \chapter{My Chapter}

    \sampletext \endnote{My End Note 1} \label{en:endnote1}

    \sampletext \endnote{My End Note 2} \label[endnote]{en:endnote2}

    \sampletext \endnote{My End Note 3} \label[endnote]{en:endnote3}

    \sampletext \endnote{My End Note 4} \label[endnote]{en:endnote4}

    \sampletext \endnote{My End Note 5} \label[endnote]{en:endnote5}

    \sampletext \endnote{My End Note 6} \label[endnote]{en:endnote6}

    \sampletext \endnote{My End Note 7} \label[endnote]{en:endnote7}

    \sampletext \endnote{My End Note 8} \label[endnote]{en:endnote8}

    \sampletext \endnote{My End Note 9} \label[endnote]{en:endnote9}

    \vspace{\baselineskip}


    \cref{en:endnote1}

    \cref{en:endnote1,en:endnote2,en:endnote3}

    \cref{en:endnote4,,en:endnote5,,en:endnote6}

    \cref{en:endnote1,en:endnote2,en:endnote3,en:endnote5,en:endnote6,en:endnote9}

    \cref{en:endnote2,en:endnote3,en:endnote5,en:endnote6,en:endnote7,en:endnote8,,en:endnote9}

    \cref{en:endnote1,en:endnote2,en:endnote3,en:endnote5,en:endnote6,en:endnote7,en:endnote8,en:endnote9}

    \AfterNextEndnotesList{A sample of text that comes before end note list}
    \AtNextEndnotesList{A sample of text that comes after end note list}
    \printendnotes[custom]

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.