I'm working on a project very similar to the one described in this question, only for various reasons I'm using ConTeXt rather than that poster's use of XeLaTeX.

I too am typesetting a text with verse/line numbers in the margin and am interested in combining them should there happen to be two that end up on the same line, dividing them with a slash or a comma or something like that.

The comments there allude to a possible solution in ConTeXt with the possible use of \EveryLine, but I have not yet been able to figure out how to implement a solution using that command - I think I'm a bit newer at various implementations of TeX than the previous questioner! Is there a reliable way to implement this in ConTeXt?


A very simple MWE:


\inmargin{1}Now we are engaged in a great civil war.
\inmargin{2}We are testing whether that nation or any nation so conceived 
and so dedicated, can long endure.
\inmargin{3}We are met on a great battle-field of that war.


Results in:

The result

I would like the 1 and 2 not to be overlapping, nor to be stacked like the \setupmargindata[stack=yes] would get me, but rather to automatically combine those that would overlap to get something like "1,2" that would look like:

Desired output

I would appreciate any help...thank you!

  • In the project I work on we had a similar problem. A colleague of mine solved it by traversing each line of the document with Lua and building a string, that separates each margin datum with a comma. This string is stored in a separate file that is used to run a PERL script with regexes that produce the desired effect. If you're interested, I can write a more detailed answer with code etc. -- but I'd prefer a simpler solution that only relies on ConTeXt, too.
    – meliade
    Mar 15, 2018 at 15:07
  • I have looked at the margin notes code and it appears to me as if it was possible to add this possibility as an alternative to the stack option. It's a good idea to ask about this on the mailing list mailman.ntg.nl/mailman/listinfo/ntg-context Mar 17, 2018 at 8:34
  • 1
    @meliade I would be quite interested in your solution. Are you still willing to write up an answer?
    – TeXnician
    Dec 5, 2018 at 12:15


You must log in to answer this question.

Browse other questions tagged .