1

I am trying to send numbered observations to the last page, as shown in the following MWE. How can I obtain the correct numbers to be displayed at the last page? Thank you!

\documentclass{article}

\usepackage{endnotes}

\newcounter{thought}

\def\mythought{%
    \refstepcounter{thought}
    \noindent
    \textbf{Thought \#\thethought:}
    }

%-> Defining the environment for the OBSERVATIONS @ the footnote
\newcommand{\myfnobs}[1]{%
    \let\thefootnote\relax %... suppresses the footnote numbering
    \footnote{\textbf{Observation on thought \#\thethought-} #1}
    }


%-> Redefine the ENDOTES page title:
\renewcommand{\notesname}{My observations}

%-> Defining the environment for the OBSERVATIONS @ last page
\newcommand{\mylpobs}[1]{%
    \let\theendnote\relax %... suppresses the \endnote numbering
    \endnote{\textbf{Observation on thought \#\thethought-} #1}
    }


\begin{document}
\begin{abstract}
    In this MWE I show that the \texttt{endnotes} package doesn't read each \texttt{thought} counter value, but only the last one.
\end{abstract}


\section{Introduction}
The \texttt{endnotes} package is based on the \texttt{\textbackslash footnote} command. The difference: it sends the content to the last page. I created two commands in the preable, as described below

\begin{itemize}
    \item \texttt{\textbackslash myfnobs}, which receives one argument, is the command that places my observations in the footnote of the page where it occurs.

    \item \texttt{\textbackslash mylpobs}, which receives one arguement, is the command that places my observation in the last page of the document.
\end{itemize}

I also defined the macro \texttt{\textbackslash mythought}, where I want to express my thoughts. This is numbered sequentially. For examples, see next section.




\section{Thoughts placed at the footnote}
I want to express three thoughts of mine.

\mythought
Everyday is a good day to start something new in our lives.%
    \myfnobs{This may not be true if we still didn't accomplish what we started last.}

\mythought
It is never late to learn new things.%
    \myfnobs{I believe this has no exception}

\mythought
Tolerance is the key to achieve better world.%
    \myfnobs{Intolerance causes violence, war, and death.}




\section{Thoughts placed at the last page}
Please, let me repeat my three thoughts, but changing the command from \texttt{\textbackslash myfnobs} to \texttt{\textbackslash mylpobs}:

\mythought
Everyday is a good day to start something new in our lives.%
    \mylpobs{This may not be true if we still didn't accomplish what we started last.}

\mythought
It is never late to learn new things.%
    \mylpobs{I believe this has no exception}

\mythought
Tolerance is the key to achieve better world.%
    \mylpobs{Intolerance causes violence, war, and death.}




\section{Final considerations}
Let's finish this issue by adding new page and calling the \texttt{\textbackslash theendnotes} command. Observe that at such page, all the \textbf{Observation on thought \#} receive the value 6 (six), instead of the intended value, differently from what happened to when I called the \texttt{\textbackslash myfnobs}


\newpage
\theendnotes



\end{document}

First page output: enter image description here

Last page output: enter image description here

2

You need to expand \thethought: the footnote text is expanded right away, so there is no problem with it, but \endnote just saves the text without interpreting it.

\documentclass{article}

\usepackage{endnotes}

\newcounter{thought}

\newcommand\mythought{%
  \refstepcounter{thought}%
  \noindent
  \textbf{Thought \#\thethought:}%
}

%-> Defining the environment for the OBSERVATIONS @ the footnote
\newcommand{\myfnobs}[1]{%
  \let\thefootnote\relax %... suppresses the footnote numbering
  \footnote{\textbf{Observation on thought \#\thethought-} #1}
}


%-> Redefine the ENDOTES page title:
\renewcommand{\notesname}{My observations}

%-> Defining the environment for the OBSERVATIONS @ last page
\newcommand{\mylpobs}[1]{%
  \let\theendnote\relax %... suppresses the \endnote numbering
  \begingroup
  \edef\x{\endgroup
    \noexpand\endnote{\noexpand\textbf{Observation on thought \noexpand\#\thethought-} \unexpanded{#1}}%
  }\x
}


\begin{document}
\begin{abstract}
    In this MWE I show that the \texttt{endnotes} package doesn't read each \texttt{thought} counter value, but only the last one.
\end{abstract}


\section{Introduction}
The \texttt{endnotes} package is based on the \texttt{\textbackslash footnote} command. The difference: it sends the content to the last page. I created two commands in the preable, as described below

\begin{itemize}
    \item \texttt{\textbackslash myfnobs}, which receives one argument, is the command that places my observations in the footnote of the page where it occurs.

    \item \texttt{\textbackslash mylpobs}, which receives one arguement, is the command that places my observation in the last page of the document.
\end{itemize}

I also defined the macro \texttt{\textbackslash mythought}, where I want to express my thoughts. This is numbered sequentially. For examples, see next section.




\section{Thoughts placed at the footnote}
I want to express three thoughts of mine.

\mythought
Everyday is a good day to start something new in our lives.%
    \myfnobs{This may not be true if we still didn't accomplish what we started last.}

\mythought
It is never late to learn new things.%
    \myfnobs{I believe this has no exception}

\mythought
Tolerance is the key to achieve better world.%
    \myfnobs{Intolerance causes violence, war, and death.}




\section{Thoughts placed at the last page}
Please, let me repeat my three thoughts, but changing the command from \texttt{\textbackslash myfnobs} to \texttt{\textbackslash mylpobs}:

\mythought
Everyday is a good day to start something new in our lives.%
    \mylpobs{This may not be true if we still didn't accomplish what we started last.}

\mythought
It is never late to learn new things.%
    \mylpobs{I believe this has no exception}

\mythought
Tolerance is the key to achieve better world.%
    \mylpobs{Intolerance causes violence, war, and death.}




\section{Final considerations}
Let's finish this issue by adding new page and calling the \texttt{\textbackslash theendnotes} command. Observe that at such page, all the \textbf{Observation on thought \#} receive the value 6 (six), instead of the intended value, differently from what happened to when I called the \texttt{\textbackslash myfnobs}


\newpage
\theendnotes

\end{document}

enter image description here

By the way, it's useless to repeat \let\thefootnote\relax, unless you hide it inside a group. The first call to \myfnobs will set \thefootnote to \relax globally. Similarly for \theendnote.

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.