Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Towards a more flexible margin-note implementation #20

Open
alarsyo opened this issue Jan 27, 2025 · 3 comments
Open

Towards a more flexible margin-note implementation #20

alarsyo opened this issue Jan 27, 2025 · 3 comments

Comments

@alarsyo
Copy link

alarsyo commented Jan 27, 2025

Hi! Thanks for the very useful package, I'm opening this issue to start a discussion around margin notes. Here is the issue that I'm hitting in another package: nogula/tufte-memo#5, prompting me to discuss things here :)

So tufte-memo uses drafting's margin notes to implement its own margin notes (which work like numbered footnotes), but is hitting issues related to how the current margin-note interface works:

  • either dy is left to auto, and notes are automatically shifted to not overlap, as much as possible
  • or dy is set to a value, and notes are not automatically shifted when overlapping

tufte-memo currently made the choice to set dy to -2em to try to align a margin note with the line where it originated (instead of starting the note "1 line below", which seems to be the default for drafting). But in doing so, its users miss out on the auto-shift feature.

I think there are several solutions to this problem:

  • The ergonomic "auto-shift" feature could be decoupled from dy: as a user, I could hint to where I want the note to be placed by default, AND want the package to move it to the best place should it overlap with another note.
  • drafting could provide a global setting for how margin notes should be positioned relative to the line where they were created (this would be different from dy, which is a granular, per-note adjustment)
  • If you think this is out of scope for drafting, then tufte-memo should implement its own margin note rendering logic (or even better, depend on a common hypothetical margin-notes package which is flexible enough to suit both tufte-memo and drafting's use cases?)
  • Maybe it's already possible to achieve such functionality, in this case I couldn't find how :)
@alarsyo alarsyo changed the title Towards a more general margin-note implementation Towards a more flexible margin-note implementation Jan 27, 2025
@ntjess
Copy link
Owner

ntjess commented Jan 27, 2025

Thanks for the issue request! It's definitely planned, and ideas around modifying the "margin trail" and positioning already came up in the most recent PR (see #18 (comment)). Curious if @Tinggaard has thoughts around it since they brought up the modification initially

@Tinggaard
Copy link
Collaborator

As Nathan said, the plan is to allow the user to move the default placement of the note, which would resolve you issue.

As a temporary workaround, you could maybe do something like this:

#import "@preview/drafting:0.2.1": *

#set page(paper: "a7", flipped: true, margin: (right: 3cm))

#let my-rect(
  stroke: none,
  fill: none,
  width: 0pt,
  body
) = move(
  dy: -1.57em,
  rect(
    stroke: stroke, 
    fill: fill, 
    width: width, 
    body
  )
)

#set-margin-note-defaults(rect: my-rect)

#set-page-properties()

#lorem(30)
#margin-note[hello]
#margin-note(stroke: blue)[hello]
#lorem(20)

Image

It is very hacky, I know.
Currently, the line to the note is drawn far into the margin, and thus moving the note only a half a line (or multiple lines) up or down will leave you with a funky layout that doesn't make much sense...

@alarsyo
Copy link
Author

alarsyo commented Jan 27, 2025

Awesome, I'd missed this discussion! Thanks for the quick replies :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants