Repository navigation
Conversation
|
In general, Laurenz does not like hyphenated argument names, but I'd say that in this case, it's okay and quite clear. If you think about something equally clear but more concise, that would be preferable! Given that |
outline-title to headingsoutline-title and bookmark-title to headings
| /// as `outline-title`. If `outline-title` is also `{auto}`, the title will | ||
| /// be the same as `body`. | ||
| #[default(Smart::Auto)] | ||
| pub bookmark_title: Smart<Content>, |
There was a problem hiding this comment.
This should probably be a string, since it's going to be stringified in the end anyway as it's PDF metadata.
There was a problem hiding this comment.
I wonder whether we need it at all. Shouldn't outline_title suffice for pretty much every use case? I think adding too many knobs isn't good either.
There was a problem hiding this comment.
I see that it would be parallel with bookmarked. I can't say that I'm a big fan of that existing either though. But I see how it can be useful, which I'm having a harder time for here. I think a pdf.bookmark function will exist sooner or later (in a pdf module. and there will be a html module for html primitives), which will allow arbitrary customization.
There was a problem hiding this comment.
I think it's useful to display something different for the PDF metadata, as it's a string, and content to string conversion isn't always lossless.
I should note that this could very well be reused for something like HTML or EPUB or anything that would take a stringified table of contents.
There was a problem hiding this comment.
@PgBiel I am actually considering to allow content for set document(title) because it is such a common pitfall. Together with get rules this would allow to move more general properties from the template function to document set rules (also author e.g. which could allow richer standardized metadata like email and institution). For PDF, we would then use the internal content to plain-text functionality that is already used for bookmarks. If we indeed go down that route, it would be strange to introduce further string-only arguments for the sake of PDF.
There was a problem hiding this comment.
The benefit of standardization for such metadata of course being that it's easier to switch templates.
There was a problem hiding this comment.
I'm not sure still. I think it might make perfect sense to add extra content to the outline title which you might not want to display in a PDF bookmark, such as a particular footnote (maybe not the best example as we could filter out footnotes, but there could be other kinds of undesirable content).
There was a problem hiding this comment.
Why would you have a footnote in the outline heading? The example seems pretty contrived to me to be honest.
There was a problem hiding this comment.
Well... Another example would be having manual linebreaks in the outline but not in the bookmark (linebreaks in content result in spaces when converted to string, which is not expected in Chinese).
There was a problem hiding this comment.
I should note that this could very well be reused for something like HTML or EPUB or anything that would take a stringified table of contents.
Then, the name bookmark-title would be super confusing if there's also outline-title.
|
Maybe this should also be extended to figures? It could be a separate PR, but might as well have that here too if you're up for it. |
|
If we keep only one field (which I prefer I think), we could also consider calling it |
|
After discussing this with @laurmaedje, I'm also of the opinion that a heading has a single, semantic short title that should be used for outlines and bookmarks alike. The argument name |
|
@reknih What about the situation I described above? What should I do if I really want to specify different contents for ToC (inside the pages) and PDF bookmarks but there're only one such option?
|
|
I just had the idea that we could have a more general mechanism for this than adding evermore arguments to all elements. Basically, content that is reactive to the context it is placed into, so that it can be different in bookmark, outline, and normal text. This would require some sort of ancestry handling. I acknowledge that there are significant design challenges for such a generalization though, compared to this PR. |
In general, I think that bookmarks should not contain linebreaks and that therefore Typst should strip them from the |
However, this is a common practice in Chinese publicatons. We avoid breaking inside sense groups, so manual linebreaks are required. 韩立新, 新版《德意志意识形态》研究 (2008): Jürgen Habermas, 公共领域的结构转型 (1999): |
|
@balthild The point @reknih made wasn't that the outline can't contain linebreaks, just that even if the short-title contained one, it would be stripped from the PDF bookmark. Since the width of the PDF viewer's outline panel isn't known in advance, it wouldn't make sense to linebreak manually for creating sense groups. |
I stated the difficulty at the comment above... When eliminating linebreaks, some languages (e.g. English, Korean) require replacing the linebreak with a space, and some (e.g. Chinese, Japanese) require no space. Ultimately, what if the linebreak appears at the boundary between a Chinese character and an English word, and different users need to follow different standards that require a space or no space at the boundary? That is is the reason I cannot rely on an any automatic stripping procedure and require manual editing. |
|
There are other situations too. One example is when I need to put "subtitles" describing each chapters into ToC but not in the bookmark because it isn't really a part of title or could be too long to fit in the bookmark panel. The bookmark contains only the excerpt of each "subtitles". Axel Honneth, 理性的病理学 (2022) |
|
In that case, I think the best way forward is a general mechanism for this as mentioned in the comment above: #1892 (comment) Then, it will work for figure's automatically too and custom elements can make use of the same mechanism. |
|
@balthild @PgBiel We could have a general type for a thing that can be in the document/outline/pdf and make it cast from a dictionary. For now, we would keep the type internal and only use it with heading and figure, so that only the dictionary form is available, but perhaps down the road it could be exposed so that is also works for user-defined elements (once that's a thing). Before: #heading(
[A],
outline-title: [B],
bookmark-title: "C",
)
#figure(
[Body],
caption: [A],
outline-caption: [A],
)After: #heading((
default: [A],
outline: [B],
bookmark: "C",
))
#figure(
[Body],
caption: (
default: [A],
outline: [B],
)
)We could go with
The type itself should be an element with a default show rule showing, well, the default. That way |
|
I'm closing this for now. If work on the alternative design starts, this could be reopened or there can be a new PR. |





Closes #1889
Follow-up considerations:
outline-titleas the name of field?bookmark-titleas well to support making the bookmark text different from the outline?