ntjess / typst-drafting

Some common drafting utilities for the `typst` document typesetter
The Unlicense
52 stars 2 forks source link

Margin notes jump to next page. #8

Closed SebastianJL closed 7 months ago

SebastianJL commented 7 months ago

Possibly related to #5.

Sometimes margin notes jump to the next page, seemingly unwarrented.

image

My quickfix is

#margin-note(dy:2cm)[margin note text]

But of course that dy value changes with every change I make.

SebastianJL commented 7 months ago

I have a new bug, I'll post it here. The note just goes off page, and I couldn't use dy or dx to correct that. image

ntjess commented 7 months ago

Thanks for the report, but I'm having a difficult time reproducing the behavior:

#import "@preview/drafting:0.1.1": set-page-properties, margin-note

#let margin = (left: 2.5cm, right: 2.5cm)  // Increased margins for notes.
#set page(margin: margin, numbering: "1", number-align: center)
#set-page-properties(margin-left: margin.left, margin-right: margin.right)

#for ii in range(5) [
+ #lorem((ii + 1) * 3)#margin-note[test]#lorem((ii + 1)* 3)
]

image

Any chance you are able to attach a MWE so I can debug more easily?

SebastianJL commented 7 months ago

@ntjess Yes for sure. This time the note overlaps the text on the left. It doesn't look exactly the same, but it might be the same thing.

#import "@preview/drafting:0.1.1": margin-note, set-page-properties

#set text(font: "New Computer Modern", lang: "en")
#show par: set par(justify: true)

#let margin = (left: 2.5cm, right: 2.5cm)
#set page(margin: margin, numbering: "1", number-align: center)
#set-page-properties(margin-left: margin.left, margin-right: margin.right)

#lorem(100)#margin-note[Trying to replicate a certain problem.]
#lorem(50)#margin-note[I have no idea how it would happen.]
#lorem(200)#margin-note[But let's still try anyway.]
#lorem(200)#margin-note[But let's still try anyway.]

image

SebastianJL commented 7 months ago

@ntjess Hi, I just wanted to ask if the minimal example was at all helpful for finding the issue.

Meanwhile I found more occasions where the note is placed in the wrong place.

image

ntjess commented 7 months ago

Thanks for the reproducible example! I've fixed the problem from the code you've given, is it possible to provide the source for your other error cases?

SebastianJL commented 7 months ago

Ah very cool. Thanks a lot. Yes I can give you the other cases, but only as full projects. It's not that large though. I'll have to do that later when I am on the computer.

SebastianJL commented 7 months ago

Ok, I just downloaded 2f2950a487b5 and there are still problems in the document. I added you as collaborator in a private repo https://github.com/SebastianJL/master-thesis. You can download and see errors from there.

It's not very long yet so it shouldn't be a problem to find the buggy examples. Please don't share the contents. They are not sensitive but I'd still prefer them to remain private.

Have a quick look at the README.md. I think I documented everything relevant there. Your repo is in a git submodule. In principle you could fix any issues right there.

Thanks for the amazing work 😁.

ntjess commented 7 months ago

Thank you for sharing the code! The error occurs even in this simple case:

#import "typst-drafting/drafting.typ": margin-note, set-page-properties

#let margin = (left: 2.5cm, right: 2.5cm)  // Increased margins for notes.
#set page(margin: margin)
#set-page-properties(margin-left: margin.left, margin-right: margin.right)

c#margin-note[Insert reference]
+ B #margin-note[is this true?]

propagation happen.
#margin-note[s?]

image

I will continue to investigate.

SebastianJL commented 7 months ago

Thanks this fixes all problems. It's sometimes a little weird when you have several large notes close in the text, because the lines start overlapping but I think it's worth it. Especially since I use this only as a temporary annotation tool.