Debian Codegraph @

texmf-dist/doc/latex/magicthegathering/magicthegathering-doc.tex

raw
1 %%
2 %% magicthegathering-doc.tex -- Documentation for the magicthegathering LaTeX package
3 %%
4 %% This file is both the user manual and a compilable working example.
5 %% Compile with two passes for the table of contents:
6 %%
7 %% lualatex --shell-escape magicthegathering-doc.tex
8 %% lualatex --shell-escape magicthegathering-doc.tex
9 %%
10 %% Or, if SVGs have been pre-converted to PDF:
11 %%
12 %% pdflatex magicthegathering-doc.tex
13 %% pdflatex magicthegathering-doc.tex
14 %%
15
16 \documentclass[a4paper,11pt]{article}
17
18 %% --- Layout ---------------------------------------------------------------
19 \usepackage[T1]{fontenc}
20 \usepackage{lmodern}
21 \usepackage[top=2.5cm, bottom=2.8cm, left=2.8cm, right=2.8cm,
22 headheight=15pt]{geometry}
23
24 %% --- Load the package we are documenting ----------------------------------
25 %% (hyperref=false because we configure hyperref ourselves below)
26 \usepackage[hyperref=false]{magicthegathering}
27
28 %% --- Hyperref -------------------------------------------------------------
29 \usepackage[
30 colorlinks = true,
31 linkcolor = black,
32 urlcolor = blue,
33 citecolor = black,
34 pdftitle = {The magicthegathering package -- User Manual},
35 pdfauthor = {Hypergeomancer},
36 ]{hyperref}
37
38 %% --- Code listings --------------------------------------------------------
39 \usepackage{listings}
40 \lstdefinestyle{mtgcode}{
41 language = [LaTeX]TeX,
42 basicstyle = \ttfamily\small,
43 keywordstyle = \bfseries,
44 commentstyle = \color{gray}\itshape,
45 backgroundcolor = \color{black!3},
46 frame = single,
47 framerule = 0.4pt,
48 rulecolor = \color{black!25},
49 xleftmargin = 4pt,
50 xrightmargin = 4pt,
51 aboveskip = 8pt,
52 belowskip = 4pt,
53 breaklines = true,
54 columns = flexible,
55 keepspaces = true,
56 showstringspaces= false,
57 morekeywords = {
58 mana,manacost,manaW,manaU,manaB,manaR,manaG,manaC,
59 setmanasymbolsize,setsetsymbolsize,
60 setsymbol,card,cardlink,
61 initem,outitem,matchup,
62 insertdeck,
63 matchresult,matchresults,
64 },
65 }
66 \lstset{style=mtgcode}
67
68 %% --- Result boxes ---------------------------------------------------------
69 \usepackage{tcolorbox}
70 \tcbuselibrary{skins,breakable}
71 \newtcolorbox{result}{
72 enhanced,
73 colback = white,
74 colframe = black!25,
75 boxrule = 0.4pt,
76 left = 6pt,
77 right = 6pt,
78 top = 5pt,
79 bottom = 5pt,
80 fonttitle = \bfseries\small,
81 title = Output,
82 }
83
84 %% --- Section formatting ---------------------------------------------------
85 \usepackage{titlesec}
86 \titleformat{\section}
87 {\large\bfseries}{\thesection}{0.7em}{}
88 [\vspace{2pt}{\color{black!40}\hrule height 0.8pt}]
89 \titleformat{\subsection}
90 {\normalsize\bfseries}{\thesubsection}{0.6em}{}
91
92 %% --- Header / footer ------------------------------------------------------
93 \usepackage{fancyhdr}
94 \pagestyle{fancy}
95 \fancyhf{}
96 \fancyhead[L]{\small\textsf{The \texttt{magicthegathering} package}}
97 \fancyhead[R]{\small\textsf{v1.1 \,--\, \today}}
98 \fancyfoot[C]{\small\thepage}
99 \renewcommand{\headrulewidth}{0.4pt}
100
101 %% --- Misc -----------------------------------------------------------------
102 \usepackage{booktabs,array,enumitem,parskip,longtable,multicol}
103
104 %% --- Doc shorthand --------------------------------------------------------
105 \newcommand{\pkg}[1]{\textsf{#1}}
106 \newcommand{\opt}[1]{\texttt{#1}}
107 \newcommand{\env}[1]{\texttt{#1}}
108 \newcommand{\file}[1]{\texttt{#1}}
109 \newcommand{\cmd}[1]{\texttt{\textbackslash#1}}
110 \newcommand{\meta}[1]{\textnormal{\textit{$\langle$#1$\rangle$}}}
111 \newcommand{\carg}[1]{\texttt{\{}\meta{#1}\texttt{\}}}
112
113 %% ==========================================================================
114 %% Title
115 %% ==========================================================================
116 \title{%
117 {\LARGE\bfseries The \texttt{magicthegathering} package}\\[6pt]
118 {\large Magic: The Gathering typesetting for \LaTeX}\\[6pt]
119 {\normalsize v1.1 \quad\textbullet\quad 2026-03-21}%
120 }
121 \author{Hypergeomancer}
122 \date{}
123
124 %% ==========================================================================
125 \begin{document}
126 %% ==========================================================================
127
128 \maketitle
129 \thispagestyle{empty}
130
131 \begin{abstract}\noindent
132 The \pkg{magicthegathering} package provides \LaTeX{} commands for typesetting
133 \emph{Magic:~The~Gathering} content: inline mana symbols,
134 expansion-set icons, Scryfall-linked card names, sideboard-guide
135 tables, plain-text deck-list import, and tournament match-result
136 tracking. Every code listing in this document is a live,
137 compilable example.
138 \end{abstract}
139
140 \tableofcontents
141 \newpage
142
143 %% ==========================================================================
144 \section{Feature overview}
145 \label{sec:features}
146 %% ==========================================================================
147
148 \begin{center}
149 \begin{tabular}{@{} c l l @{}}
150 \toprule
151 \textbf{\#} & \textbf{Feature} & \textbf{Primary command(s)} \\
152 \midrule
153 1 & Mana symbols & \cmd{mana}\carg{id} \\
154 2 & Full mana costs & \cmd{manacost}\carg{id id \ldots} \\
155 3 & Colour shortcuts & \cmd{manaW} \ldots\ \cmd{manaC} \\
156 4 & Set symbols & \cmd{setsymbol}\carg{code} \\
157 5 & Card hyperlinks & \cmd{card}\carg{name} \\
158 6 & Custom-text card links & \cmd{cardlink}\carg{name}\carg{text} \\
159 7 & Sideboard guide & \env{matchup} environment \\
160 8 & Deck-list import & \cmd{insertdeck}\carg{file} \\
161 9 & Match results & \env{matchresults} environment \\
162 \bottomrule
163 \end{tabular}
164 \end{center}
165
166 %% ==========================================================================
167 \section{Requirements}
168 %% ==========================================================================
169
170 \paragraph{TeX distribution.}
171 TeX~Live~2020+ or MiK\TeX~21+.
172 Dependencies: \pkg{pgfopts}, \pkg{svg}, \pkg{booktabs}, \pkg{array},
173 \pkg{multicol}, \pkg{enumitem}, \pkg{xcolor}, \pkg{xparse},
174 \pkg{expl3}, \pkg{hyperref}.
175 All of these ship with standard distributions.
176
177 \paragraph{SVG rendering.}
178 The package uses \pkg{svg}, which delegates SVG-to-PDF conversion to Inkscape. Two workflows:
179 \begin{enumerate}[itemsep=2pt]
180 \item \textbf{Live SVG} (Inkscape required):
181 compile with \texttt{lualatex -{}-shell-escape}.
182 \item \textbf{Pre-converted PDF} (no Inkscape):
183 convert all SVGs to PDF beforehand;
184 the package auto-detects \file{.pdf} files.
185 \end{enumerate}
186
187 %% ==========================================================================
188 \section{Installation}
189 %% ==========================================================================
190
191 Copy the following tree into any texmf directory:
192
193 \begin{lstlisting}[language={},basicstyle=\ttfamily\small]
194 <texmf>/tex/latex/magicthegathering/
195 magicthegathering.sty
196 symbols/ <-- mtg-sym-*.pdf / mtg-sym-*.svg
197 sets/ <-- mtg-set-*.pdf / mtg-set-*.svg
198 \end{lstlisting}
199
200 Then run \texttt{texhash} (TeX~Live) or
201 \texttt{initexmf -{}-update-fndb} (MiK\TeX).
202
203 %% ==========================================================================
204 \section{Package options}
205 \label{sec:options}
206 %% ==========================================================================
207
208 \begin{lstlisting}
209 \usepackage[<options>]{magicthegathering}
210 \end{lstlisting}
211
212 \medskip
213 \begin{center}
214 \begin{tabular}{@{} l l p{6.8cm} @{}}
215 \toprule
216 \textbf{Option} & \textbf{Default} & \textbf{Description} \\
217 \midrule
218 \opt{hyperref} & \opt{true} & Load \pkg{hyperref}.
219 Set \opt{false} if your document loads it first. \\[3pt]
220 \opt{colorlinks} & \opt{true} & Colour hyperlinks. \\[3pt]
221 \opt{activelinks} & \opt{true} & Enable Scryfall links in
222 \cmd{card} and \cmd{cardlink}. When \opt{false},
223 these commands produce plain italic text
224 with no hyperlink. \\[3pt]
225 \opt{symbolpath} & \opt{symbols} & Directory for
226 mana-symbol files. \\[3pt]
227 \opt{setpath} & \opt{sets} & Directory for
228 set-symbol files. \\[3pt]
229 \opt{symbolprefix} & \opt{mtg-sym-} & Filename prefix for
230 mana-symbol files. \\[3pt]
231 \opt{setprefix} & \opt{mtg-set-} & Filename prefix for
232 set-symbol files. \\
233 \bottomrule
234 \end{tabular}
235 \end{center}
236
237 \medskip\noindent Example:
238 \begin{lstlisting}
239 \usepackage[hyperref=false, symbolpath=img/symbols]{magicthegathering}
240 \end{lstlisting}
241
242 %% ==========================================================================
243 \section{Feature 1 -- Mana symbols}
244 %% ==========================================================================
245
246 \subsection{Syntax}
247
248 \begin{lstlisting}
249 \mana{<id>} % single symbol
250 \setmanasymbolsize{<dimension>} % default: 0.8em
251 \end{lstlisting}
252
253 The command \cmd{mana} inserts the symbol whose filename (without extension)
254 matches \meta{id} from the \opt{symbolpath} directory.
255
256 \subsection{Example}
257
258 \begin{lstlisting}
259 \mana{W} \mana{U} \mana{B} \mana{R} \mana{G} \mana{C}
260 \mana{3} \mana{X} \mana{S}
261 \mana{BG} \mana{UR} \mana{WU}
262 \mana{2W} \mana{BP} \mana{WUP}
263 \end{lstlisting}
264 \begin{result}
265 \mana{W}~\mana{U}~\mana{B}~\mana{R}~\mana{G}~\mana{C}~%
266 \mana{3}~\mana{X}~\mana{S}~%
267 \mana{BG}~\mana{UR}~\mana{WU}~%
268 \mana{2W}~\mana{BP}~\mana{WUP}
269 \end{result}
270
271 \subsection{Available identifiers}
272
273 \begin{center}
274 \begin{tabular}{@{} l p{8.5cm} @{}}
275 \toprule
276 \textbf{Category} & \textbf{IDs} \\
277 \midrule
278 Generic / colourless
279 & \texttt{0}--\texttt{20}, \texttt{X}, \texttt{C},
280 \texttt{S} \\
281 Colours
282 & \texttt{W}, \texttt{U}, \texttt{B}, \texttt{R},
283 \texttt{G} \\
284 Phyrexian
285 & \texttt{WP}, \texttt{UP}, \texttt{BP}, \texttt{RP},
286 \texttt{GP} \\
287 Two-colour hybrid
288 & \texttt{WU}, \texttt{WB}, \texttt{UB}, \texttt{UR},
289 \texttt{BR}, \texttt{BG}, \texttt{RG}, \texttt{RW},
290 \texttt{GW}, \texttt{GU} \\
291 Hybrid Phyrexian
292 & \texttt{WUP}, \texttt{WBP}, \texttt{UBP},
293 \texttt{URP}, \texttt{BRP}, \texttt{BGP},
294 \texttt{RGP}, \texttt{RWP}, \texttt{GWP},
295 \texttt{GUP} \\
296 Hybrid generic
297 & \texttt{2W}, \texttt{2U}, \texttt{2B}, \texttt{2R},
298 \texttt{2G} \\
299 Colourless hybrid
300 & \texttt{CW}, \texttt{CU}, \texttt{CB}, \texttt{CR},
301 \texttt{CG} \\
302 \bottomrule
303 \end{tabular}
304 \end{center}
305
306 \medskip\noindent
307 \textbf{Note on symbol updates.}
308 The mana and set symbol artwork bundled with this package was last
309 updated in December~2025. Symbols for sets released after that
310 date may not be included. Updated artwork will be provided in
311 future package releases.
312
313 %% ==========================================================================
314 \section{Feature 2 -- Full mana costs}
315 %% ==========================================================================
316
317 \subsection{Syntax}
318
319 \begin{lstlisting}
320 \manacost{<id> <id> ...}
321 \end{lstlisting}
322
323 A space-separated list of symbol IDs.
324 Each token is passed to \cmd{mana} internally.
325
326 \subsection{Example}
327
328 \begin{lstlisting}
329 Lightning Bolt: \manacost{R}
330 Counterspell: \manacost{U U}
331 Cryptic Command:\manacost{1 U U U}
332 \end{lstlisting}
333 \begin{result}
334 Lightning Bolt: \manacost{R}\quad
335 Counterspell: \manacost{U U}\quad
336 Cryptic Command: \manacost{1 U U U}
337 \end{result}
338
339 %% ==========================================================================
340 \section{Feature 3 -- Colour shortcuts}
341 %% ==========================================================================
342
343 Six convenience commands for the most common single-colour symbols.
344
345 \medskip
346 \begin{center}
347 \begin{tabular}{@{} l l l @{}}
348 \toprule
349 \textbf{Command} & \textbf{Output} & \textbf{Equivalent} \\
350 \midrule
351 \cmd{manaW} & \manaW & \lstinline|\mana{W}| \\
352 \cmd{manaU} & \manaU & \lstinline|\mana{U}| \\
353 \cmd{manaB} & \manaB & \lstinline|\mana{B}| \\
354 \cmd{manaR} & \manaR & \lstinline|\mana{R}| \\
355 \cmd{manaG} & \manaG & \lstinline|\mana{G}| \\
356 \cmd{manaC} & \manaC & \lstinline|\mana{C}| \\
357 \bottomrule
358 \end{tabular}
359 \end{center}
360
361 %% ==========================================================================
362 \section{Feature 4 -- Set symbols}
363 %% ==========================================================================
364
365 \subsection{Syntax}
366
367 \begin{lstlisting}
368 \setsymbol{<set-code>}
369 \setsetsymbolsize{<dimension>} % default: 1em
370 \end{lstlisting}
371
372 The \meta{set-code} is the lowercase Scryfall / MTGJSON set
373 identifier (e.g.\ \texttt{mh3}, \texttt{fdn}, \texttt{lea}).
374
375 \subsection{Example}
376
377 \begin{lstlisting}
378 Modern Horizons 3: \setsymbol{mh3}
379 Foundations: \setsymbol{fdn}
380 Alpha: \setsymbol{lea}
381 \end{lstlisting}
382 \begin{result}
383 Modern Horizons~3: \setsymbol{mh3}\quad
384 Foundations: \setsymbol{fdn}\quad
385 Alpha: \setsymbol{lea}
386 \end{result}
387
388 %% ==========================================================================
389 \section{Feature 5 -- Card hyperlinks}
390 %% ==========================================================================
391
392 \subsection{Syntax}
393
394 \begin{lstlisting}
395 \card{<card name>}
396 \end{lstlisting}
397
398 Typesets \meta{card name} in \textit{italics} and makes it a
399 clickable link to the Scryfall search page for that card.
400 Requires \pkg{hyperref} (loaded by default).
401
402 \subsection{Example}
403
404 \begin{lstlisting}
405 \card{Lightning Bolt} has been a staple since Alpha.
406 \card{Tarmogoyf} defined Modern for years.
407 \end{lstlisting}
408 \begin{result}
409 \card{Lightning Bolt} has been a staple since Alpha.\\
410 \card{Tarmogoyf} defined Modern for years.
411 \end{result}
412
413 %% ==========================================================================
414 \section{Feature 6 -- Card links with custom text}
415 %% ==========================================================================
416
417 \subsection{Syntax}
418
419 \begin{lstlisting}
420 \cardlink{<card name>}{<display text>}
421 \end{lstlisting}
422
423 Like \cmd{card}, but shows \meta{display text} instead of
424 the card name.
425
426 \subsection{Example}
427
428 \begin{lstlisting}
429 \cardlink{Lightning Bolt}{This iconic spell} costs
430 \manacost{R}.
431 \end{lstlisting}
432 \begin{result}
433 \cardlink{Lightning Bolt}{This iconic spell} costs \manacost{R}.
434 \end{result}
435
436 %% ==========================================================================
437 \section{Feature 7 -- Sideboard guide}
438 %% ==========================================================================
439
440 \subsection{Syntax}
441
442 \begin{lstlisting}
443 \begin{matchup}
444 \initem{<entry>} % IN column
445 \outitem{<entry>} % OUT column
446 \end{matchup}
447 \end{lstlisting}
448
449 Produces a centred IN\,/\,OUT table. Entries are sorted
450 alphabetically within each column. The shorter column is
451 padded automatically. Any content is accepted as
452 \meta{entry}\,---\,plain text, \cmd{card} links, etc.
453
454 \subsection{Example}
455
456 \begin{lstlisting}
457 \begin{matchup}
458 \initem{\card{Leyline of Sanctity}}
459 \initem{\card{Roiling Vortex}}
460 \initem{\card{Skullcrack}}
461 \outitem{\card{Eidolon of the Great Revel}}
462 \outitem{\card{Searing Blaze}}
463 \end{matchup}
464 \end{lstlisting}
465 \begin{result}
466 \begin{matchup}
467 \initem{\card{Leyline of Sanctity}}
468 \initem{\card{Roiling Vortex}}
469 \initem{\card{Skullcrack}}
470 \outitem{\card{Eidolon of the Great Revel}}
471 \outitem{\card{Searing Blaze}}
472 \end{matchup}
473 \end{result}
474
475 %% ==========================================================================
476 \section{Feature 8 -- Deck-list import}
477 %% ==========================================================================
478
479 \subsection{Syntax}
480
481 \begin{lstlisting}
482 \insertdeck{<filename>}
483 \end{lstlisting}
484
485 Reads a plain-text file and renders a two-column deck list
486 with Scryfall-linked card names and automatic totals.
487
488 \subsection{File format}
489
490 \begin{lstlisting}[language={},basicstyle=\ttfamily\small]
491 4 Lightning Bolt
492 4 Goblin Guide
493 4 Monastery Swiftspear
494 ...
495 SIDEBOARD
496 3 Leyline of Sanctity
497 2 Skullcrack
498 \end{lstlisting}
499
500 One card per line: \texttt{\meta{qty}~\meta{card name}}.
501 The literal line \texttt{SIDEBOARD} (uppercase, no leading
502 whitespace) separates main deck from sideboard.
503 Blank lines are ignored. The sideboard separator is
504 optional; omitting it treats all entries as main-deck cards.
505
506 \subsection{Example}
507
508 \begin{lstlisting}
509 \insertdeck{deck-sample.txt}
510 \end{lstlisting}
511
512 \insertdeck{deck-sample.txt}
513
514 %% ==========================================================================
515 \section{Feature 9 -- Match results}
516 %% ==========================================================================
517
518 \subsection{Syntax}
519
520 \begin{lstlisting}
521 \begin{matchresults}
522 \matchresult{<round>}{<opponent>}{<deck>}{<score>}{<result>}
523 ...
524 \end{matchresults}
525 \end{lstlisting}
526
527 The \meta{result} argument must be exactly \texttt{Win},
528 \texttt{Loss}, or \texttt{Draw} (case-sensitive). The
529 win--loss--draw record is computed automatically.
530
531 \subsection{Example}
532
533 \begin{lstlisting}
534 \begin{matchresults}
535 \matchresult{1}{Alice}{Amulet Titan}{2--1}{Win}
536 \matchresult{2}{Bob}{Living End}{0--2}{Loss}
537 \matchresult{3}{Carol}{Yawgmoth}{2--1}{Win}
538 \matchresult{4}{Dave}{Burn}{2--0}{Win}
539 \matchresult{5}{Eve}{Cascade Crash}{1--1}{Draw}
540 \end{matchresults}
541 \end{lstlisting}
542 \begin{result}
543 \begin{matchresults}
544 \matchresult{1}{Alice}{Amulet Titan}{2--1}{Win}
545 \matchresult{2}{Bob}{Living End}{0--2}{Loss}
546 \matchresult{3}{Carol}{Yawgmoth}{2--1}{Win}
547 \matchresult{4}{Dave}{Burn}{2--0}{Win}
548 \matchresult{5}{Eve}{Cascade Crash}{1--1}{Draw}
549 \end{matchresults}
550 \end{result}
551
552 %% ==========================================================================
553 \section{Quick-reference table}
554 %% ==========================================================================
555
556 \begin{longtable}{@{} p{5.8cm} p{7.5cm} @{}}
557 \toprule
558 \textbf{Command / environment}
559 & \textbf{Description} \\
560 \midrule\endhead
561 \bottomrule\endfoot
562 \cmd{setmanasymbolsize}\carg{dim}
563 & Set mana-symbol height (default 0.8em). \\
564 \cmd{mana}\carg{id}
565 & Single mana symbol. \\
566 \cmd{manacost}\carg{id id \ldots}
567 & Full mana cost (space-separated). \\
568 \cmd{manaW}\,\ldots\,\cmd{manaC}
569 & Colour shortcuts. \\[3pt]
570 \cmd{setsetsymbolsize}\carg{dim}
571 & Set-symbol height (default 1em). \\
572 \cmd{setsymbol}\carg{code}
573 & Expansion symbol. \\[3pt]
574 \cmd{card}\carg{name}
575 & Italic card name with Scryfall link. \\
576 \cmd{cardlink}\carg{name}\carg{text}
577 & Custom text with Scryfall link. \\[3pt]
578 \env{matchup}
579 & IN\,/\,OUT sideboard table. \\
580 \quad\cmd{initem}\carg{entry}
581 & Add to IN column. \\
582 \quad\cmd{outitem}\carg{entry}
583 & Add to OUT column. \\[3pt]
584 \cmd{insertdeck}\carg{file}
585 & Import deck list from text file. \\[3pt]
586 \env{matchresults}
587 & Tournament results table. \\
588 \cmd{matchresult}\carg{rd}\carg{opp}\\%
589 \carg{deck}\carg{score}\carg{result}
590 & Add one match row. \\
591 \end{longtable}
592
593 %% ==========================================================================
594 \section{Licence}
595 %% ==========================================================================
596
597 This work is released under the
598 \href{https://www.latex-project.org/lppl/lppl-1-3c/}%
599 {LaTeX Project Public Licence v1.3c} or later.
600
601 The SVG artwork in \file{symbols/} and \file{sets/} is from
602 the \href{https://mana.andrewgioia.com}{Mana} and
603 \href{https://keyrune.andrewgioia.com}{Keyrune} projects by
604 Andrew~Gioia, released under the SIL Open Font Licence~1.1.
605
606 Magic:~The~Gathering, the mana symbols, the tap symbol, the set
607 symbols, and all associated card names and game elements are
608 trademarks and/or copyrighted materials of Wizards of the
609 Coast~LLC and/or its affiliates. All rights in such materials
610 are reserved by Wizards of the~Coast. This package is an
611 unofficial fan project and is not produced, endorsed, supported,
612 or affiliated with Wizards of the~Coast.
613
614 %% ==========================================================================
615 \section{Version history}
616 %% ==========================================================================
617
618 \begin{description}[font=\normalfont\ttfamily\bfseries,
619 itemsep=4pt]
620 \item[v1.1 (2026-03-21)]
621 Renamed all symbol and set files with unique prefixes
622 (\file{mtg-sym-*}, \file{mtg-set-*}) for TeX~Live
623 compatibility. Added \opt{symbolprefix} and
624 \opt{setprefix} package options.
625 No changes to user-facing commands.
626 \item[v1.0 (2026-03-15)]
627 First public release. Nine features: mana symbols, full
628 mana costs, colour shortcuts, set symbols, card hyperlinks,
629 custom-text card links, sideboard guide, deck-list import,
630 match results.
631 \end{description}
632
633 \end{document}