Using enotez for getting endnotes at the end AND footnotes on each page (like we used to get from the endnotes package)

endnotesenotezfootnotes

I wish to reproduce the following using the enotez package:

\documentclass{article}
\usepackage{endnotes}

\begin{document}

My text\footnote{my footnote}

\newpage

\theendnotes

\end{document}

The above gives me footnotes and endnotes.

My attempt :

\documentclass{article}
\usepackage{enotez}

\begin{document}

My text\footnote{my footnote}

\newpage

\printendnotes

\end{document}

This is giving my only footnotes.

\documentclass{article}
\usepackage{enotez}
\let\footnote=\endnote

\begin{document}

My text\footnote{my footnote}

\newpage

\printendnotes

\end{document}

This is giving my only endnotes.

How do I get both footnotes and endnotes from enotez package ?

Best Answer

You can define \footnote to issue both \footnote and \endnote; this of course requires to use an alias of the original \footnote command.

\documentclass{article}

\usepackage[papersize={52mm,74mm}]{geometry} % just to make a smaller picture

\usepackage{enotez}

\NewCommandCopy{\enotezfootnote}{\footnote}
\RenewDocumentCommand{\footnote}{om}{%
 \IfNoValueTF{#1}
   {\enotezfootnote{#2}\endnote{#2}}
   {\enotezfootnote[#1]{#2}\endnote[#1]{#2}}%
}
\makeatletter
\setenotez{mark-cs=\@gobble}
\makeatother

\begin{document}

My text\footnote{my footnote}

My text\footnote{my second footnote}

\clearpage
\printendnotes

\end{document}

enter image description here