Skip to content
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

Citations do not work with Typst writer #8763

Closed
benjamineskola opened this issue Apr 7, 2023 · 7 comments
Closed

Citations do not work with Typst writer #8763

benjamineskola opened this issue Apr 7, 2023 · 7 comments
Labels

Comments

@benjamineskola
Copy link

Explain the problem.
I'm trying to generate a PDF, including citations, using as minimal a change as possible from pdf-engine: latex to pdf-engine: typst. When simply changing the engine to typst failed, I tried changing the final output format to typst so I could see the output and try to make sense of the issue.

Firstly, an absolute path to the bibliography fails. If I generate with pandoc -s --bibliography "/Users/ben/Documents/Study/bibliography.yaml" … then I get a typst file containing the following:

#bibliography("/Users/ben/Documents/Study/bibliography.yaml")

When I tried processing this the error was as follows:

$ typst TMA04.typ
error: file not found (searched at Users/ben/Documents/Study/bibliography.yaml)
    ┌─ TMA04.typ:135:14
    │
135 │ #bibliography("/Users/ben/Documents/Study/bibliography.yaml")
    │               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Note the lack of leading / in the error message: Typst seems to be stripping this and treating it as a relative path.

Passing a relative path to Pandoc (e.g. pandoc -s --bibliography=../bibliography.yaml …) seems to work — at least, it finds the bibliography file.

However this then produces the second error:

$ typst TMA04.typ
error: unknown bibliography format
    ┌─ TMA04.typ:135:14
    │
135 │ #bibliography("../bibliography.yaml")
    │               ^^^^^^^^^^^^^^^^^^^^^^

My expectation was that a citeproc yaml file would be processed by pandoc to generate the output (as with the other output formats, which as far as I know don't support citeproc). However it seems that the typst writer needs the yaml file to be in a different format (typst-specific?).

I don't know if the right thing to do is to alter Pandoc's behaviour or just to document it — I can completely understand if it's a limitation of the output format.

Pandoc version?
pandoc 3.1.2 on macOS 13.3

@jgm
Copy link
Owner

jgm commented Apr 7, 2023

My expectation was that a citeproc yaml file would be processed by pandoc to generate the output (as with the other output formats, which as far as I know don't support citeproc).

This is correct, if you specify --citeproc on the command line. Did you? Even if you did, I think there may be a bug; pandoc should not be passing through the bibliography to the template in this case.

@jgm jgm closed this as completed in e89a3ed Apr 7, 2023
@jgm
Copy link
Owner

jgm commented Apr 7, 2023

With the commit I pushed, this should work: use --citeproc -t typst-citations (the latter disables native typst citations and will omit #bibliography in the template).

@benjamineskola
Copy link
Author

This is correct, if you specify --citeproc on the command line. Did you?

Sorry for being unclear: I specify citeproc etc in a defaults file and left this out of my examples — the setup certainly works for me for other output formats.

Thanks for the quick response, that seems to fix it for me!

@iandol
Copy link
Contributor

iandol commented Oct 9, 2023

--citeproc -t typst-citations

@jgm -- this is not documented in the manual AFAICT? The extensions citations section in the manual seems a bit arbitrary for org / docx, would you want this added there or just above https://pandoc.org/MANUAL.html#other-relevant-metadata-fields in a paragraph after mentioning LaTeX?

@jgm
Copy link
Owner

jgm commented Oct 9, 2023

I'm really not sure. That section only talks about the effect on readers, and in typst's case, citations always work in the reader regardless of the extension. The extension only affects the writer.

@iandol
Copy link
Contributor

iandol commented Oct 10, 2023 via email

@iandol
Copy link
Contributor

iandol commented Oct 10, 2023

I made a pull request to add this info to the Options > --citeproc section...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants