I'm working on a game manual and I'd like to put page references in the margins for key concepts, for example something like this (from Justin Alexander's Legends and Labyrinths):
I can use \marginpar to produce the margin notes. But I would like only one margin note per key concept per page. For example, the word class is used several times in the above example, but there is only one margin note. But when writing my LaTeX source, I don't know what the output pagination will be. So, for example, I might use the word class in two different paragraphs. If they end up on the same page, I only want one note. If they end up on different pages, I want one note on each page.
One solution would be to wait until I've completed the main body of text, then manually go back and add margin notes making sure I don't add duplicates on any given page. But that's a lot of work, and if I need to edit the document after adding the notes I may need to redo it all. So I'm wondering if there's an automated way to do this in LaTeX itself.
I've searched for any package that provides this sort of functionality, but have not found any. I figure there's a not simple solution, but I am willing to try programming my own solution. That said, I'm not very knowledgeable about LaTeX/TeX programming, so any details or references would be greatly appreciated. Thank you,