-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add inside / outside margins and todo outline #18
base: main
Are you sure you want to change the base?
Conversation
Thanks for the PR! I'm traveling for holidays this week but should be able to review the code afterward, if that timing is ok for you |
No worries |
Are there any updates @ntjess? |
Thanks for the reminder! It's been a particularly busy week for me, but I will get this reviewed tomorrow. I appreciate your patience 🙂 |
I was also considering adding additional styling to specify the size of the small upward line, as I'm fond of a smaller one in general. Like the ones shown here: But I'm not 100% sure how the path drawing is achieved though, as it seemed to break the layout when I tried to change the size of the line at line 374 Lines 373 to 380 in 769fbbc
|
Something like this? Changing the property From 64d8c48616a8c74e1ca6e655a2fad1c99f91cd2c Mon Sep 17 00:00:00 2001
From: Nathan Jessurun <[email protected]>
Date: Thu, 12 Dec 2024 20:40:47 -0600
Subject: [PATCH] Allow configurable margin caret height
---
drafting.typ | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drafting.typ b/drafting.typ
index a2ba157..96ca03a 100644
--- a/drafting.typ
+++ b/drafting.typ
@@ -33,6 +33,7 @@
rect: rect,
side: auto,
hidden: false,
+ caret-height: 1em,
),
)
#let note-descent = state("note-descent", (:))
@@ -434,8 +435,8 @@
let path-pts = _path-from-diffs(
// make an upward line before coming back down to go all the way to
// the top of the lettering
- (0pt, -1em),
- (0pt, 1em + text-offset),
+ (0pt, -props.caret-height),
+ (0pt, props.caret-height + text-offset),
(dist-to-margin, 0pt),
(0pt, dy),
(1*pct + right-width / 2, 0pt)
@@ -464,8 +465,8 @@
let text-offset = 0.4em
let box-width = props.margin-left - 4 * pct
let path-pts = _path-from-diffs(
- (0pt, -1em),
- (0pt, 1em + text-offset),
+ (0pt, -props.caret-height),
+ (0pt, props.caret-height + text-offset),
(-anchor-x + props.margin-left + 1 * pct, 0pt),
(-2 * pct, 0pt),
(0pt, dy),
--
2.39.5 (Apple Git-154) We can also have a |
Oh my, thanks for a comprehensive review! Edit: This aged well... |
Change page-binding to be `alignment` Set default note fill to `none` Move margin calculations to seperate function Determine text direction based on lang
Not entirely sure what you mean by a margin trail... Is it the path from the location in the text, to the note you wish to customize? |
drafting.typ
Outdated
@@ -398,7 +513,7 @@ | |||
/// - dy (length): Vertical offset from the note's location -- negative values | |||
/// move the note up, positive values move the note down | |||
/// - ..kwargs (dictionary): Additional properties to apply to the note. Accepted values are keys from `margin-note-defaults`. | |||
#let margin-note(body, dy: auto, ..kwargs) = { | |||
#let margin-note(body, dy: auto, ..kwargs) = [ #h(0pt) #{ // h(0pt) forces here().position() to take paragraph indent into account |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really happy about this approach btw, if you have a suggestion...
But setting
#set par(first-line-indent: 1em)
Results in notes in a new paragraph not being place properly
Indeed — in case users want e.g. smooth radius curves instead of rectangular paths or something. Just a thought if we are providing ways to customize the path |
The package does currently not support inside/outside margins afaik, or am I missing something? I see your problem @reverendpaco. The addition was made to allow for an outline entry such that all notes in the document can be listed, along with their content. |
I will see if I can make it work with labels instead of figures, as @ntjess suggested. This way the content would not be displayed twice. |
Huh.. that's funny. You're right. I have no idea how I got here then 😄 . It's especially funny because if I bothered to look at what your PR was, I could see that it has nothing to do with inside/outside auto-location. |
Ok.. Sorry for confusing you and myself. I DO want to use your repo @Tinggaard . You are the one who introduces inside/outside margin (which I needed for my tufte-style layout). I was incorrect to say:
should have said:
I got your names/repos confused. |
@reverendpaco I have removed the hidden figure ( I have also tested your provided MRE, and it does not create an additional footnote unless |
@ntjess, would you care to review again? |
Hey, sorry again for the delay. Yes, I'll be able to review this weekend if it's not too late? Otherwise, I can make time in the next two days. I want to test a few edge cases which requires me to sit down and make the typst documents |
Take your time. I just wanted to make sure the PR was not forgotten :) |
tests/misc.typ
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tinggaard any other good things to test here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that depends on the purpose of the test...
We could basically test all the functionality in margin-note-defaults
, most important is probably something like hidden
and caret-height
.
Also, how is the test evaluated?
let props = ( | ||
fill: note.at("fill", default: defaults.fill), | ||
stroke: note.at("stroke", default: defaults.stroke), | ||
body: note.at("body", default: "<body text unkonwn>"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tinggaard Do you think it's desirable to copy the entire stroke
instead of just the paint
for the outline box, which will preserve dashing etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we could consider using get.text()
from t4t
. This would remove all the styling at least.
I've had the same issue when using it locally and setting a smaller font-size in the notes, which makes the outline look weird if the styling is applied.
As for the stroke, I think it's nice to have the dash
available, as well as possibly the thickness
.
let paint = stroke(note-props.stroke).paint | ||
link( | ||
note.location().position(), | ||
grid( | ||
columns: (1em, 1fr, 10pt), | ||
column-gutter: 5pt, | ||
align: (top, bottom, bottom), | ||
box( | ||
fill: note-props.fill, | ||
stroke: if note-props.stroke == none { | ||
none | ||
} else if paint != note-props.fill { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is of lesser concern (as it seems weird to do), but this panics in the stroke
constructor if note-props.stroke
is none
, which is possible (in the current version).
#set-margin-note-defaults(stroke: none)
As discussed in typst/packages#1315, a port of package to allow a note outline, and usage of inside / outside margins.
It does not take text orientation into account, as it is (to my knowledge) not inferrable. I was contemplating implementing it manually, but saw that it broke the logic for drawing the notes overall, so I disregarded it.
I'm not that experienced in writing in Typst yet, so please let me know if there could be improvements :)