The context is collaborative latex writing using GIT and some online repository. I have a simple macro that uses a counter to index notes in a pdf, which puts a number in the margin:


\newcommand{\note}[1]{% a simple margin note
        \refstepcounter{mynote}% step counter
        {\color{red} ToNote;~#1
        \marginnote{\color{red}\mbox{\textbf{[\themynote]}}}}% the note
Here is some text \note{with a note.}


The problem with this solution is that the labels will change (in general) each time a new note is added in the text. This makes it hard to discuss when several versions are pushed/merged, with text edits and new notes added.

I have no MWE for this as I am not sure how I should proceed: would writing some data in an auxiliary file be optimal ? Maybe there would be a way to use the hash of the last commit ? That would probably lead to rather random and annoying label names though.

enter image description here

  • 1
    unrelated but you are missing a % after #1 (otherwise you get at least a word space and possibly a line break between the text and the node holding the marginpar) – David Carlisle Dec 13 '16 at 12:44

This is really no different to \section{hello} or any other automatically numbered thing.

The standard latex way would be to use \note{\label{abc}some text here} then you have the internal stable identifier label abc which you can refer to in discussion (or in the document as \ref{abc}) even if the text or number of the note changes.

  • Well I suppose I wanted to make it simpler for my collaborators, so that they did not to have to add a label by hand every time, but maybe that's definitely the only rather simple way to go. – picop Dec 13 '16 at 15:42

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.