Thanks Hans. The \newinteger approach would always increment the value, regardless of conditionals within the MetaPost code (i.e., it was like legend := "\ConcurrentTextGet" would always invoke the macro just be referencing the MPgraphic and nothing would prevent its execution). This meant that the Get indexes would not correspond to the Set indexes. Switching to \definenumber resolved the issue. There were a few other oddities, such as the "Get" counter incrementing twice. Here's the code: \definenumber[ConcurrentTextSetCounter][prefix=no] \definenumber[ConcurrentTextGetCounter][prefix=no] \setnumber[ConcurrentTextSetCounter][0] \setnumber[ConcurrentTextGetCounter][0] % Map each label as global key/value pairs. \def\ConcurrentTextSet#1{% \incrementnumber[ConcurrentTextSetCounter]% \setxvariable {concurrent} {text:\rawcountervalue[ConcurrentTextSetCounter]} {#1}} % Account for the counter incrementing twice and the index being 1-based. \def\ConcurrentTextGet{% \incrementnumber[ConcurrentTextGetCounter]% \getvariable {concurrent} {text:\number\numexpr1+\rawcountervalue[ConcurrentTextGetCounter]/2\relax}} \startuseMPgraphic{GraphicConcurrent} numeric index; index := 1; % Differentiate between new text blocks and those crossing pages. if (multikind[ index ] = "single") or (multikind[ index ] = "first"): string legend; legend := "\ConcurrentTextGet"; % For new text blocks, write the title. picture p; p := textext.rt( legend ) shifted ulcorner multipars[ index ] shifted (1cm, 0); % Draw the horizontal rule only for the initial text block. draw ulcorner multipars[ index ] shifted (1mm + xpart lrcorner p, 0) -- urcorner multipars[ index ]; % Draw the vertical rule for the initial text block. draw llcorner multipars[ index ] -- ulcorner multipars[ index ] -- ulcorner multipars[ index ] shifted (9mm, 0); draw p; else: % Draw only the vertical rule only when crossing page boundaries. draw llcorner multipars[ index ] -- ulcorner multipars[ index ]; fi \stopuseMPgraphic \definetextbackground[TextConcurrentFrame][ mp=GraphicConcurrent, frame=off, topoffset=1em, leftoffset=1em, before=\blank[2*big], after=\blank, location=paragraph, ] \startsetups concurrent:before \ConcurrentTextSet{% % Be sure to format "a.m." and other special phrases. \expandafter\TextReplacement{% \xmlatt{\getvariable{div}{concurrent}}{data-title}% } } \startTextConcurrentFrame \stopsetups \startsetups concurrent:after \stopTextConcurrentFrame \stopsetups \definestartstop[concurrent][ before=\directsetup{concurrent:before}, after=\directsetup{concurrent:after} ] This allows for typesetting a wider range of pandoc-style Markdown annotations, such as: ::: {.concurrent title="Terminal Berth 5, 3:17 a.m."} text goes here ::: With these changes, the titles now only appear at the start of the demarcated text, in any combination of "concurrent" annotation instances spanning any number of pages. Much appreciated. Cheers! P.S. The following line requires KeenWrite themes: \expandafter\TextReplacement{ ... } For details, see: - https://github.com/DaveJarvis/keenwrite-themes/blob/main/xhtml/xml-blocks.te... - https://github.com/DaveJarvis/keenwrite-themes/blob/main/boschet/replace.tex