-
Notifications
You must be signed in to change notification settings - Fork 22
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
AMS template does not support math mode in title #12
Comments
I am considering to support passing arbitrary content for |
@laurmaedje, I have a solution to this problem (which is also mentioned here): To use a string or content for the title of a document, the only problem is to set the title metadata properly, which has to be of type string. I wrote a function named set document(title: extractText(title), author: authors.map(author => author.name)) The helper function can be outsourced and imported or included in the template: #let extractText(element) = {
if type(element) == content {
if element == [ ] { return " " }
return extractText(element.fields()).trim() }
if type(element) == dictionary { return extractText(element.values()) }
if type(element) == array {
return element.fold("", (res, item) => res + extractText(item))
}
if type(element) == bool { return "" }
return str(element)
}
#assert.eq(extractText("hey"), "hey")
#assert.eq(extractText(12), "12")
#assert.eq(extractText(12.0), "12")
#assert.eq(extractText(12.1), "12.1")
#assert.eq(extractText(false), "")
#assert.eq(extractText(version(1,2,3)), "1.2.3")
#assert.eq(extractText((1,2,3)), "123")
#assert.eq(extractText((4,(1,"Hey",12.0),(hey: 2))), "41Hey122")
#assert.eq(extractText([This is some text.]), "This is some text.")
#assert.eq(extractText([This is _some_ text.]), "This is some text.")
#assert.eq(extractText([ Is $x^2$ an _even_ Function? ]), "Is x2 an even Function?")
#assert.eq(extractText([Is $x^2$ an _even_ Function?]), "Is x2 an even Function?")
#assert.eq(extractText([[Hey] [you]]), "[Hey] [you]") What do you think? |
Related to typst/typst#1623 (comment)
I wanted to have a
content
for the title, so it can have math in it, but the current template passes the entire title toset document(title: title, abstract: abstract)
and gives an error becausetitle
should bestring
.I am interested in extracting the plain text representation of the content for the title like mentioned in the linked issue, but I have failed to do so.
Meanwhile, do you think it would be interesting to avoid breaking compilation of titles with
content
type by doing something likeThe text was updated successfully, but these errors were encountered: