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

📝 Typst template documentation #1179

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

roaldarbol
Copy link
Contributor

Beginning to document how to create Typst templates. Will be accompanied by a new copier template (that will initially live on my Github, but that we can later transfer over to https://github.com/myst-templates/.

@roaldarbol roaldarbol changed the title Begin Typst template documentation 📝 Begin Typst template documentation May 2, 2024
@roaldarbol roaldarbol changed the title 📝 Begin Typst template documentation 📝 Typst template documentation May 2, 2024
@@ -1,5 +1,5 @@
---
title: Create a Template
title: Create a LaTeX Template
description: jtex templates have a template.yml, template.tex, and any other images, class or definition files required for the template to render.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: jtex templates have a template.yml, template.tex, and any other images, class or definition files required for the template to render.
description: LaTeX templates have a template.yml, template.tex, and any other images, class or definition files required for the template to render.

@@ -0,0 +1,324 @@
---
title: Create a Typst Template
description: jtex templates have a template.yml, template.typ, and any other images, class or definition files required for the template to render.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: jtex templates have a template.yml, template.typ, and any other images, class or definition files required for the template to render.
description: Typst templates have a template.yml, template.typ, and any other images, class or definition files required for the template to render.

---

A `jtex` template contains everything necessary to create a $\LaTeX$ document, including a `template.yml`, the main `template.typ`, and any associated files such as classes (`*.cls`), definitions (`*.def`), or images (`*.png`).
These $\LaTeX$ templates are data-driven, in that they record all of the options in a `template.yml` which you create as you are working through moving your $\LaTeX$ document to a `jtex` template.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These $\LaTeX$ templates are data-driven, in that they record all of the options in a `template.yml` which you create as you are working through moving your $\LaTeX$ document to a `jtex` template.
These Typst templates are data-driven, in that they record all of the options in a `template.yml` which you create as you are working through moving your Typst document to a `jtex` template.

Comment on lines +174 to +206
## Update the authors and affiliations

The authors and affiliations are usually the hardest part to template as many journals do these differently.
If you are looking for inspiration, take a look at some of the existing templates in the [myst-templates](https://github.com/myst-templates) organization on GitHub.

For example, to create the following author/affiliations list:

```latex
\authors{First Author\affil{1}, Author\affil{1,2}}

\affiliation{1}{First Affiliation}
\affiliation{2}{Second Affiliation}
```

The `jtex` template is as follows:

```latex
\authors{
[#- for author in doc.authors -#]
[-- author.name --]
[#- if author.affiliations -#]
\affil{
[-- author.affiliations|join(",", "index") --]
}
[#- endif -#]
[#- if not loop.last #], [# endif -#]
[#- endfor -#]
}

[# for affiliation in doc.affiliations #]
\affiliation{[-affiliation.index-]}{[-affiliation.value-]}
[# endfor #]
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: refer to the frontmatter plugin from Curvenote for typst

myst build my-document.md --tex
```

By default these are put in a `_build` folder. If you want to control that, use the `output:` field in the appropriate export. If you have $\LaTeX$ installed, you can also try changing the format to `pdf` or `pdf+tex` to keep the source files. See [](/guide/creating-pdf-documents) for more information on using MyST templates for $\LaTeX$.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By default these are put in a `_build` folder. If you want to control that, use the `output:` field in the appropriate export. If you have $\LaTeX$ installed, you can also try changing the format to `pdf` or `pdf+tex` to keep the source files. See [](/guide/creating-pdf-documents) for more information on using MyST templates for $\LaTeX$.
By default these are put in a `_build` folder. If you want to control that, use the `output:` field in the appropriate export. If you have Typst installed, you can also try changing the format to `pdf` or `pdf+typst` to keep the source files. See [](/guide/creating-pdf-documents) for more information on using MyST templates for Typst.

---
```

Ensure that the exports list has a `format: tex` in it. To also have your `parts` defined, use blocks with JSON metadata:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Ensure that the exports list has a `format: tex` in it. To also have your `parts` defined, use blocks with JSON metadata:
Ensure that the exports list has a `format: typst` in it. To also have your `parts` defined, use blocks with JSON metadata:

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

Successfully merging this pull request may close these issues.

2 participants