Skip to content

Commit 3a88312

Browse files
authored
introduce basic Typst template for TCG (#252)
* introduce basic Typst template for TCG * actually commit the template
1 parent b0d97f5 commit 3a88312

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ PDF_ENGINE=xelatex
1919
CROSSREF_TYPE="iso"
2020
DO_AUTO_BACKMATTER="yes"
2121
TEMPLATE_PDF="tcg.tex"
22+
TEMPLATE_TYPST="tcg.typ"
2223
TEMPLATE_HTML=""
2324
HTML_STYLESHEET_ARGS=""
2425
CSL=""
@@ -163,7 +164,10 @@ while true; do
163164
shift 2
164165
;;
165166
--template)
167+
# TODO: If simultaneous LaTeX and Typst-based PDF generation is required,
168+
# then we need separate --template_latex and --template_typst flags.
166169
TEMPLATE_PDF="${2}"
170+
TEMPLATE_TYPST="${2}"
167171
shift 2
168172
;;
169173
--template_html)
@@ -842,6 +846,7 @@ do_typst() {
842846
local cmd=(pandoc
843847
--standalone
844848
--highlight-style=${SYNTAX_HIGHLIGHT_STYLE}
849+
--template=${TEMPLATE_TYPST}
845850
--lua-filter=convert-diagrams.lua
846851
--lua-filter=convert-images.lua
847852
--lua-filter=parse-html.lua

template/tcg.typ

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
//
2+
// TCG Template for Typst
3+
// Initial version generated by Pandoc v3.6.4 using:
4+
// pandoc -D typst
5+
//
6+
7+
#let horizontalrule = line(start: (25%,0%), end: (75%,0%))
8+
9+
#show terms: it => {
10+
it.children
11+
.map(child => [
12+
#strong[#child.term]
13+
#block(inset: (left: 1.5em, top: -0.4em))[#child.description]
14+
])
15+
.join()
16+
}
17+
18+
#set table(
19+
inset: 6pt,
20+
stroke: 1pt
21+
)
22+
23+
#show figure.where(
24+
kind: table
25+
): set figure.caption(position: $if(table-caption-position)$$table-caption-position$$else$top$endif$)
26+
27+
#show figure.where(
28+
kind: image
29+
): set figure.caption(position: $if(figure-caption-position)$$figure-caption-position$$else$bottom$endif$)
30+
31+
$if(template)$
32+
#import "$template$": conf
33+
$else$
34+
$template.typst()$
35+
$endif$
36+
37+
$if(smart)$
38+
$else$
39+
#set smartquote(enabled: false)
40+
41+
$endif$
42+
$for(header-includes)$
43+
$header-includes$
44+
45+
$endfor$
46+
#show: doc => conf(
47+
$if(title)$
48+
title: [$title$],
49+
$endif$
50+
$if(subtitle)$
51+
subtitle: [$subtitle$],
52+
$endif$
53+
$if(author)$
54+
authors: (
55+
$for(author)$
56+
$if(author.name)$
57+
( name: [$author.name$],
58+
affiliation: [$author.affiliation$],
59+
email: [$author.email$] ),
60+
$else$
61+
( name: [$author$],
62+
affiliation: "",
63+
email: "" ),
64+
$endif$
65+
$endfor$
66+
),
67+
$endif$
68+
$if(keywords)$
69+
keywords: ($for(keywords)$$keyword$$sep$,$endfor$),
70+
$endif$
71+
$if(date)$
72+
date: [$date$],
73+
$endif$
74+
$if(lang)$
75+
lang: "$lang$",
76+
$endif$
77+
$if(region)$
78+
region: "$region$",
79+
$endif$
80+
$if(abstract)$
81+
abstract: [$abstract$],
82+
$endif$
83+
$if(margin)$
84+
margin: ($for(margin/pairs)$$margin.key$: $margin.value$,$endfor$),
85+
$endif$
86+
$if(papersize)$
87+
paper: "$papersize$",
88+
$endif$
89+
$if(mainfont)$
90+
font: ("$mainfont$",),
91+
$endif$
92+
$if(fontsize)$
93+
fontsize: $fontsize$,
94+
$endif$
95+
$if(section-numbering)$
96+
sectionnumbering: "$section-numbering$",
97+
$endif$
98+
pagenumbering: $if(page-numbering)$"$page-numbering$"$else$none$endif$,
99+
cols: $if(columns)$$columns$$else$1$endif$,
100+
doc,
101+
)
102+
103+
$for(include-before)$
104+
$include-before$
105+
106+
$endfor$
107+
$if(toc)$
108+
#outline(
109+
title: auto,
110+
depth: $toc-depth$
111+
);
112+
$endif$
113+
114+
$body$
115+
116+
$if(citations)$
117+
$if(csl)$
118+
119+
#set bibliography(style: "$csl$")
120+
$elseif(bibliographystyle)$
121+
122+
#set bibliography(style: "$bibliographystyle$")
123+
$endif$
124+
$if(bibliography)$
125+
126+
#bibliography($for(bibliography)$"$bibliography$"$sep$,$endfor$)
127+
$endif$
128+
$endif$
129+
$for(include-after)$
130+
131+
$include-after$
132+
$endfor$

0 commit comments

Comments
 (0)