-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Adding new features to the Typst template #9970
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
base: main
Are you sure you want to change the base?
Conversation
Hi @jgm, I don't want to bother you if this is already on your radar, but should I add you as a reviewer (for when you have time)? I'm not 100% sure of the norms for contributions here. |
Sorry for the delay on this! |
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.
Thanks for this PR, and sorry I took so long to review it. I made a number of queries and comments, which you can look over.
$if(mathfont)$ | ||
mathfont: ($for(mathfont)$"$mathfont$",$endfor$), | ||
$endif$ | ||
$if(codefont)$ | ||
codefont: ($for(codefont)$"$codefont$",$endfor$), | ||
$endif$ |
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.
Curious why you used $for$
here. mathfont
would normally be expected to be a string in pandoc templates.
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 a bit of an odd one, but Typst uses a vector of fonts because it automatically falls back to the next font if one is not found. This use of $for$
keeps that idea, where you might set (for example) EB Garamond
and then Garamond
. If EB Garamond
is downloaded, then the template uses that. If not, it falls back to the (less featured, but more common) Garamond
. This goes to the design choice that Typst will cycle through all the fonts chosen until it finds one available or ends up back at the default.
$if(citecolor)$ | ||
citecolor: [$citecolor$], | ||
$endif$ |
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.
It works in content like this, with the escaped #
?
citecolor: [\#ffffff]
You've tested I assume?
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 can confirm that this works, as I'm currently using it in a custom template. If there's something that you don't like about it, happy to brainstorm alternatives.
data/templates/template.typst
Outdated
author: authors.map(author => content-to-string(author.name)), | ||
author: authors.map(author => content-to-string(author.name)).join(", ", last: ", and "), |
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 like this because and
is an English word; anyone writing in another language would need to change the template. We could consider using &
, or just use commas.
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.
Happy to go either way here. I pushed a change to make it &
. I can make it anything that you think is least problematic, even removing the last
special case.
leading: linestretch * 0.65em | ||
) |
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.
What does the leading
do here, and why is it needed with linestretch? Is the result the same as Typst's defaults when the default linestretch is used?
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.
leading
sets the space between lines. Here, mixing it with linestretch
ensures that a value of 1 * 0.65em = 0.65em
or Typst's default single-spaced. For double spacing, then 1.3 = 2 * 0.65em
. Here, this setting just makes it explicit so that setting 1
for single, etc, all map onto what is expected.
data/templates/template.typst
Outdated
#text(weight: "bold", size: 1.5em)[#title] | ||
#text(weight: "bold", size: 1.5em)[#title #if thanks != none { | ||
footnote(thanks, numbering: "*") | ||
counter(footnote).update(n => n - 1) |
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 assume this is needed because otherwise the first note would be 2
? That's a bit unexpected when numbering
is explicitly specified, but maybe Typst works that way? (I'd consider it a bug if so.)
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, so the numbering is a wrapper on top of a counter for footnotes. The numbers for footnotes are the counting numbers (1, 2, ...) and don't update even when you change the style. So this simply says: use * for the title, then set it back to 1 so that it can use 1, 2, ... for future footnotes.
Sorry for the long delay on this. I've been on the academic job market and a bit crazed. I'm using Quarto + pandoc + Typst for my dissertation and will resolve these over the next few days while in the midst of this. |
d05ca30 handles the merging with the pagenumber change |
Hi @jgm. I've rerequested your review for when you have a chance. These are all now set to be less opinionated and better fit with the default typst settings, especially removing colors and fonts unless specified. |
Apologies, spoke too soon on the last message. Just went through and triple checked things and now it is ready for re-review. |
data/templates/template.typst
Outdated
} | ||
#if abstract != none { | ||
block(inset: 2em)[ | ||
#text(weight: "semibold")[Abstract] #h(1em) #abstract |
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.
It would be nice not to force the use of an English word "Abstract" here. People write in other languages, too. If typst doesn't have a way of retrieving a localization of this, we colud introduce $abstract-title$
, and I could set it to a localized default in the Tyspt writer.
looks pretty good -- I made one comment about "Abstract." |
The other thing that needs to be done is modifying MANUAL.txt so that the new variables are documented. |
TODO (for me): set |
abstractTitle <- translateTerm Abstract and then when setting template variables, defField "abstract-title" abstractTitle . |
The MANUAL.txt and abstract-title defaults are now updated. Thanks for the review! |
Looks like the branch has to be rebased on to main in order to be merged cleanly. |
eb63b85
to
587dcd4
Compare
So, I just rebased onto main, but I have a strong suspicion that this is not what you wanted. Before doing this, I made a |
@christopherkenny -- I had a look at what may have gone wrong with your rebase. My theory is as follows (please correct me if any of this is wrong!):
To fix this, you could restore your previous version of this branch (via your |
Yeah, that sounds exactly like what happened. Thanks for the help @rnwst. I will get this cleaned up tomorrow. |
aa96126
to
c86ebe6
Compare
Thanks @rnwst, that was exactly it. All cleaned up now. Thanks for the help! |
Looks like you have opted to undo and then redo (after merging |
I was thinking this could all be rebased into one commit (unless there's some strong reason for having more than one commit for this change). |
This implements the changes suggested in #9956, with the exception of the
filecolor
/urlcolor
one. These would require adding some regex to guess the link types. This is theoretically possible to do, but it wasn't clear to me that this is a good thing to put in a default template. Happy to adjust if you have thoughts on this.Some things to note:
#
if that was included. An alternative here is to just do something like:rgb(linkcolor.replace("\\#", "#"))
.