-
Notifications
You must be signed in to change notification settings - Fork 411
fix(typst): left-align cross-ref callouts #14130
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
Merged
+30
−5
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
17e3d78
fix: typst format's callouts show different text alignment with Prefix
mcanouil 24cbef1
fix: warning from Typst
mcanouil d4e00c1
test: callout paragraph alignment with cross-ref ID
gordonwoodhull 2f35b17
changelog: add entry for #12803 callout alignment fix
gordonwoodhull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
tests/docs/smoke-all/typst/callout-paragraph-alignment.qmd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| --- | ||
| title: "Callout Paragraph Alignment" | ||
| format: | ||
| typst: | ||
| keep-typ: true | ||
| _quarto: | ||
| tests: | ||
| typst: | ||
| ensurePdfTextPositions: | ||
| - # Paragraphs inside cross-referenced callout should be left-aligned | ||
| - subject: "ShortLine" | ||
| relation: leftAligned | ||
| object: "LongerParagraph with additional words" | ||
| tolerance: 2 | ||
| - [] | ||
| noErrors: default | ||
| --- | ||
|
|
||
| ::: {.callout-tip #tip-alignment} | ||
| ## Alignment Test | ||
|
|
||
| ShortLine | ||
|
|
||
| LongerParagraph with additional words filling out this line. | ||
| ::: |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The hardcoding to
lefthere is a little concerning, because it means that in general it won't be possible to affirmatively choose to centerfigurecontent. Or am I missing something?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.
This is just for callouts? Do we support non-left callout content?
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.
Yes, I'm fiddling to see another approach that would let users define something that would allow changing the alignment while keeping cross-ref callouts/ non cross-ref consistent.
not directly.
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.
Let me scope the align() to allow figure show rule like the one from Andrew to work.
Uh oh!
There was an error while loading. Please reload this page.
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.
So, here are the results:
Setting align() inside the show rule either as I did or adding a new rule, like the one from Andrew will forbid any change by the users.
One alternative if we want to set align and allow users to change it would be to use state context variable, but this only change cross-ref callouts.
Then users can do:
Uh oh!
There was an error while loading. Please reload this page.
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.
If we want this customisation of alignement to work also for non-crossref, it would require more changes: either in Lua to surround calls to callouts with
#context align(quarto-callout-align.get(), [,], or create a wrapper which contains this, then update the Lua filter to call the wrapper.-> The current
#callout()has no selector that would allow changing alignment from a show rule.Uh oh!
There was an error while loading. Please reload this page.
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 don't see a (easy) way to keep cross-ref/non cross-ref consistent in all scenarios.
Blocks inherit from the context in which they are called.
As stated before, if we set
set align(left),align(left)[..., or set a show rule, it means the alignment is hardcoded and cannot be changed unless removed by users.Uh oh!
There was an error while loading. Please reload this page.
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 have the changes ready with the state variable.
This will makes callouts no longer inherit from context (page, column, etc.)
Screen.Recording.2026-02-27.at.21.56.05.mov
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, I should have qualified my "little concerning" more strongly. I'm actually happy with the original PR as it was. This
statebusiness is pretty cool, but I think it's a bigger change than I'm ready to put into 1.9 at this stage.Uh oh!
There was an error while loading. Please reload this page.
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.
The state variable is really good when you want to control the state of something across context changes.
The main use in Typst is usually for counters.
For reference, the code from the screencast:
quarto-cli/src/resources/filters/customnodes/callout.lua
Line 322 in 2f35b17
quarto-cli/src/resources/formats/typst/pandoc/quarto/definitions.typ
Line 165 in 2f35b17
And this in
definitions.typor anywhere before content: