Quantcast
Channel: Command that outputs at the end of the document the pages and line numbers where it was used - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 2

Answer by egreg for Command that outputs at the end of the document the pages and line numbers where it was used

$
0
0

You have to expand \arabic{modification} on the spot, or it would be written literally in the auxiliary file for the endnotes.

\documentclass{article}\usepackage{endnotes}\usepackage[pagewise,switch]{lineno}\linenumbers\newcounter{modification}\newcommand{\revised}[2]{%  \stepcounter{modification}%  \begingroup\edef\x{\endgroup    \noexpand\linelabel{ln:line\arabic{modification}}%  }\x  #1%  \begingroup\edef\x{\endgroup    \noexpand\endnote{\unexpanded{#2}. Page \noexpand\pageref{ln:line\arabic{modification}},       Line \noexpand\ref{ln:line\arabic{modification}}, Counter \arabic{modification}}%  }\x}% revision with footnote\begin{document}\revised{New text 1.}{Reason of change 1.}\revised{New text 2.}{Reason of change 2.}\revised{New text 3.}{Reason of change 3.}\nolinenumbers\theendnotes\end{document}

I suggest not to redefine \footnote, but to use \endnote.

enter image description here

The code is less convoluted using xparse that allows to better control expansion. The code from \newcounter{modification} up to \begin{document} can be changed into

\usepackage{xparse}\newcounter{modification}\ExplSyntaxOn\NewDocumentCommand{\revised}{mm} {  \stepcounter{modification}  \jb_revised:fnn { \arabic{modification} } { #1 } { #2 } }\cs_new_protected:Nn \jb_revised:nnn {  \linelabel{ln:line#1}  #2  \endnote{#3.~Page~\pageref{ln:line#1},~Line~\ref{ln:line#1},~Counter~#1} }\cs_generate_variant:Nn \jb_revised:nnn { f }\ExplSyntaxOff

with the same result.


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>