# Endnotes instead of footnotes and parencite with page numbers

I am looking to transfer \parencites and \footnotes to endnotes. Following this thread, I half succeeded. It works beautifully for every instance, except for one where there is a page argument (Example 5).

\documentclass{article}
\usepackage[backend=biber,
style=authoryear-comp]{biblatex}
\begin{filecontents}{\ref.bib}
@article{A,
author = {Doe, Jane and Doe, John},
title = {Title},
journal = {Journal of Something},
volume = {1},
number = {1},
pages = {1-29},
year = {1997},
type = {Journal Article}
}
@article{B,
author = {Doe, Janelle and Doe, Jack},
title = {Title},
journal = {Journal of Something},
volume = {1},
number = {1},
pages = {1-29},
year = {2000},
type = {Journal Article}
}
@article{C,
author = {Doe, Jasmin and Doe, Jared},
title = {Title},
journal = {Journal of Something},
volume = {1},
number = {1},
pages = {1-29},
year = {2001},
type = {Journal Article}
}
@article{D,
author = {Doe, Janelle and Doe, Jack},
title = {Title},
journal = {Journal of Something},
volume = {1},
number = {1},
pages = {1-29},
year = {2002},
type = {Journal Article}
}
@article{E,
author = {Doe, Janelle and Doe, Jack},
title = {Title},
journal = {Journal of Something},
volume = {1},
number = {1},
pages = {1-29},
year = {2004},
type = {Journal Article}
}
\end{filecontents}

\addbibresource{ref.bib}

\usepackage{endnotes}

\let\footnote=\endnote
\renewcommand{\parencite}[1]{\footnote{\cite{#1}}}

\begin{document}

Example\footnote{Text.}.
Example\parencite{A}.
Example\parencite{A,B,C,D,E}.
Example\footnote{\cite[31--32]{A} More text after cite.}.
Example\parencite[337]{A}.

\theendnotes
\printbibliography
\end{document}


## 1 Answer

You should include an optional argument in \renewcommand so that it can deal with the prenote.

\renewcommand{\parencite}[2][]{\footnote{\cite[#1]{#2}.}}


Depending on your usage, this is perhaps less than ideal. It won't deal with postnotes, also not with parencites etc. The conversion of parencite to footnote/endnote will also require local intervention because of position relative to punctuation (usually parencite will follow a space and be followed by a period, while footcite will follow a period and be followed by a space). But I'm following your initial approach to the issue here.

The result is: