TransWikia.com

enotez – printing a single endnote separately (or synchronizing enotez and footnote counters)

TeX - LaTeX Asked by Johannes Reimer on January 23, 2021

My Goal

I’m using the enotez package to place my endnotes on the page margin.

But when inserting a hyperlink I want to tyeset the URL as a "standard" LaTeX footnote.

Nevertheless, the footnote/endnote counter should be continuous (1, 2, 3, …) and not as in the MWE interrupted (1, 1, 2, …), the "standard" footnote being the bold one here.


MWE

documentclass[12pt, a4paper]{article}
usepackage[a4paper,left=30mm,right=45mm]{geometry}


usepackage[english]{babel}
usepackage{blindtext}


usepackage{calc}


usepackage{enumitem}
    setlist{%
        labelindent=0pt,
        font=bfseries,
        labelwidth=1em,
        leftmargin=0pt,
        itemindent=2em,
        labelsep=1em,
    }


usepackage{hyperref}
    newcommand{link}[3]{%
        href{#1}{underline{#2}}%
        footnote{URL:hspace{1em}href{#1}{#1} #3}%
    }


usepackage{marginnote}
    newcommand{minimarginnote}[1]{marginnote{footnotesize#1}}
    setlength{marginparsep}{5mm}
    setlength{marginparwidth}{30mm}


usepackage{enotez}
    setenotez{backref = true}
    % Formatting for endnotes in the 'list' style (option "sidenotes")
    DeclareInstance{enotez-list}{sidenotes}{list}{%
        heading = {footnotesizetextbf{#1:}},
        format = footnotesize,
        list-type = enumerate
    }
    % 'Sidenotes' will get printed as margin notes
    newcommand{printsidenotes}{%
        marginnote{%
            printendnotes[sidenotes]
        }
    }


% -------------------------


begin{document}

Here, I'm writing some lines about my problem and what I'm intending to do. I hope you get what I mean. This is a ``before'' endnoteendnote{This is an endnote.}.

In this paragraph, I'm using a link{https://tex.stackexchange.com/}{hyperlink}{This footnote should be number textbf{2}.} with a ``standard'' footnote in order to demonstrate my problem.

Now I just need to insert the ``after'' endnoteendnote{This is another endnote. But it should be number textbf{3}.} in this paragraph.

printsidenotes[-5baselineskip]

end{document}

Results

Body:

Result of MWE (Body)

Footnote:

Result of MWE (Footnote)


Question

Is there any way to either

  • print a single endnote separately, i. e. the endnotes that are typed before the separate footnote get passed to the next printendnotes command or
  • synchronize the counters of enotez and footnote, i. e. the referencing numbers are in the correct order?

One Answer

Teach LaTeX to use the same counter for footnotes and endnotes.

documentclass[12pt, a4paper]{article}
usepackage[a4paper,left=30mm,right=45mm]{geometry}

usepackage[english]{babel}
usepackage{blindtext}
usepackage{enumitem}

usepackage{marginnote}
usepackage{enotez}

usepackage{hyperref} % should be last

% enumitem
setlist{%
    labelindent=0pt,
    font=bfseries,
    labelwidth=1em,
    leftmargin=0pt,
    itemindent=2em,
    labelsep=1em,
}

% marginnote
newcommand{minimarginnote}[1]{marginnote{footnotesize#1}}
setlength{marginparsep}{5mm}
setlength{marginparwidth}{30mm}

% enotez
setenotez{backref = true}
% Formatting for endnotes in the 'list' style (option "sidenotes")
DeclareInstance{enotez-list}{sidenotes}{list}{%
    heading = {footnotesizetextbf{#1:}},
    format = footnotesize,
    list-type = enumerate
}
% 'Sidenotes' will get printed as margin notes
newcommand{printsidenotes}{%
    marginnote{%
        printendnotes[sidenotes]
    }%
}
makeatletter % make footnote use the same counter as endnote
letc@footnotec@endnote
makeatother

% links
newcommand{link}[3]{%
    href{#1}{underline{#2}}%
    footnote{URL:hspace{1em}href{#1}{#1} #3}%
}

%%%% just to make a smaller picture
setlength{textheight}{5cm}

begin{document}

Here, I'm writing some lines about my problem and what I'm intending to do. I hope 
you get what I mean. This is a ``before'' endnoteendnote{This is an endnote.}.

In this paragraph, I'm using a 
link{https://tex.stackexchange.com/}{hyperlink}{This footnote should be number textbf{2}.} 
with a ``standard'' footnote in order to demonstrate my problem.

Now I just need to insert the ``after'' endnoteendnote{This is another endnote. 
But it should be number textbf{3}.} in this paragraph.

printsidenotes[-5baselineskip]

end{document}

You'll notice that I rearranged the code. Having settings for a package just after loading it may seem more practical, but it clutters the preamble. Moreover, settings may be entangled and depend on other loaded packages.

enter image description here

Correct answer by egreg on January 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP