Debian Codegraph @

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

raw
1 % PuyoTikZ package for LaTeX.
2 % Created by amosborne (GitHub) / terramyst (Twitter).
3 % MIT License
4
5 \documentclass{article}
6 \usepackage{puyotikz}
7 \usepackage[hidelinks]{hyperref}
8 \usepackage{xspace}
9 \usepackage{ifmtarg}
10 \usepackage{listings}
11 \usepackage{graphicx}
12
13 \lstset{basicstyle=\footnotesize\ttfamily,%
14 language=[LaTeX]{TeX},%
15 commentstyle=\color{darkpurplepuyo},%
16 tabsize=4
17 }
18
19 \newcommand{\latex}{\LaTeX\xspace}
20 \newcommand{\tex}{\TeX\xspace}
21 \newcommand{\parline}{\vspace{\baselineskip}}
22 \newcommand{\parlineskip}{\par \parline}
23 \newcommand{\link}[2]{\href{#1}{\color{darkbluepuyo}#2}}
24
25 \newcommand{\code}[1]{{\small\texttt{#1}}}
26 \newcommand{\cmd}[1]{{\small\textbackslash\texttt{#1}}}
27 \newcommand{\codepar}[2]{\paragraph{\color{darkgreenpuyo}\code{#1} #2.}\mbox{}\par}
28
29 \newcommand{\github}{\link{https://github.com/amosborne/puyotikz}{GitHub}\xspace}
30 \newcommand{\python}{\link{https://www.python.org/download/releases/3.0/}{Python3}\xspace}
31 \newcommand{\anaconda}{\link{https://www.anaconda.com/products/individual}{Anaconda}\xspace}
32 \newcommand{\pypygments}{\link{https://pygments.org/}{Pygments}\xspace}
33 \newcommand{\pynumpy}{\link{https://numpy.org/}{Numpy}\xspace}
34 \newcommand{\pythontex}{\link{https://ctan.org/pkg/pythontex?lang=en}{Python\tex}\xspace}
35 \newcommand{\tikzpgf}{\link{https://ctan.org/pkg/pgf?lang=en}{TikZ}\xspace}
36
37 \makeatletter
38 \newenvironment{halfpage}[1][]
39 {\noindent\begin{minipage}{0.5\textwidth}\@ifmtarg{#1}{}{\begin{center}\Huge#1\end{center}}}
40 {\end{minipage}}
41 \makeatother
42
43 \lstnewenvironment{puyolisting}{\parline}{\parline}
44
45 \begin{document}
46
47 \begin{halfpage}
48 \begin{puyotikz}
49 \puyoboard{rbbggppbgggbr/rbrngbpn/yrynbb/yybrrn/bbpryyn/pbppryn}{rr/gg/yr}
50 \puyomarker{f8rA/f9rA/d7gB/d8gB/e8yC/e9rC}
51 \end{puyotikz}
52 \end{halfpage}%
53 \begin{halfpage}[PuyoTikZ]
54 A \latex package for quickly typesetting board states of Puyo Puyo games.\parlineskip
55 Supports large and small boards with arbitrary shape, hidden rows, current and next puyos, labels and move planning markers.\parlineskip
56 Source code available for download on \github or your favorite \tex repository. Package requires \python in support of scripts driven by \pythontex.\parlineskip
57 Move planning markers shown at left. Tailing variations on the Great Tanaka Rensa (GTR) shown below.\parlineskip
58 Created by \link{https://twitter.com/terramyst1}{terramyst}.
59 \end{halfpage}\\ \\
60
61 \noindent\makebox[\textwidth][c]{%
62 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/pbprg/prrgg}%
63 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrgg/pbrg/rrppg}%
64 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbgg/pbprg/rrrpg}%
65 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/pbrpg/rrgpg}%
66 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/pbrgp/rggrp}%
67 }\\
68
69 \noindent\makebox[\textwidth][c]{%
70 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/pbprg/rprgg}%
71 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/rbrpg/rppgg}%
72 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbgg/pbgrp/rrrpg}%
73 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/rbpg/pbprg/rprgg}%
74 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/gbrg/pbrpg/rrppg}%
75 }\\
76
77 \noindent\makebox[\textwidth][c]{%
78 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbpg/rbprg/rprgg}%
79 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbgg/pbrrg/rrppg}%
80 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/gbpg/pbprg/rrrgp}%
81 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbbg/rggrp/rgrpp}%
82 \puyogrid[nrows=6, ncols=6]{grr/grg/rgb/pbgr/pbgrr/gbgpp}%
83 }\\
84
85 \noindent\makebox[\textwidth][c]{%
86 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbpg/rbrpg/rrpgg}%
87 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/rbrpg/rppgg}%
88 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/pbrg/pbprg/prggr}%
89 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/bbpg/ppgrg/rprrg}%
90 \puyogrid[nrows=6, ncols=6]{grr/grg/bgb/brgp/brrgp/rgppg}%
91 }
92
93 \section{Installation}
94 \subsection{Python3 and PythonTeX}
95 Installing this package should be straightforward through the user's \tex package manager. \python will additionally need to be installed; it is recommended to use a virtual environment management tool such as \anaconda. The Python environment will need packages \pypygments and \pynumpy installed.\par
96 Compiling the document requires inserting a new command into the build sequence. \pythontex must run \code{pythontex.py} in between two separate runs of the \tex engine (see \pythontex documentation for more detail).
97
98 \section{Usage}
99 This package provides an environment and three macros for typesetting Puyo Puyo boards for inclusion in \latex documents.
100
101 \codepar{puyotikz}{environment}
102 The \code{puyotikz} environment is simply a wrapper for the \code{tikzpicture} environment. The user is therefore able to use additional \tikzpgf macros inside this environment if they wish to augment whatever graphics are already provided by this package.\par
103 The \code{puyotikz} environment takes a single numeric argument which is passed to the \code{tikzpicture} environment as the scaling parameter. This package provides two scaling parameter definitions for convenience, \cmd{puyosmallscale} and \cmd{puyobigscale} (the default).
104
105 \begin{puyolisting}
106 % example usage
107 \begin{puyotikz}[\puyosmallscale]
108 % content...
109 \end{puyotikz}
110 \end{puyolisting}
111
112 For the traditional colors of red, yellow, green, blue, purple, and gray this package also provides new color definitions such as \code{bluepuyo} and \code{darkredpuyo}.
113
114 \pagebreak
115 \codepar{puyoboard}{macro}
116 The \cmd{puyoboard} macro takes 2 arguments and 4 optional parameters and must be used inside the \code{puyotikz} environment.\par
117 Puyos are specified in format strings by column (bottom-up, left-to-right). Each puyo is identified by a single letter (\code{r}, \code{y}, \code{g}, \code{b}, \code{p}, \code{n}). Columns (or next puyos) are separated by \code{/}. Columns are labeled numerically and rows and next puyos are labeled alphabetically (lowercase and uppercase, respectively).
118
119 \begin{puyolisting}
120 % parameters
121 % - ncols: number of columns (default 6)
122 % - nrows: number of visible rows (default 12)
123 % - nhidrows: number of hidden rows (default 1)
124 % - showlabels: display coordinate labels (default True)
125
126 % arguments
127 % - #1: board format string
128 % - #2: next puyos format string
129
130 % example usage (see image below)
131 \begin{puyotikz}
132 \puyoboard[ncols=12, nrows=6, nhidrows=0]
133 {/rr/brbb/ggbg/rrg//yb/ggy}
134 {yy/yr}
135 \end{puyotikz}
136 \end{puyolisting}
137
138 \begin{center}
139 \begin{puyotikz}
140 \puyoboard[ncols=12, nrows=6, nhidrows=0]
141 {/rr/brbb/ggbg/rrg//yb/ggy}
142 {yy/yr}
143 \end{puyotikz}
144 \end{center}
145
146 \pagebreak
147 \codepar{puyomarker}{macro}
148 The \cmd{puyomarker} macro takes 1 argument and must be used inside the \code{puyotikz} environment following a \cmd{puyoboard} macro.
149
150 Puyo markers are specified in a single format string, separated by \code{/}. A single marker is a concatenation of the row label (lowercase letter), column label (number), puyo color (lowercase letter) and puyo label (uppercase letter).
151
152 \begin{puyolisting}
153 % arguments
154 % - #1: marker format string
155
156 % example usage (see image below)
157 \begin{puyotikz}
158 \puyoboard[ncols=12, nrows=6, nhidrows=0]
159 {/rr/brbb/ggbg/rrg//yb/ggy}
160 {yy/yr}
161 \puyomarker{a1yA/a2yA/b3yB/b4rB}
162 \end{puyotikz}
163 \end{puyolisting}
164
165 \begin{center}
166 \begin{puyotikz}
167 \puyoboard[ncols=12, nrows=6, nhidrows=0]
168 {/rr/brbb/ggbg/rrg//yb/ggy}
169 {yy/yr}
170 \puyomarker{a1yA/a2yA/b3yB/b4rB}
171 \end{puyotikz}
172 \end{center}
173
174 \pagebreak
175 \codepar{puyogrid}{macro}
176 The \cmd{puyogrid} macro is provided as an example derived from \cmd{puyoboard}. It assumes a \cmd{puyosmallscale} \code{puyotikz} environment and only provides a single argument for the board format string (assuming no next puyos and no markers). It also assumes zero hidden rows and turns off labeling, however any parameters available to set in \cmd{puyoboard} are also available in \cmd{puyogrid}.\par
177 The user is encouraged to construct their own derived macros in similar fashion for their intended purpose.
178
179 \begin{puyolisting}
180 % source code \puyogrid definition from puyotikz.sty
181 \newcommand{\puyogrid}[2][]{
182 \setkeys{puyoboard}{nhidrows=0, showlabels=False}
183 \begin{puyotikz}[\puyosmallscale]
184 \puyoboard[#1]{#2}{}
185 \end{puyotikz}
186 }
187
188 % example usage (see image below)
189 \puyogrid[nrows=4, ncols=10]
190 {rrr/yyyr/gggy/bbbg/pppb/rrrp/yyyr/gggy/bbbg/pppb}
191 \end{puyolisting}
192
193 \begin{center}
194 \puyogrid[nrows=4, ncols=10]{rrr/yyyr/gggy/bbbg/pppb/rrrp/yyyr/gggy/bbbg/pppb}
195 \end{center}
196
197 \section{Limitations}
198
199 \subsection{TikZ}
200 The graphics provided in this package are created using \tikzpgf. Having many graphics compiled in a single document will result in a long compilation time.\par
201 It is recommended in this case to generate images in separately compiled standalone documents and include them in the main document via \cmd{includegraphics}. \pythontex is not compatible with \cmd{tikzexternalize}.
202
203 \subsection{PythonTeX}
204 The \pythontex documentation gives a warning which bears repeating: compiling a document that uses \pythontex involves executing Python code on your computer therefore you should only compile documents from sources you trust.
205
206 \end{document}