-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpf-book.sty
214 lines (182 loc) · 6 KB
/
pf-book.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
\ProvidesPackage{pf-book}
%
% Prerequisite Packages
%
% Set a different geometry with \newgeometry
\usepackage[
% bindingoffset=15pt, % .2in
% hmargin=50pt, % .7in
top=40pt, % .55in
bottom=50pt, % .7in
footskip=30pt, % makes the footer text line up with the graphic
% scale=0.90,
]{geometry}
% stop hyphenation
\usepackage[none]{hyphenat}
% Loaded before tikz to avoid package option conflict with pgf.
\RequirePackage[table]{xcolor}
\RequirePackage[cm]{fullpage} % Small margins
\RequirePackage{array}
\RequirePackage{calc}
\RequirePackage{enumitem}
\RequirePackage{ifluatex}
\RequirePackage{keycommand}
%\RequirePackage{ragged2e}
%\RequirePackage[document]{ragged2e}
%\RequirePackage{microtype} % Improve ragged2e hyphenation and overfull boxes
\RequirePackage{tabularx}
\RequirePackage[most]{tcolorbox} % used for some boxes
\RequirePackage{tikz}
\RequirePackage{xkeyval}
\RequirePackage{xparse}
\RequirePackage[hidelinks]{hyperref}
\RequirePackage[colaction]{multicol}
\RequirePackage{ifthen}
% \pf@deprecate{<command or environment>}{<version>}[<suggestion>]
\DeclareDocumentCommand{\pf@deprecate}{m m o}{%
\PackageWarning{pf}{#1 is deprecated and will be removed in version #2.\IfNoValueF{#3}{ #3}}
}
%
% Generally used things
%
\usepackage[english]{babel}
% \usepackage[utf8]{inputenc}
\usepackage{tabu}
\usepackage[colaction]{multicol}
% probably going to remove this eventually...
\usepackage{longtable,booktabs}
\usepackage{csquotes}
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
%
% Options
%
\newtoggle{bool-bg}
\newtoggle{bool-footer-scroll}
\DeclareOptionX{bg}[full]{%
% This macro call looks complicated, but simply sets up a case environment
% to process choices. Refer to the xkeyval documentation for details.
\XKV@cc*+[\val\index]{#1}{full,none,print}{%
\ifcase\index\relax
% full
\toggletrue{bool-bg}
\toggletrue{bool-footer-scroll}
\or
% none
\togglefalse{bool-bg}
\togglefalse{bool-footer-scroll}
\or
% print
\togglefalse{bool-bg}
\toggletrue{bool-footer-scroll}
\fi
}{%
\PackageWarning{pf}{\val\ is not a valid choice for bg and was ignored}
}
}
% Legacy bg option variants.
\DeclareOptionX{bg-full}{%
\pf@deprecate{bg-full}{0.7}[Use bg=full instead.]
\toggletrue{bool-bg}
\toggletrue{bool-footer-scroll}
}
\DeclareOptionX{bg-none}{%
\pf@deprecate{bg-none}{0.7}[Use bg=none instead.]
\togglefalse{bool-bg}
\togglefalse{bool-footer-scroll}
}
\DeclareOptionX{bg-print}{%
\pf@deprecate{bg-print}{0.7}[Use bg=print instead.]
\togglefalse{bool-bg}
\toggletrue{bool-footer-scroll}
}
\DeclareOptionX{bg-a4}{\pf@deprecate{bg-a4}{0.7}[Remove call to this package option.]}
\DeclareOptionX{bg-letter}{\pf@deprecate{bg-letter}{0.7}[Remove call to this package option.]}
% Toggle justification (official books are flush left).
\newtoggle{justified}
\DeclareOptionX{justified}{\toggletrue{justified}}
% Toggle multitoc.
\newtoggle{multitoc}
\settoggle{multitoc}{true}
\DeclareOptionX{nomultitoc}{\togglefalse{multitoc}}
% Default Settings
\ExecuteOptionsX{bg=full}
\ProcessOptionsX\relax
% Stuff every module should be able to use
\newcommand{\pfdescblock}[2]{%
\noindent\hangindent=1ex\textbf{#1}~#2
% keep the newline
}
%% I have now made this functionality part of my currfile package. It is provided as a sub-package currfile-abspath, which can also be used on its own. It provides \getmainfile, \getabspath{<file>} and \getpwd which set \themainfile, \theabspath and \thepwd to the main file name (which might be different from \jobname.tex), the absolute path of the given file and the parent working directory of the compiler run.
\usepackage{currfile-abspath}
\getabspath{pf-book.sty}
% Load other modules of this package
\RequirePackage{\theabsdir/book/pf-art}
\RequirePackage{\theabsdir/book/pf-box}
\RequirePackage{\theabsdir/book/pf-colors}
\RequirePackage{\theabsdir/book/pf-fonts} % font definitions
\RequirePackage{\theabsdir/book/pf-pagestyle} % page style
\RequirePackage{\theabsdir/book/pf-list}
\RequirePackage{\theabsdir/book/pf-creature}
\RequirePackage{\theabsdir/book/pf-sections}
\RequirePackage{\theabsdir/book/pf-spell}
\RequirePackage{\theabsdir/book/pf-strings} % Load document strings
\RequirePackage{\theabsdir/book/pf-table}
% Things I've added, will soon be mixed in with the above list
\RequirePackage{\theabsdir/book/pf-actions}
\RequirePackage{\theabsdir/book/pf-traits}
\RequirePackage{\theabsdir/book/pf-rarity}
\RequirePackage{\theabsdir/book/pf-character}
\RequirePackage{\theabsdir/book/pf-items}
\RequirePackage{\theabsdir/book/pf-license}
% Set paragraph and line spacing
%\linespread{1.1}%
%\setlength{\parindent}{1em}
\setlength{\parindent}{15pt}
%\setlength{\RaggedRightRightskip}{0pt plus 1cm}
%\setlength{\RaggedRightParindent}{\parindent}
%\hyphenpenalty=1000 % Fewer hyphens
%
%% Set left justification if not justified
%\nottoggle{justified}{\RaggedRight}
%
% Style Parameters
%
% Disable space between paragraphs.
\setlength{\parskip}{0pt}
% Font environment
\newenvironment{lmss}{%
\pf@deprecate{lmss}{0.7}
\fontfamily{lmss}\selectfont
}{}
% Columns setup
\setlength{\columnsep}{25pt} % .35in
% Customize itemize environment.
\setlist{leftmargin=1em}
\setitemize{noitemsep,topsep=0.5ex}
\renewcommand{\labelitemi}{\raisebox{0.25ex}{\tiny{\( \bullet \)}}}
% Figure out the best values for the pre & post \vspace
\newcommand{\pfhline}{
\vspace{-7pt}\noindent%
\begin{tikzpicture}[]
\draw (0, 0) -- (0,0) -- (\linewidth, 0.05);
\end{tikzpicture}%
\vspace{-5pt}%
% \leaders\hbox{\rule[0.5em]{1pt}{3pt}}\hfill%
% \par%
}
% Either hilariously, or infuriatingly, the \ifcommandkey
% implementation is buggy. Here is a re-implementation
% from tex.stackexchange.
\begingroup
\makeatletter
\catcode`\/=8 %
\@firstofone
{
\endgroup
\renewcommand{\ifcommandkey}[1]{%
\csname @\expandafter \expandafter \expandafter
\expandafter \expandafter \expandafter \expandafter
\kcmd@nbk \commandkey {#1}//{first}{second}//oftwo\endcsname
}
}