| 1 |
% \iffalse meta-comment |
| 2 |
% SPDX-FileCopyrightText: Copyright (c) 2021-2026 Yegor Bugayenko |
| 3 |
% SPDX-License-Identifier: MIT |
| 4 |
% \fi |
| 5 |
|
| 6 |
%%% \CheckSum{0} |
| 7 |
% |
| 8 |
% \CharacterTable |
| 9 |
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z |
| 10 |
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z |
| 11 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 12 |
% Exclamation \! Double quote \" Hash (number) \# |
| 13 |
% Dollar \$ Percent \% Ampersand \& |
| 14 |
% Acute accent \' Left paren \( Right paren \) |
| 15 |
% Asterisk \* Plus \+ Comma \, |
| 16 |
% Minus \- Point \. Solidus \/ |
| 17 |
% Colon \: Semicolon \; Less than \< |
| 18 |
% Equals \= Greater than \> Question mark \? |
| 19 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 20 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 21 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 22 |
% Right brace \} Tilde \~} |
| 23 |
|
| 24 |
% \GetFileInfo{yb-book.dtx} |
| 25 |
% \DoNotIndex{\end,\empty,\defined,\def,\begin,\if,\isempty,\endgroup,\begingroup,\let,\else,\fi,\newcommand,\newenvironment} |
| 26 |
|
| 27 |
% \iffalse |
| 28 |
%<*driver> |
| 29 |
\ProvidesFile{yb-book.dtx} |
| 30 |
%</driver> |
| 31 |
%<class>\NeedsTeXFormat{LaTeX2e} |
| 32 |
%<class>\ProvidesClass{yb-book} |
| 33 |
%<*class> |
| 34 |
[2026-05-25 0.10.0 YB Branded Book Style] |
| 35 |
%</class> |
| 36 |
%<*driver> |
| 37 |
\documentclass{ltxdoc} |
| 38 |
\usepackage{lmodern} |
| 39 |
\usepackage{microtype} |
| 40 |
\microtypesetup{verbose=false,nopatch=footnote} |
| 41 |
\AddToHook{env/verbatim/begin}{\microtypesetup{protrusion=false}} |
| 42 |
\usepackage{href-ul} |
| 43 |
\usepackage{graphicx} |
| 44 |
\PageIndex |
| 45 |
\EnableCrossrefs |
| 46 |
\CodelineIndex |
| 47 |
\RecordChanges |
| 48 |
\begin{document} |
| 49 |
\DocInput{yb-book.dtx} |
| 50 |
\PrintChanges |
| 51 |
\PrintIndex |
| 52 |
\end{document} |
| 53 |
%</driver> |
| 54 |
% \fi |
| 55 |
|
| 56 |
% \title{\includegraphics[width=0.75in]{yb-book-logo.pdf} \\ \LaTeX{} Class |yb-book|\thanks{The sources are on GitHub at \href{https://github.com/yegor256/yb-book}{yegor256/yb-book}}} |
| 57 |
% \author{Yegor Bugayenko \\ \texttt{[email protected]}} |
| 58 |
% \date{\filedate, \fileversion} |
| 59 |
% |
| 60 |
% \maketitle |
| 61 |
% |
| 62 |
% \section{Introduction} |
| 63 |
% |
| 64 |
% \index{Amazon} |
| 65 |
% The class |yb-book| was devised to assist the author in producing |
| 66 |
% \href{https://www.yegor256.com/books.html}{his books} and in publishing them |
| 67 |
% \href{https://www.amazon.com/Yegor-Bugayenko/e/B01AM1QMDK}{on Amazon}. |
| 68 |
% Others are welcome to employ it for their own books. The procedure is |
| 69 |
% straightforward: |
| 70 |
%\iffalse |
| 71 |
%<*verb> |
| 72 |
%\fi |
| 73 |
\begin{verbatim} |
| 74 |
\documentclass{yb-book} |
| 75 |
\renewcommand*\thetitle{New Book About OOP} |
| 76 |
\renewcommand*\theauthor{Jeff Lebowski} |
| 77 |
\renewcommand*\thevolume{1} |
| 78 |
\renewcommand*\theversion{1.0} |
| 79 |
\begin{document} |
| 80 |
\ybPrintTitlePage |
| 81 |
\chapter{First One} |
| 82 |
\section{About Something Interesting} |
| 83 |
Hello, world! |
| 84 |
\end{document} |
| 85 |
\end{verbatim} |
| 86 |
%\iffalse |
| 87 |
%</verb> |
| 88 |
%\fi |
| 89 |
|
| 90 |
% Suggestions for additional options and commands are welcome; nevertheless, the style |
| 91 |
% of the author's books is intentionally as plain as possible, eschewing formatting |
| 92 |
% to the greatest extent practicable. The reasoning is set out |
| 93 |
% \href{https://www.yegor256.com/2019/05/21/dont-improvise.html}{here}. |
| 94 |
|
| 95 |
% \section{Options} |
| 96 |
|
| 97 |
% Several class options are available: |
| 98 |
|
| 99 |
% \begin{macro}{compact} |
| 100 |
% This package option is to be used when the text is required in a more compact |
| 101 |
% form, occupying less vertical space. It proves convenient for works of fiction. |
| 102 |
% The author employs it to render the \href{https://www.yegor256.com/code-ahead.html}{Code Ahead} book. |
| 103 |
% \end{macro} |
| 104 |
|
| 105 |
% \begin{macro}{sparse} |
| 106 |
% Under this package option, every section commences on a new page. |
| 107 |
% \end{macro} |
| 108 |
|
| 109 |
% \begin{macro}{manuscript} |
| 110 |
% Whenever the format is not intended for Amazon printing |
| 111 |
% but for some other purpose (the page size being A4), this option proves |
| 112 |
% convenient. The author likewise employs it whenever the book is to be rendered |
| 113 |
% for printing on paper for review purposes. |
| 114 |
% \end{macro} |
| 115 |
|
| 116 |
% \begin{macro}{authordraft} |
| 117 |
% \changes{v0.4.0}{2024/03/23}{The package option \texttt{draft} renamed to \texttt{authordraft}} |
| 118 |
% This option is appropriate when the document is a draft for reviewers (the page size being A4) |
| 119 |
% and a watermark together with a compact form of the content is desired. The |
| 120 |
% option is used in conjunction with the |\thereviewer{}| command, which may be redefined |
| 121 |
% to embed the name of the reviewer within the watermark. This serves |
| 122 |
% as a deterrent to theft of the book: |
| 123 |
%\iffalse |
| 124 |
%<*verb> |
| 125 |
%\fi |
| 126 |
\begin{verbatim} |
| 127 |
\documentclass[authordraft]{yb-book} |
| 128 |
\renewcommand*\thereviewer{Walter Sobchak} |
| 129 |
\begin{document} |
| 130 |
Hello, world! |
| 131 |
\end{document} |
| 132 |
\end{verbatim} |
| 133 |
%\iffalse |
| 134 |
%</verb> |
| 135 |
%\fi |
| 136 |
% \end{macro} |
| 137 |
|
| 138 |
% \section{Meta Commands} |
| 139 |
|
| 140 |
% A number of commands may be redefined within the preamble: |
| 141 |
%\iffalse |
| 142 |
%<*verb> |
| 143 |
%\fi |
| 144 |
\begin{verbatim} |
| 145 |
\documentclass{yb-book} |
| 146 |
\newcommand*\thetitle{My New Book About OOP} |
| 147 |
\newcommand*\theauthor{Yegor Bugayenko} |
| 148 |
\newcommand*\thevolume{1} |
| 149 |
\newcommand*\thedate{24 Feb 2022} |
| 150 |
\newcommand*\theversion{1.4} |
| 151 |
\newcommand*\thereviewer{Jeff Lebowski} |
| 152 |
\begin{document} |
| 153 |
... the content goes here ... |
| 154 |
\end{document} |
| 155 |
\end{verbatim} |
| 156 |
%\iffalse |
| 157 |
%</verb> |
| 158 |
%\fi |
| 159 |
|
| 160 |
% \section{Printers} |
| 161 |
|
| 162 |
% A number of printers are provided---commands that render substantial blocks of text |
| 163 |
% in the expected format: |
| 164 |
|
| 165 |
% \begin{macro}{\ybPrintTitlePage} |
| 166 |
% Prints the first page of a book. At minimum, |\thetitle| |
| 167 |
% and |\theauthor| must be defined: |
| 168 |
%\iffalse |
| 169 |
%<*verb> |
| 170 |
%\fi |
| 171 |
\begin{verbatim} |
| 172 |
\documentclass{yb-book} |
| 173 |
\renewcommand*\thetitle{My New Book} |
| 174 |
\renewcommand*\theauthor{Yegor Bugayenko} |
| 175 |
\begin{document} |
| 176 |
\ybPrintTitlePage |
| 177 |
.. the rest of the book goes here |
| 178 |
\end{document} |
| 179 |
\end{verbatim} |
| 180 |
%\iffalse |
| 181 |
%</verb> |
| 182 |
%\fi |
| 183 |
% \end{macro} |
| 184 |
|
| 185 |
% \begin{macro}{\ybPrintTOC} |
| 186 |
% Prints the table of contents. |
| 187 |
% \end{macro} |
| 188 |
|
| 189 |
% \begin{macro}{\ybQuote} |
| 190 |
% Prints a side quote: |
| 191 |
%\iffalse |
| 192 |
%<*verb> |
| 193 |
%\fi |
| 194 |
\begin{verbatim} |
| 195 |
\documentclass{yb-book} |
| 196 |
\begin{document} |
| 197 |
Hello, world! |
| 198 |
\ybQuote{Never tell the truth to people who |
| 199 |
are not worthy of it}{Mark Twain}{} |
| 200 |
\end{document} |
| 201 |
\end{verbatim} |
| 202 |
%\iffalse |
| 203 |
%</verb> |
| 204 |
%\fi |
| 205 |
% A warning is emitted to the log whenever the quotation falls very close to the top |
| 206 |
% or the bottom of a page, since the underlying |wrapfig| environment behaves |
| 207 |
% poorly in such positions. |
| 208 |
% \end{macro} |
| 209 |
|
| 210 |
% \begin{macro}{\ybPrintBibliography} |
| 211 |
% Prints the list of bib references. |
| 212 |
% \end{macro} |
| 213 |
|
| 214 |
% \begin{macro}{\ybPrintIndex} |
| 215 |
% Prints index with an optional name of the section (instead of ``Index''): |
| 216 |
%\iffalse |
| 217 |
%<*verb> |
| 218 |
%\fi |
| 219 |
\begin{verbatim} |
| 220 |
\documentclass{yb-book} |
| 221 |
\begin{document} |
| 222 |
Hello, world! |
| 223 |
\ybPrintIndex[Recommended Books] |
| 224 |
\end{document} |
| 225 |
\end{verbatim} |
| 226 |
%\iffalse |
| 227 |
%</verb> |
| 228 |
%\fi |
| 229 |
% \end{macro} |
| 230 |
|
| 231 |
% \StopEventually{} |
| 232 |
|
| 233 |
% \section{Implementation} |
| 234 |
|
| 235 |
% \changes{v0.1.0}{2022/01/09}{Initial version} |
| 236 |
% \changes{v0.2.0}{2022/10/02}{Started using l3build} |
| 237 |
|
| 238 |
% First, we parse package options: |
| 239 |
% \changes{v0.3.0}{2023/05/22}{The \texttt{pgfopts} package is now used to parse package options.} |
| 240 |
% \changes{v0.5.0}{2024/01/02}{The \texttt{sparse} package option added, to place every section on a new page.} |
| 241 |
% \changes{v0.6.0}{2025/01/08}{The \texttt{apa} package option added, to enable APA citation style.} |
| 242 |
% \changes{v0.7.0}{2025/12/14}{The \texttt{colored} package option added, to enable colors.} |
| 243 |
% \begin{macrocode} |
| 244 |
\RequirePackage{pgfopts} |
| 245 |
\pgfkeys{ |
| 246 |
/yb/.cd, |
| 247 |
apa/.store in=\yb@apa, |
| 248 |
authordraft/.store in=\yb@authordraft, |
| 249 |
compact/.store in=\yb@compact, |
| 250 |
manuscript/.store in=\yb@manuscript, |
| 251 |
colored/.store in=\yb@colored, |
| 252 |
sparse/.store in=\yb@sparse, |
| 253 |
} |
| 254 |
\ProcessPgfPackageOptions{/yb} |
| 255 |
% \end{macrocode} |
| 256 |
|
| 257 |
% Then, depending on the options like |authordraft| and |manuscript|, we preset |
| 258 |
% options of the class |book| and then load it: |
| 259 |
% \begin{macrocode} |
| 260 |
\makeatletter |
| 261 |
\ifdefined\yb@authordraft |
| 262 |
\PassOptionsToClass{11pt}{book} |
| 263 |
\PassOptionsToClass{oneside}{book} |
| 264 |
\else |
| 265 |
\ifdefined\yb@manuscript |
| 266 |
\PassOptionsToClass{12pt}{book} |
| 267 |
\PassOptionsToClass{oneside}{book} |
| 268 |
\else |
| 269 |
\PassOptionsToClass{11pt}{book} |
| 270 |
\PassOptionsToClass{twoside}{book} |
| 271 |
\fi |
| 272 |
\fi |
| 273 |
\makeatother |
| 274 |
\LoadClass{book} |
| 275 |
% \end{macrocode} |
| 276 |
|
| 277 |
% Then, we load \href{https://ctan.org/pkg/href-ul}{href-ul} to underline links correctly: |
| 278 |
% \begin{macrocode} |
| 279 |
\RequirePackage{href-ul} |
| 280 |
% \end{macrocode} |
| 281 |
|
| 282 |
% Then, we load \href{https://ctan.org/pkg/cleveref}{cleveref} for the |\cref| command: |
| 283 |
% \changes{v0.7.0}{2025/07/06}{Added \texttt{cleveref} package for the \texttt{\char`\\cref} command.} |
| 284 |
% \begin{macrocode} |
| 285 |
\PassOptionsToPackage{capitalize}{cleveref} |
| 286 |
\RequirePackage{amsmath} |
| 287 |
\RequirePackage{cleveref} |
| 288 |
\crefformat{section}{\S#2#1#3} |
| 289 |
% \end{macrocode} |
| 290 |
|
| 291 |
% The class does not change the main font; the default Computer Modern |
| 292 |
% Roman is used. Document authors are free to select a different font in |
| 293 |
% their own preamble. |
| 294 |
% \changes{v0.5.1}{2025/01/05}{Added the usage of \texttt{inputenc} in order to ensure UTF-8 encoding for the sources.} |
| 295 |
% \changes{v0.8.1}{2026/05/25}{Removed the CMU Concrete font setup; the class no longer changes the main font and works under any engine.} |
| 296 |
|
| 297 |
% \begin{macro}{geometry} |
| 298 |
% Then, using |geometry|, we set up page layout: |
| 299 |
% \begin{macrocode} |
| 300 |
\RequirePackage{geometry} |
| 301 |
\geometry{ |
| 302 |
paperwidth=6in, paperheight=9in, |
| 303 |
bindingoffset=0.25in, |
| 304 |
left=0.75in, right=0.75in, top=0.75in, bottom=1.25in} |
| 305 |
\makeatletter |
| 306 |
\ifdefined\yb@authordraft |
| 307 |
\geometry{a4paper, margin=1in, left=1.5in} |
| 308 |
\else |
| 309 |
\ifdefined\yb@manuscript |
| 310 |
\geometry{a4paper, margin=1.2in} |
| 311 |
\fi |
| 312 |
\fi |
| 313 |
\makeatother |
| 314 |
% \end{macrocode} |
| 315 |
% \end{macro} |
| 316 |
|
| 317 |
% Then, we load \href{https://ctan.org/pkg/anyfontsize}{anyfontsize} to enable all sizes of fonts: |
| 318 |
% \begin{macrocode} |
| 319 |
\RequirePackage{anyfontsize} |
| 320 |
% \end{macrocode} |
| 321 |
|
| 322 |
% Then, we load \href{https://ctan.org/pkg/tikz}{tikz} for graphics: |
| 323 |
% \begin{macrocode} |
| 324 |
\RequirePackage{tikz} |
| 325 |
\usetikzlibrary{positioning} |
| 326 |
\usetikzlibrary{shapes} |
| 327 |
\usetikzlibrary{fit} |
| 328 |
% \end{macrocode} |
| 329 |
|
| 330 |
% Then, we load \href{https://ctan.org/pkg/chngcntr}{chngcntr} for something else: |
| 331 |
% \begin{macrocode} |
| 332 |
\RequirePackage{chngcntr} |
| 333 |
\counterwithout{footnote}{chapter} |
| 334 |
% \end{macrocode} |
| 335 |
|
| 336 |
% Then, we load \href{https://ctan.org/pkg/lastpage}{lastpage} to enable rendering of the last page number: |
| 337 |
% \begin{macrocode} |
| 338 |
\RequirePackage{lastpage} |
| 339 |
% \end{macrocode} |
| 340 |
|
| 341 |
% Then, we load \href{https://ctan.org/pkg/paralist}{paralist} for inline enumeration: |
| 342 |
% \begin{macrocode} |
| 343 |
\RequirePackage{paralist} |
| 344 |
% \end{macrocode} |
| 345 |
|
| 346 |
% Then, we load \href{https://ctan.org/pkg/xcolor}{xcolor} for colors: |
| 347 |
% \begin{macrocode} |
| 348 |
\RequirePackage{xcolor} |
| 349 |
% \end{macrocode} |
| 350 |
|
| 351 |
% Then, we load \href{https://ctan.org/pkg/graphicx}{graphicx} to enable graphic files inclusion: |
| 352 |
% \begin{macrocode} |
| 353 |
\RequirePackage{graphicx} |
| 354 |
% \end{macrocode} |
| 355 |
|
| 356 |
% Then, we load \href{https://ctan.org/pkg/enumitem}{enumitem} for inline enumeration: |
| 357 |
% \begin{macrocode} |
| 358 |
\PassOptionsToPackage{inline}{enumitem} |
| 359 |
\RequirePackage{enumitem} |
| 360 |
\setlist{nosep} |
| 361 |
% \end{macrocode} |
| 362 |
|
| 363 |
% Then, we load \href{https://ctan.org/pkg/float}{float} for floating figures: |
| 364 |
% \begin{macrocode} |
| 365 |
\RequirePackage{float} |
| 366 |
% \end{macrocode} |
| 367 |
|
| 368 |
% Then, we load \href{https://ctan.org/pkg/xfp}{xfp} and |
| 369 |
% \href{https://ctan.org/pkg/xifthen}{xifthen} for if-then-else: |
| 370 |
% \begin{macrocode} |
| 371 |
\RequirePackage{xfp} |
| 372 |
\RequirePackage{xifthen} |
| 373 |
% \end{macrocode} |
| 374 |
|
| 375 |
% Then, we load \href{https://ctan.org/pkg/csquotes}{csquotes} for better rendering: |
| 376 |
% \begin{macrocode} |
| 377 |
\PassOptionsToPackage{autostyle=try}{csquotes} |
| 378 |
\RequirePackage{csquotes} |
| 379 |
% \end{macrocode} |
| 380 |
|
| 381 |
% \begin{macro}{\pagestyle} |
| 382 |
% Then, we set the layout of a page to |plain|: |
| 383 |
% \begin{macrocode} |
| 384 |
\pagestyle{plain} |
| 385 |
% \end{macrocode} |
| 386 |
% \end{macro} |
| 387 |
|
| 388 |
% \begin{macro}{setspace} |
| 389 |
% Then, using |setspace| package we set the spacing between lines in the text, |
| 390 |
% depending on the package options: |
| 391 |
% \begin{macrocode} |
| 392 |
\RequirePackage{setspace} |
| 393 |
\setstretch{1.2} |
| 394 |
\makeatletter |
| 395 |
\ifdefined\yb@compact\setstretch{1.0}\fi |
| 396 |
\ifdefined\yb@manuscript\setstretch{1.1}\fi |
| 397 |
\ifdefined\yb@authordraft\setstretch{1.4}\fi |
| 398 |
\makeatother |
| 399 |
% \end{macrocode} |
| 400 |
% \end{macro} |
| 401 |
|
| 402 |
% \begin{macro}{biblatex} |
| 403 |
% Then, we configure |biblatex| for citation management: |
| 404 |
% \begin{macrocode} |
| 405 |
\PassOptionsToPackage{indexing=cite, |
| 406 |
natbib=true,maxnames=2,minnames=1,doi=true, |
| 407 |
url=false,isbn=false}{biblatex} |
| 408 |
\makeatletter |
| 409 |
\ifdefined\yb@apa |
| 410 |
\PassOptionsToPackage{style=authoryear}{biblatex} |
| 411 |
\else |
| 412 |
\PassOptionsToPackage{style=numeric}{biblatex} |
| 413 |
\fi |
| 414 |
\makeatother |
| 415 |
\RequirePackage{doi} |
| 416 |
\RequirePackage{biblatex} |
| 417 |
\DeclareCiteCommand{\citetitle} |
| 418 |
{\boolfalse{citetracker}% |
| 419 |
\boolfalse{pagetracker}% |
| 420 |
\usebibmacro{prenote}} |
| 421 |
{\ifciteindex |
| 422 |
{\indexnames{labelname}} |
| 423 |
{}% |
| 424 |
\printfield[citetitle]{labeltitle}} |
| 425 |
{\multicitedelim} |
| 426 |
{\usebibmacro{postnote}} |
| 427 |
\DeclareCiteCommand*{\citetitle} |
| 428 |
{\boolfalse{citetracker}% |
| 429 |
\boolfalse{pagetracker}% |
| 430 |
\usebibmacro{prenote}} |
| 431 |
{\ifciteindex |
| 432 |
{\indexnames{labelname}} |
| 433 |
{}% |
| 434 |
\printfield[citetitle]{title}} |
| 435 |
{\multicitedelim} |
| 436 |
{\usebibmacro{postnote}} |
| 437 |
% \end{macrocode} |
| 438 |
% \end{macro} |
| 439 |
|
| 440 |
% \begin{macro}{condensed} |
| 441 |
% Then, we define |condensed| environment for snippets: |
| 442 |
% \begin{macrocode} |
| 443 |
\newenvironment{condensed} |
| 444 |
{\begingroup% |
| 445 |
\addfontfeature{LetterSpace=-15}% |
| 446 |
\lstset{columns=fixed,basewidth=0.45em}} |
| 447 |
{\endgroup} |
| 448 |
% \end{macrocode} |
| 449 |
% \end{macro} |
| 450 |
|
| 451 |
% \begin{macro}{microtype} |
| 452 |
% Then, we include |microtype| for better rendering: |
| 453 |
% \begin{macrocode} |
| 454 |
\makeatletter |
| 455 |
\ifdefined\yb@authordraft |
| 456 |
\PassOptionsToPackage{nopatch=footnote}{microtype} |
| 457 |
\else |
| 458 |
\PassOptionsToPackage{nopatch=footnote,protrusion=true}{microtype} |
| 459 |
\fi |
| 460 |
\makeatother |
| 461 |
\RequirePackage{microtype} |
| 462 |
% \end{macrocode} |
| 463 |
% \end{macro} |
| 464 |
|
| 465 |
% \begin{macro}{\section} |
| 466 |
% Then, we redefine the |\section| command: |
| 467 |
% \begin{macrocode} |
| 468 |
\makeatletter |
| 469 |
\let\yb@oldsection\section |
| 470 |
\def\yb@secstart{\ifdefined\yb@sparse\newpage\fi} |
| 471 |
\ifdefined\yb@authordraft |
| 472 |
\PassOptionsToPackage{medium}{titlesec} |
| 473 |
\RequirePackage{titlesec} |
| 474 |
\else |
| 475 |
\PassOptionsToPackage{raggedright}{titlesec} |
| 476 |
\RequirePackage{titlesec} |
| 477 |
\titlespacing{\section}{0em}{2em}{1em} |
| 478 |
\renewcommand\section{\yb@secstart\yb@oldsection} |
| 479 |
\fi |
| 480 |
\ifdefined\yb@compact |
| 481 |
\renewcommand\section{\yb@secstart\vspace{2em}\yb@oldsection} |
| 482 |
\fi |
| 483 |
\makeatother |
| 484 |
% \end{macrocode} |
| 485 |
% \end{macro} |
| 486 |
|
| 487 |
% Then, we do small tweaking: |
| 488 |
% \begin{macrocode} |
| 489 |
\makeatletter |
| 490 |
\renewcommand\@makefntext[1]{% |
| 491 |
\raggedright% |
| 492 |
\parindent=1em% |
| 493 |
\noindent\hb@[email protected]{\hss\@makefnmark}#1} |
| 494 |
\makeatother |
| 495 |
% \end{macrocode} |
| 496 |
|
| 497 |
% Then, if it's an |authordraft|, we put a watermark comment: |
| 498 |
% \begin{macrocode} |
| 499 |
\makeatletter |
| 500 |
\ifdefined\yb@authordraft |
| 501 |
\PassOptionsToPackage{absolute}{textpos} |
| 502 |
\RequirePackage{textpos} |
| 503 |
\TPGrid{16}{16} |
| 504 |
\RequirePackage{fancyhdr} |
| 505 |
\pagestyle{fancy} |
| 506 |
\renewcommand\headrulewidth{0em} |
| 507 |
\renewcommand\footrulewidth{0em} |
| 508 |
\setlength{\headheight}{3em} |
| 509 |
\fancyhf{} |
| 510 |
\fancyhead[L,C,LO,CO]{} |
| 511 |
\fancyhead[R,RO]{ |
| 512 |
\begin{textblock}{16}[0.5,0.5](8,8)% |
| 513 |
\tikz \node[minimum width=16\TPHorizModule] {% |
| 514 |
\fontsize{64}{64}\selectfont\bfseries% |
| 515 |
\rotatebox{45}{ |
| 516 |
\tikz \node |
| 517 |
[fill=gray!6, font=\ttfamily\color{white}] |
| 518 |
{it is a draft};% |
| 519 |
}% |
| 520 |
};% |
| 521 |
\end{textblock}% |
| 522 |
\begin{textblock}{4}(11.5,1)% |
| 523 |
\tikz \node [color=gray, rotate=270, |
| 524 |
font=\ttfamily\scriptsize, text width=24em] at (0,0) {% |
| 525 |
Copyright \textcopyright{} \the\year{} by \theauthor{}. |
| 526 |
All rights reserved. No part of the contents of |
| 527 |
this book may be reproduced or transmitted in any |
| 528 |
form or by any means without the written permission |
| 529 |
of the publisher. This particular manuscript is |
| 530 |
printed for \textbf{\thereviewer{}} and may be used only |
| 531 |
for one-time review. The manuscript has to be destroyed |
| 532 |
after the review.% |
| 533 |
}; |
| 534 |
\end{textblock} |
| 535 |
} |
| 536 |
\fancyfoot[C,CO,C]{\small\ttfamily% |
| 537 |
page \thepage{} of \pageref{LastPage}} |
| 538 |
\fi |
| 539 |
\makeatother |
| 540 |
% \end{macrocode} |
| 541 |
|
| 542 |
% \begin{macro}{\maketitle} |
| 543 |
% Then, we redefine the |\maketitle| command: |
| 544 |
% \begin{macrocode} |
| 545 |
\renewcommand\maketitle{ |
| 546 |
{\LARGE\textbf{\thetitle}} |
| 547 |
\\[1em] |
| 548 |
by \theauthor{} |
| 549 |
\\[4em] |
| 550 |
\ifx\thevolume\empty\else% |
| 551 |
Volume \thevolume{}\\ |
| 552 |
\fi |
| 553 |
\ifx\thedate\empty\else% |
| 554 |
Rendered on \thedate{}\\ |
| 555 |
\fi |
| 556 |
\ifx\theversion\empty\else% |
| 557 |
Ver. \theversion{} |
| 558 |
\fi |
| 559 |
} |
| 560 |
% \end{macrocode} |
| 561 |
% \end{macro} |
| 562 |
|
| 563 |
% \begin{macro}{\incolor} |
| 564 |
% Then, we define the |\incolor| command: |
| 565 |
% \begin{macrocode} |
| 566 |
\makeatletter |
| 567 |
\newcommand\incolor[2]{\ifdefined\yb@colored\textcolor{#1}{#2}\else#2\fi} |
| 568 |
\makeatother |
| 569 |
% \end{macrocode} |
| 570 |
% \end{macro} |
| 571 |
|
| 572 |
% \begin{macro}{\ix} |
| 573 |
% Then, we define the |\ix| command: |
| 574 |
% \begin{macrocode} |
| 575 |
\newcommand\ix[2][]{% |
| 576 |
\incolor{brown}{#2}% |
| 577 |
\def\ixparam{#1}% |
| 578 |
\ifx\ixparam\empty% |
| 579 |
\index{#2}% |
| 580 |
\else% |
| 581 |
\index{#1}% |
| 582 |
\fi} |
| 583 |
% \end{macrocode} |
| 584 |
% \end{macro} |
| 585 |
|
| 586 |
% \begin{macro}{\emph} |
| 587 |
% Then, we redefine the |\emph| command: |
| 588 |
% \begin{macrocode} |
| 589 |
\renewcommand\emph[1]{\incolor{orange}{\textit{#1}}} |
| 590 |
% \end{macrocode} |
| 591 |
% \end{macro} |
| 592 |
|
| 593 |
% \begin{macro}{\ybPrintTitlePage} |
| 594 |
% Then, we define the |\ybPrintTitlePage| command: |
| 595 |
% \begin{macrocode} |
| 596 |
\makeatletter |
| 597 |
\newcommand\ybPrintTitlePage{ |
| 598 |
\ifdefined\yb@authordraft\else |
| 599 |
\begin{titlepage} |
| 600 |
\ttfamily |
| 601 |
\vspace*{\fill} |
| 602 |
\noindent |
| 603 |
{\Huge\thetitle} |
| 604 |
\\[1em] |
| 605 |
by \theauthor{} |
| 606 |
\\[4em] |
| 607 |
\ifx\thevolume\empty\else% |
| 608 |
Volume \thevolume{}\\ |
| 609 |
\fi |
| 610 |
\ifx\thedate\empty\else% |
| 611 |
\thedate{}\\ |
| 612 |
\fi |
| 613 |
\ifx\theversion\empty\else% |
| 614 |
\theversion{} |
| 615 |
\fi |
| 616 |
\vspace*{\fill} |
| 617 |
\end{titlepage} |
| 618 |
\fi |
| 619 |
} |
| 620 |
\makeatother |
| 621 |
% \end{macrocode} |
| 622 |
% \end{macro} |
| 623 |
|
| 624 |
% \begin{macro}{\ybEpigraph} |
| 625 |
% Then, we define the |\ybEpigraph| command to print the epigraph: |
| 626 |
% \begin{macrocode} |
| 627 |
\newcommand\ybEpigraph[3]{ |
| 628 |
\cleardoublepage |
| 629 |
\vspace*{\fill} |
| 630 |
\begin{quote} |
| 631 |
\begin{raggedleft} |
| 632 |
``#1'' \\[1em] |
| 633 |
{---} #2 \\ |
| 634 |
\citetitle{#3}\\ |
| 635 |
\citeyear{#3}\par |
| 636 |
\end{raggedleft} |
| 637 |
\end{quote} |
| 638 |
\vspace*{\fill}} |
| 639 |
% \end{macrocode} |
| 640 |
% \end{macro} |
| 641 |
|
| 642 |
% \begin{macro}{\ybPrintTOC} |
| 643 |
% Then, we define the |\ybPrintTOC| command to print the table of contents: |
| 644 |
% \begin{macrocode} |
| 645 |
\makeatletter |
| 646 |
\newcommand\ybPrintTOC{% |
| 647 |
\ifdefined\yb@authordraft\else% |
| 648 |
\ifdefined\yb@compact\else\cleardoublepage\fi% |
| 649 |
{\setstretch{0.7}\tableofcontents}% |
| 650 |
\fi% |
| 651 |
} |
| 652 |
\makeatother |
| 653 |
% \end{macrocode} |
| 654 |
% \end{macro} |
| 655 |
|
| 656 |
% \begin{macro}{\ybPrintIndex} |
| 657 |
% Then, we configure the |imakeidx| package and define the |\ybPrintIndex| command: |
| 658 |
% \begin{macrocode} |
| 659 |
\RequirePackage{imakeidx} |
| 660 |
\renewbibmacro*{citeindex}{\indexnames{labelname}{}} |
| 661 |
\makeindex |
| 662 |
\indexsetup{othercode={\hyphenpenalty=10000}} |
| 663 |
\makeatletter |
| 664 |
\newcommand\ybPrintIndex[1][Index]{% |
| 665 |
\ifdefined\yb@authordraft\else% |
| 666 |
\ifdefined\yb@compact\else\cleardoublepage\fi% |
| 667 |
{% |
| 668 |
\setstretch{1.0}% |
| 669 |
\small% |
| 670 |
\addcontentsline{toc}{chapter}{#1}% |
| 671 |
\printindex% |
| 672 |
}% |
| 673 |
\fi% |
| 674 |
} |
| 675 |
\makeatother |
| 676 |
% \end{macrocode} |
| 677 |
% \end{macro} |
| 678 |
|
| 679 |
% \begin{macro}{\ybQuote} |
| 680 |
% Then, with the help of |wrapfig| and |mdframed|, we define the |\ybQuote| command: |
| 681 |
% \begin{macrocode} |
| 682 |
\RequirePackage{wrapfig} |
| 683 |
\RequirePackage{mdframed} |
| 684 |
\RequirePackage{changepage} |
| 685 |
\strictpagecheck |
| 686 |
\mdfdefinestyle{quoteodd}{backgroundcolor=black!0, |
| 687 |
leftmargin=1em,rightmargin=0em, |
| 688 |
innerleftmargin=1em,innerrightmargin=0em, |
| 689 |
innertopmargin=0em,innerbottommargin=0em, |
| 690 |
skipabove=0em,skipbelow=0em, |
| 691 |
linewidth=.2em, |
| 692 |
topline=false,bottomline=false,rightline=false} |
| 693 |
\mdfdefinestyle{quoteeven}{backgroundcolor=black!0, |
| 694 |
rightmargin=1em,leftmargin=0em, |
| 695 |
innerrightmargin=1em,innerleftmargin=0em, |
| 696 |
innertopmargin=0em,innerbottommargin=0em, |
| 697 |
skipabove=0em,skipbelow=0em, |
| 698 |
linewidth=.2em, |
| 699 |
topline=false,bottomline=false,leftline=false} |
| 700 |
\makeatletter |
| 701 |
\newcommand\ybQuote[3]{% |
| 702 |
\ifthenelse{\isempty{#3}}{}{ |
| 703 |
\ifx\hfuzz#2\hfuzz% |
| 704 |
\index{#3}% |
| 705 |
\else% |
| 706 |
\index{#3, #2}% |
| 707 |
\fi% |
| 708 |
}% |
| 709 |
\ifdim\pagetotal<4\baselineskip\relax% |
| 710 |
\ClassWarning{yb-book}{ybQuote stays at the top of a page: \detokenize{#1}}% |
| 711 |
\fi% |
| 712 |
\ifdim\dimexpr\pagegoal-\pagetotal\relax<8\baselineskip\relax% |
| 713 |
\ClassWarning{yb-book}{ybQuote stays at the bottom of a page: \detokenize{#1}}% |
| 714 |
\fi% |
| 715 |
\def\yb@body{% |
| 716 |
\raggedright% |
| 717 |
\ifx\hfuzz#3\hfuzz% |
| 718 |
#1% |
| 719 |
\else% |
| 720 |
``#1''\\\raggedleft---#2 #3% |
| 721 |
\fi% |
| 722 |
} |
| 723 |
\ifdefined\yb@authordraft% |
| 724 |
\begin{wrapfigure}{r}{0.4\textwidth}% |
| 725 |
\begin{mdframed}[style=quoteodd]% |
| 726 |
\yb@body% |
| 727 |
\end{mdframed}% |
| 728 |
\end{wrapfigure}% |
| 729 |
\else% |
| 730 |
\begin{wrapfigure}{o}[2em]{0.4\textwidth}% |
| 731 |
\sffamily\checkoddpage% |
| 732 |
\ifoddpage% |
| 733 |
\begin{mdframed}[style=quoteodd]\yb@body\end{mdframed}% |
| 734 |
\else% |
| 735 |
\begin{mdframed}[style=quoteeven]\yb@body\end{mdframed}% |
| 736 |
\fi% |
| 737 |
\vspace{-1em} |
| 738 |
\end{wrapfigure}% |
| 739 |
\fi% |
| 740 |
} |
| 741 |
\makeatother |
| 742 |
% \end{macrocode} |
| 743 |
% \end{macro} |
| 744 |
|
| 745 |
% Then, we use and configure |footmisc| as suggested |
| 746 |
% \href{https://tex.stackexchange.com/questions/40072/incompatibility-between-footmisc-option-multiple-and-hyperref/62091#62091}{here}: |
| 747 |
% \begin{macrocode} |
| 748 |
\RequirePackage{perpage} |
| 749 |
\PassOptionsToPackage{bottom,perpage,multiple}{footmisc} |
| 750 |
\RequirePackage{footmisc} |
| 751 |
\makeatletter |
| 752 |
\let\yb@oldfootnote\footnote |
| 753 |
\newcommand\yb@nexttoken\relax |
| 754 |
\newcommand\yb@isfootnote{% |
| 755 |
\ifx\footnote\yb@nexttoken\textsuperscript{,}\fi} |
| 756 |
\renewcommand\footnote[1]{% |
| 757 |
\yb@oldfootnote{#1}\futurelet\yb@nexttoken\yb@isfootnote} |
| 758 |
\makeatother |
| 759 |
% \end{macrocode} |
| 760 |
|
| 761 |
% \begin{macro}{\ybPrintBibliography} |
| 762 |
% Then, we define |\ybPrintBibliography|, to print a list of references: |
| 763 |
% \changes{v0.6.2}{2025/01/19}{The \texttt{\char`\\ybPrintBibliography} command has an optional argument, which is the title of the chapter.} |
| 764 |
% \begin{macrocode} |
| 765 |
\makeatletter |
| 766 |
\newcommand\ybPrintBibliography[1][Bibliography]{% |
| 767 |
\AtNextBibliography{\small}% |
| 768 |
\raggedright% |
| 769 |
\ifdefined\yb@manuscript% |
| 770 |
\setlength\bibitemsep{0em}% |
| 771 |
\newpage% |
| 772 |
\begin{multicols}{2}% |
| 773 |
{\setstretch{1.0}\printbibliography}% |
| 774 |
\end{multicols}% |
| 775 |
\else% |
| 776 |
\setlength\bibitemsep{.2em}% |
| 777 |
\@openrightfalse% |
| 778 |
\printbibliography[heading=bibintoc,title={#1}]% |
| 779 |
\ifdefined\yb@compact\@openrighttrue\fi% |
| 780 |
\fi% |
| 781 |
} |
| 782 |
\makeatother |
| 783 |
% \end{macrocode} |
| 784 |
% \end{macro} |
| 785 |
|
| 786 |
% \begin{macro}{\highlight} |
| 787 |
% Then, we define the |\highlight| command: |
| 788 |
% \changes{v0.7.0}{2025/11/30}{The \texttt{\char`\\highlight} command was added.} |
| 789 |
% \begin{macrocode} |
| 790 |
\newcommand\highlight[1]{% |
| 791 |
\tikz[baseline=(text.base)] { |
| 792 |
\node[inner sep=0em, outer sep=0em] (text) {% |
| 793 |
{\ifdefined\yb@colored\color{orange}\fi#1}}; |
| 794 |
\begin{scope} |
| 795 |
\path[use as bounding box] (text.east) rectangle (text.west); |
| 796 |
\draw[decorate, |
| 797 |
decoration={random steps, amplitude=0.05em, segment length=0.3em}, |
| 798 |
line join=round, |
| 799 |
line cap=round, |
| 800 |
line width=.08em, |
| 801 |
draw=gray!80] ($(text.west) + (-0.2em, -.46em)$) rectangle ($(text.east) + (+0.2em, -.46em)$); |
| 802 |
\end{scope} |
| 803 |
}% |
| 804 |
} |
| 805 |
% \end{macrocode} |
| 806 |
% \end{macro} |
| 807 |
|
| 808 |
% Then, a few layout configurations at the beginning of the document: |
| 809 |
% \changes{v0.6.6}{2025/07/06}{Penalties for widows and clubs specified.} |
| 810 |
% \begin{macrocode} |
| 811 |
\makeatletter |
| 812 |
\AtBeginDocument{% |
| 813 |
\raggedbottom% |
| 814 |
\ifdefined\yb@authordraft% |
| 815 |
\raggedright% |
| 816 |
\fi% |
| 817 |
\setlength\topskip{0em}% |
| 818 |
\setlength\parindent{0em}% |
| 819 |
\setlength\fboxsep{0em}% |
| 820 |
\setlength\parskip{.5em}% |
| 821 |
\exhyphenpenalty=10000% to avoid line breaks before and after an em dash |
| 822 |
\widowpenalty=10000% to have fewer widows |
| 823 |
\clubpenalty=10000% to have fewer orphans |
| 824 |
\interfootnotelinepenalty=10000% to format footnotes better |
| 825 |
\hfuzz=3pt % |
| 826 |
\tolerance=1000 % |
| 827 |
\emergencystretch=1em % |
| 828 |
\hbadness=2000 % |
| 829 |
} |
| 830 |
\makeatother |
| 831 |
% \end{macrocode} |
| 832 |
|
| 833 |
% Finally, a few meta commands with default values: |
| 834 |
% \begin{macrocode} |
| 835 |
\newcommand*\thetitle{\textbackslash{}thetitle} |
| 836 |
\let\thevolume\empty |
| 837 |
\let\thedate\empty |
| 838 |
\newcommand*\theversion{\textbackslash{}theversion} |
| 839 |
\newcommand*\theauthor{\textbackslash{}theauthor} |
| 840 |
\newcommand*\thereviewer{\textbackslash{}thereviewer} |
| 841 |
|
| 842 |
\endinput |
| 843 |
% \end{macrocode} |
| 844 |
|
| 845 |
% \Finale |
| 846 |
|
| 847 |
%\clearpage |
| 848 |
% |
| 849 |
%\PrintChanges |
| 850 |
%\clearpage |
| 851 |
%\PrintIndex |