Hi Sijo! Thanks for your helpful suggestion. I did think this had solved it, but I’ve run into some further complications, which I think are probably an artefact of how here works.
I’m currently using this code:
// this adds the handout icon in the appropriate margin
// handouticon is a small image, defined elsewhere
#let hd(words) = {
set text(blue)
underline(overline[*#words*])
context {
//are we less than halfway across the page?
if here().position().x.abs < page.width * 50% {
//if so, stick it in the left column and fiddle the exact position a bit
place(left, dy: -1.5em, dx: -1.5cm, block(image(handouticon, width: 1cm)))
} else {
//otherwise, use the right column and fiddle the exact position a bit
place(right, dy: -1.5em, dx: 1.5cm, block(image(handouticon, width: 1cm)))
}
}
}
This does put the handout icon in the correct margin. However, the position varies slightly. For example:
Give players #hd[Handout]
- Give players #hd[Handout]
- Give players #hd[Handout]
- Give players #hd[Handout]
The first line leaves the handout icon significantly below the triggering text. For the remaining lines, the icon appears immediately after the text, not in the margin.
Worse, if you try changing the bullet list, any combination of indents produces a different set of positions for all the icons! For example,
Give players #hd[Handout]
- Give players #hd[Handout]
- Give players #hd[Handout]
- Give players #hd[Handout]
is different from
Give players #hd[Handout]
- Give players #hd[Handout]
- Give players #hd[Handout]
- Give players #hd[Handout]
#here seems to behave oddly (to me) which seems a likely source for this behaviour. For example:
- #context [I am located at #here().position()]
#context [I am located at #here().position()]
- #context [I am located at #here().position()]
#context [I am located at #here().position()]
Gives the following:
But introducing a single space in the second line changes the Y values for the first and third lines, even though they do not move.
- #context [I am located at #here().position()]
#context [I am located at #here().position()]
- #context [I am located at #here().position()]
#context [I am located at #here().position()]
(adding a space to the fourth line changes the Y value for the third line, but not for the first)
Can anyone tell me what, exactly, #here is checking the position of? This might help clarify the problem. Is it the upper leftmost pixel of some element, or the exact midpoint? Does it matter whether there’s a parent element (which might explain the behaviour of the bullet lists)?