Note: This posting has been augmented to reflect a corollary issue. Please refer to the UPDATE below:
I'm seeing the following error "Undefined control sequence" when using MWE below ...
./Fnote.tex:15: Undefined control sequence. \hyper@normalise ...M{ }\catcode `%\active \let % @percentchar \let %@per... l.15 ...t amet.\footnote{\url{https://google.com}}
I'm using Scrivener with LaTeX. Scrivener does not support endnotes natively, so I've tried to use the following \fnote macro to accommodate endnotes.
- The macro first tests for the presence of an endnote (e.g. if the text string begins with the character @ 'at' sign), then if present
- strips the @ 'at' sign from the beginning of the endnote, then
- calls the \endnote macro using whatever text follows the @ 'at' sign, then
- if no @ 'at' sign is found, the text string is treated as a footnote.
If the macro worked, it would have allowed for the use of footnotes as endnotes, as endnotes are not natively supported within Scrivener.
Any and all thoughts or comments greatly appreciated.
\documentclass{article}
\usepackage{endnotes} %
\usepackage{ifthen}
\usepackage{xstring}
\usepackage{hyperref}
\let\fnote\footnote
\renewcommand{\footnote}[1]{
\IfBeginWith{#1}{@}
{\endnote{\StrDel[1]{#1}{@}}} %%
{\fnote{#1}}
}
\begin{document}
Lorem ipsum dolor sit amet.\footnote{\url{https://google.com}}
% Nesting of \footnote{ ... \url{...} ... } throws an error.
\theendnotes %
\end{document}
UPDATE: As per Domenjoud's suggestion I am adding the results of a followup item posted earlier. Domenjoud's solution to the original post (utilizing an initial @ character to switch from Footnotes to Endnotes) has worked extremely well. Yet, the attempt to extend Domenjoud's solution for use with footnotemark+footnotetext has revealed issues.
In the following MWE, I've highlighted how the footnote-to-endnote shift behaves when the initial @ character is used to shift a footnote to endnote using footnotemark+footnotetext.
\documentclass{article}
\usepackage{endnotes}
\usepackage{hyperref}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage[T1]{fontenc}
% \footnote -> \fnote
\let\fnote\footnote
\renewcommand\footnote[1]{\xfnt#1\empty\xfnt}
\long\def\xfnt#1#2\xfnt{%
\def\tempa{#1}%
\def\tempb{@}%
\ifx\tempa\tempb
\endnote{#2}%
\else
\fnote{#1#2}%
\fi
}
% \footnotetext -> \fnotetext
\let\fnotetext\footnotetext
\renewcommand\footnotetext[1]{\xfntext#1\empty\xfntext}
\long\def\xfntext#1#2\xfntext{%
\def\tempc{#1}%
\def\tempd{@}%
\ifx\tempc\tempd
\endnote{#2}%
\else
\fnotetext{#1#2}%
\fi
}
% Color endnotes red
\makeatletter
\renewcommand*\makeenmark{\hbox{\textcolor{red}{\textsuperscript{@Alph{\theenmark}}}}}
\makeatother
% Change endnotes to Alph
\makeatletter
\def\enoteformat{%
\rightskip\z@ \leftskip\z@ \parindent=1.8em
\leavevmode{\setbox\z@=\lastbox}\llap{%
@Alph\theenmark.\enskip}%
}
\makeatother
\begin{document}
\lipsum[1][1-3] (\textcolor{cyan}{1st \textbf{Foot}note} via "\textcolor{purple}{\textbf{footnote -> fnote}}").,\footnote{This is \textcolor{cyan}{1st \textbf{Foot}note} via "\textcolor{purple}{\textbf{footnote -> fnote}}". Google. \url{http://www.google.com}} Works Great! \par
\par
\lipsum[1][3-4] (\textcolor{cyan}{1st \textbf{End}note} via "\textcolor{purple}{\textbf{footnote -> fnote}}").,\footnote{@,This is the \textcolor{cyan}{1st \textbf{End}note} via "\textcolor{purple}{\textbf{footnote -> fnote}}". Google (Germany). \url{http://www.google.de}} Also works great !\par
\par
\lipsum[2][1-3] (\textcolor{cyan}{2nd \textbf{End}note} via "\textcolor{violet}{\textbf{footnotetext -> fnotetext}}").\footnotemark;\lipsum[2][4-7] Doesn't work so great ... :( \par
\footnotetext{@,\textcolor{cyan}{2nd \textbf{End}note} via "\textcolor{violet}{\textbf{footnotetext -> fnotetext}}". CNN (US). \url{https://www.cnn.com}} \par
\lipsum[3][1-3] (\textcolor{cyan}{3rd \textbf{End}note} via "\textcolor{violet}{\textbf{footnotetext -> fnotetext}}").\footnotemark \lipsum[3][4-7] Also doesn't work so great ... :( \par
\footnotetext{@,\textcolor{cyan}{3rd \textbf{End}note} via "\textcolor{violet}{\textbf{footnotetext -> fnotetext}}". CNN Europe. \url{https://www.cnn.com/europe}} \par
\theendnotes % Print the endnotes
\end{document}
Notice how Endnotes
and
fail to replace
and
respectively, and are significantly offset below where they should appear.
When footnotemark+footnotetext are used in conjunction with the @ sign in a LaTeX minipage to convert a footnote to an endnote, the offset is even more pronounced.
Any thoughts as to how I might properly replace
and
with
and
respectively while retaining the ability to use the @ character to shift a footnote to an endnote would be appreciated.
Thank you.


The code works fine if I include the URL as an endnote, but NOT as a footnote. Any Ideas? – Fenote Nov 21 '21 at 00:58
\xfnttook\urlas its first argument and the url without the braces as its second argument. The braces were stripped because the argument is a single group. The trick is to add\emptyafter the argument so that it does consist anymore in a single group and the braces are not stripped. I updated the code. – Eric Domenjoud Nov 21 '21 at 10:27,
– RosesBouquet Nov 24 '21 at 04:36However, when I add Domenjoud's code from above that tests for endnotes (when the at '@' sign is the first character in the text of an endnote), *ALL* the endnotes marks revert from capital letters (A,B,C,...) back to numbers (1,2,3 ...). Any thoughts? Thank you!
\makeenmark. – Eric Domenjoud Nov 24 '21 at 08:22\makeatletter \def\enoteformat{% \rightskip\z@ \leftskip\z@ \parindent=1.8em \leavevmode{\setbox\z@=\lastbox}\llap{\theenmark.\enskip}% } \makeatother.
I need to move the endnote marker into the margin (Bringhurst-style) as shown in the answer to the above post.
The above code works only for numeric endnotes. How can I move the alpha endnote marker into the margin? [1]: https://tex.stackexchange.com/questions/286339/changing-the-look-of-the-endnotes-on-the-notes-page-theendnotes
– RosesBouquet Nov 24 '21 at 09:31\enoteformatjust replace\llap{\theenmark.\enskip}with\llap{\@Alph\theenmark.\enskip}– Eric Domenjoud Nov 24 '21 at 13:31\foonotemarkand\footnotetextis that the indication that the note should be turned into an endnote is provided only in the argument of\footnotetext. At the time you use\footnotemark, there is no way to know that it should actually use\endnotemarkinstead. I don't see a way around. – Eric Domenjoud Mar 25 '22 at 09:10