diff --git a/.gitignore b/.gitignore index 410ad31..34cec95 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ out/* *.pdf *.xdv *.gz +src/version.tex diff --git a/src/Makefile b/src/Makefile index fdd02e6..220cc3c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,19 +1,53 @@ # Igal Tabachnik, 2007. # Based on work by Andres Raba et al., 2013-2015. +.PHONY: default all clean version.tex + DIR := $(shell pwd) +GIT_VER := $(shell git describe --always --long | tr -d '\n') -all: ctfp.pdf +# Default top-level LaTeX to generate +DEFAULTTOPTEX = ctfp-reader.tex ctfp-print.tex -ctfp.pdf: ctfp.tex - latexmk -shell-escape -interaction=nonstopmode -halt-on-error -norc -pdflatex="xelatex %O %S" -pdf -dvi- -ps- $<; \ - mkdir -p ../out && mv ctfp.pdf ../out/category-theory-for-programmers.pdf +# Top-level LaTeX files from which CTFP book can be generated +TOPTEXFILES = version.tex $(DEFAULTTOPTEX) + +# Default PDF file to make +DEFAULTPDF:=$(DEFAULTTOPTEX:.tex=.pdf) +# Other PDF files for the CTFP book +TOPPDFFILES:=$(TOPTEXFILES:.tex=.pdf) + +# Configuration files +OPTFILES = opt-print-ustrade.tex \ + opt-reader-10in.tex + +# All the LaTeX files for the CTFP book in order of dependency +TEXFILES = $(TOPTEXFILES) $(OPTFILES) + +default: $(DEFAULTPDF) copy + +all default: copy# todo cover + +# Main targets +$(TOPPDFFILES) : %.pdf : %.tex $(TEXFILES) + if which latexmk > /dev/null 2>&1 ;\ + then latexmk -shell-escape -interaction=nonstopmode -halt-on-error -norc -pdflatex="xelatex %O %S" -pdf $< ;\ + else echo "Error: unable to find latexmk. Is it installed?" ;\ + fi + +version.tex: + /bin/echo -n '\newcommand{\OPTversion}{' > version.tex + git describe --always --long | tr -d '\n' >> version.tex + /bin/echo -n '}' >> version.tex + +copy: + echo 'Creating output directory: $(GIT_VER)' + mkdir -p ../out/$(GIT_VER) + mv ctfp-reader.pdf ../out/$(GIT_VER)/category-theory-for-programmers.pdf + mv ctfp-print.pdf ../out/$(GIT_VER)/category-theory-for-programmers-print.pdf clean: - latexmk -CA - -clean-all: clean - ${RM} ctfp.fls ../out/category-theory-for-programmers.pdf + rm -f *~ *.aux {ctfp-*}.{out,log,pdf,dvi,fls,fdb_latexmk,aux,brf,bbl,idx,ilg,ind,toc,sed} rm -rf _minted-ctfp - -.PHONY: all clean clean-all + if which latexmk > /dev/null 2>&1 ; then latexmk -CA; fi + rm -rf ../out \ No newline at end of file diff --git a/src/content/1.7/Functors.tex b/src/content/1.7/Functors.tex index cbc0e0c..01c0073 100644 --- a/src/content/1.7/Functors.tex +++ b/src/content/1.7/Functors.tex @@ -14,17 +14,13 @@ the image of $f$ in $\cat{D}$, $F f$, will connect the image of $a$ to the image of $b$: \[F f \Colon F a \to F b\] -\begin{wrapfigure}[8]{R}{0pt} -\raisebox{0pt}[\dimexpr\height]{ -\includegraphics[width=42.5mm]{images/functor.jpg}} +\begin{wrapfigure}{r}{0pt} +\includegraphics[width=0.3\textwidth]{images/functor.jpg} \end{wrapfigure} - -\noindent (This is a mixture of mathematical and Haskell notation that hopefully makes sense by now. I won't use parentheses when applying functors to objects or morphisms.) -\noindent As you can see, a functor preserves the structure of a category: what's connected in one category will be connected in the other category. But there's something @@ -45,9 +41,8 @@ Finally, we want all identity morphisms in $\cat{C}$ to be mapped to identity mo $\cat{D}$: \[F \idarrow[a] = \idarrow[F a]\] -\begin{wrapfigure}[11]{R}{0pt} -\raisebox{0pt}[\dimexpr\height-0\baselineskip\relax]{ -\includegraphics[width=40mm]{images/functorid.jpg}} +\begin{wrapfigure}{r}{0pt} +\includegraphics[width=0.3\textwidth]{images/functorid.jpg} \end{wrapfigure} \noindent diff --git a/src/content/1.9/Function Types.tex b/src/content/1.9/Function Types.tex index ae17012..dcbc499 100644 --- a/src/content/1.9/Function Types.tex +++ b/src/content/1.9/Function Types.tex @@ -1,9 +1,9 @@ -\lettrine[lhang=0.17]{S}{o far I've} been glossing over the meaning of function types. A function +\lettrine[lhang=0.17]{S}{o far} I've been glossing over the meaning of function types. A function type is different from other types. -\begin{wrapfigure}[11]{R}{0pt} +\begin{wrapfigure}[9]{R}{0pt} \raisebox{0pt}[\dimexpr\height-0.75\baselineskip\relax]{ -\includegraphics[width=40mm]{images/set-hom-set.jpg}}% +\includegraphics[width=32mm]{images/set-hom-set.jpg}}% \caption{Hom-set in Set is just a set} \end{wrapfigure} @@ -18,14 +18,12 @@ same category ---because it is, after all, a \emph{set}. The same is not true of other categories where hom-sets are external to a category. They are even called \emph{external} hom-sets. -\pagebreak -\begin{wrapfigure}[9]{R}{0pt} -\raisebox{0pt}[\dimexpr\height]{ -\includegraphics[width=40mm]{images/hom-set.jpg}}% -\caption{Hom-set in category C is an external set} -\end{wrapfigure} +\begin{figure}[h] + \centering + \includegraphics[width=50mm]{images/hom-set.jpg} + \caption{Hom-set in category C is an external set} +\end{figure} -\noindent It's the self-referential nature of the category $\Set$ that makes function types special. But there is a way, at least in some categories, to construct objects that represent hom-sets. Such objects are called @@ -65,9 +63,9 @@ with an argument $x$ (an element of $a$) and map it to $f x$ (the application of $f$ to $x$, which is an element of $b$). -\begin{figure} +\begin{figure}[h] \centering -\includegraphics[width=40mm]{images/functionset.jpg} +\includegraphics[width=50mm]{images/functionset.jpg} \caption{In Set we can pick a function $f$ from a set of functions $z$ and we can pick an argument $x$ from the set (type) $a$. We get an element $f x$ in the set (type) $b$.} @@ -83,9 +81,9 @@ function that maps every pair $(f, x)$ to $f x$. So that's the pattern: a product of two objects $z$ and $a$ connected to another object $b$ by a morphism $g$. -\begin{figure} +\begin{figure}[h] \centering -\includegraphics[width=40mm]{images/functionpattern.jpg} +\includegraphics[width=50mm]{images/functionpattern.jpg} \caption{A pattern of objects and morphisms that is the starting point of the universal construction} \end{figure} @@ -117,9 +115,9 @@ $z$ such that the application of $g'$ factors through the application of $g$. (Hint: Read this sentence while looking at the picture.) -\begin{figure} +\begin{figure}[h] \centering -\includegraphics[width=40mm]{images/functionranking.jpg} +\includegraphics[width=50mm]{images/functionranking.jpg} \caption{Establishing a ranking between candidates for the function object} \end{figure} @@ -156,9 +154,9 @@ way that its application morphism $g$ factorizes through $eval$. This object is better than any other object according to our ranking. -\begin{figure}[H] +\begin{figure}[h] \centering -\includegraphics[width=40mm]{images/universalfunctionobject.jpg} +\includegraphics[width=50mm]{images/universalfunctionobject.jpg} \caption{The definition of the universal function object. This is the same diagram as above, but now the object $a \Rightarrow b$ is \emph{universal}.} \end{figure} @@ -272,7 +270,7 @@ and uncurry :: (a -> b -> c) -> ((a, b) -> c) uncurry f (a, b) = f a b \end{Verbatim} -Notice that \code{curry} is the \newterm{factorizer} for the universal +Notice that \code{curry} is the \emph{factorizer} for the universal construction of the function object. This is especially apparent if it's rewritten in this form: @@ -349,7 +347,7 @@ C++ Standard Library that are usually implemented using lookups. Functions like \code{isupper} or \code{isspace} are implemented using tables, which are equivalent to tuples of 256 Boolean values. A tuple is a product type, so we are dealing with products of 256 -Booleans: \code{bool × bool × bool × ... × bool}. We know from +Booleans: {\small\texttt{bool × bool × bool × ... × bool}}. We know from arithmetics that an iterated product defines a power. If you ``multiply'' \code{bool} by itself 256 (or \code{char}) times, you get \code{bool} to the power of \code{char}, or \code{bool\textsuperscript{char}}. diff --git a/src/content/2.1/Declarative Programming.tex b/src/content/2.1/Declarative Programming.tex index 4a5108a..775c1e8 100644 --- a/src/content/2.1/Declarative Programming.tex +++ b/src/content/2.1/Declarative Programming.tex @@ -70,8 +70,8 @@ which is given by force divided by mass. These are the direct encodings of the differential equations corresponding to Newton's laws of motion: \begin{align*} -F = m \frac{dv}{dt} \\ -v = \frac{dx}{dt} +F &= m \frac{dv}{dt} \\ +v &= \frac{dx}{dt} \end{align*} Similar methods may be applied to more complex problems, like the propagation of electromagnetic fields using Maxwell's equations, or even diff --git a/src/content/3.10/Ends and Coends.tex b/src/content/3.10/Ends and Coends.tex index d449839..91ad012 100644 --- a/src/content/3.10/Ends and Coends.tex +++ b/src/content/3.10/Ends and Coends.tex @@ -306,7 +306,7 @@ As expected, the dual to an end is called a coend. It is constructed from a dual to a wedge called a cowedge (pronounced co-wedge, not cow-edge). -\begin{wrapfigure}[5]{R}{0pt} +\begin{wrapfigure}{R}{0pt} \raisebox{0pt}[\dimexpr\height-0.75\baselineskip\relax]{ \includegraphics[width=30mm]{images/end-31.jpg}}% \caption{An edgy cow?} diff --git a/src/copyright.tex b/src/copyright.tex index 9df4d18..a23a07b 100644 --- a/src/copyright.tex +++ b/src/copyright.tex @@ -14,7 +14,7 @@ Bartosz Milewski\\ \vspace{1.26em} \noindent -Version \texttt{\OPTVersion},\\\today +Version \texttt{\OPTversion}\\\today \vspace{1.6em} diff --git a/src/cover/blurb.tex b/src/cover/blurb.tex new file mode 100644 index 0000000..1be40d7 --- /dev/null +++ b/src/cover/blurb.tex @@ -0,0 +1,20 @@ +% !TEX root = cover2.tex +% Blurb on back cover + +{ +\fontsize{16}{18.5}\selectfont +\lettrine[lhang=0.17]{C}{ategory Theory} +is one of the most abstract branches of mathematics. It is usually taught to +graduate students after they have mastered several other branches of mathematics, +like algebra, topology, and group theory. It might therefore come as a shock that +the basic concepts of category theory can be explained in relatively simple terms +to anybody with some experience in programming. \\ + +That's because, just like programming, +category theory is about structure. Mathematicians discover structure in mathematical +theories, programmers discover structure in computer programs. Well structured programs +are easier to understand and maintain, and are less likely to contain bugs. Category theory provides the language to talk about structure, and learning it will make you +a better programmer. +\vfil + +} diff --git a/src/cover/cover.tex b/src/cover/cover.tex index d008367..db96f8e 100644 --- a/src/cover/cover.tex +++ b/src/cover/cover.tex @@ -1,14 +1,23 @@ -\documentclass[ - coverheight=9.861in, - spinewidth=1.375in, - bleedwidth=0.306in, - 11pt, - trimmed -]{bookcover} +% Cover for Lulu.com +\input{opt-ustrade} +\documentclass[\OPTfontsize]{article} +\input{opt-color} + +\usepackage{rotating} +\usepackage[usenames,dvipsnames]{xcolor} \usepackage{lettrine} -\usepackage{fancybox} -\usepackage{wrapfig} +\usepackage{graphicx} +\usepackage[many]{tcolorbox} +\usetikzlibrary{calc,positioning, shadings} + +\definecolor{covercolor}{cmyk}{\OPTcovercolor} +\definecolor{spinecolor}{cmyk}{\OPTspinecolor} +\definecolor{covertext}{cmyk}{\OPTcovertextcolor} +\definecolor{spinetext}{RGB}{248,154,14} +\pagecolor{covercolor} + +%%% Set the fonts \usepackage[T1]{fontenc} \usepackage{Alegreya} %% Option 'black' gives heavier bold face @@ -22,83 +31,140 @@ path picture={ }; }]{}; } +\input{\olpath/version} -% \newcommand{\tikzcircle}[2][red,fill=red]{\tikz[baseline=-0.5ex]\draw[#1,radius=#2] (0,0) circle ;}% +% Some of these dimensions are reported by Lulu.com *after* you +% upload the inner PDF file. +% For casewrap hardcover see http://static.lulu.com/static/images/help_casewrap_6x9.gif + +\newlength{\totalwidth} +\setlength{\totalwidth}{1064.571pt} % Reported as total cover width + +\newlength{\totalheight} +\setlength{\totalheight}{774pt} % Reported as total cover height + +\newlength{\spinewidth} +\setlength{\spinewidth}{74.571pt} % Reported as spine width + +\newlength{\coverheight} +\setlength{\coverheight}{666pt} % Height of text area + +\newlength{\coverwidth} +\setlength{\coverwidth}{441pt} % Width of text area + +\usepackage[margin=0pt, + papersize={\totalwidth,\totalheight}, + noheadfoot]{geometry} +%\usepackage{layout} +\newcommand{\coverpage}[1]{\vbox to \coverheight{\hbox to \coverwidth{#1}}} +\newcommand{\spine}[1]{\vbox to \coverheight{\hbox to \spinewidth{#1}}} + +\parindent=0pt +\parskip=0pt + +\newcommand{\background}{ + \begin{tikzpicture}[overlay,remember picture] + \fill [left color=gray!30, right color=covercolor] + (current page.north west) rectangle (current page.south east) ; + \end{tikzpicture} +} + +\newcommand{\frontpage}{ +\begin{minipage}[b][\coverheight][c]{\coverwidth} +\hbox{}\hfill +\begin{minipage}[b][\coverheight][t]{0.9\coverwidth} +\color{covertext} +\centering +\vspace{\OPTtopskip} +{\fontsize{\OPTcovertitlefont}{\OPTcovertitlefont}\bfseries\selectfont% + CATEGORY THEORY\\ + \vfill FOR PROGRAMMERS}\par +\vfill +\hspace*{-.5cm}\includegraphics[width=.6\coverwidth]{piggie} +\vfill -\definecolor{BackgroundColor}{HTML}{f3f6ed} -\definecolor{SpineBackColor}{HTML}{262626} -\definecolor{SpineFontColor}{RGB}{248,154,14} +{\Huge\bfseries\selectfont +Bartosz Milewski + +\vspace*{\OPTbotskip} +} + +\end{minipage}\hfill\hbox{} +\end{minipage} +} + +\newcommand{\spinetext}{ +\colorbox{spinecolor}{ + \begin{minipage}[b][\coverheight][t]{\spinewidth} + \begin{center} + \begin{rotate}{-90} + \color{covertext} + \hspace{\OPTtopskip} + \begin{minipage}{\coverheight} + {\color{spinetext}\bfseries\Huge\selectfont% + Category Theory for Programmers \hspace{2em} Bartosz Milewski} + \end{minipage} + \end{rotate} + \end{center} + \end{minipage} + } +} + +\newcommand{\backpage}{ +\begin{minipage}[b][\coverheight][t]{\coverwidth} +\begin{center} +\begin{minipage}[t]{.8\coverwidth} + \color{covertext} + \vspace{\OPTtopskip} + \input{blurb} + \includegraphics[width=.8\coverwidth]{bunnies} +\end{minipage} +\begin{minipage}{.9\textwidth} + \rule{\textwidth}{0.4pt} + \begin{tabular}[h]{p{4cm} p{12cm}} + \vspace{0pt} + \begin{tcolorbox}[beamer, + width=4cm, + arc=0pt, + boxsep=0pt, + left=0pt,right=0pt,top=0pt,bottom=0pt, + ] \includegraphics[width=4cm]{bartosz} + \end{tcolorbox} + & + \vspace{0pt} + \begin{minipage}[b]{.55\coverwidth} + \fontsize{11pt}{1.4em}\selectfont\textit{Category Theory for Programmers} + by Bartosz Milewski is licensed under a Creative Commons Attribution 4.0 + International License.\\ + \vfil + Visit bartoszmilewski.com for more posts on Category Theory and other topics.\\ + \break + \begin{minipage}[b]{4cm} + \whitebg{fig/icons/by} + \whitebg{fig/icons/cc} + \whitebg{fig/icons/sa} + \end{minipage}\\ + Edited by Igal Tabachnik + \end{minipage} + \begin{minipage}{.9\coverwidth} + \centering + \vspace{-25mm} + \includegraphics[width=2in]{isbn_barcode}\\ + \tiny{\texttt{\OPTversion}} + \end{minipage} +\end{tabular} +\end{minipage} +\end{center} +\end{minipage} +} \begin{document} - -\begin{bookcover} - \bookcovercomponent{color}{bg whole}{color=BackgroundColor} - \bookcovercomponent{color}{spine}{color=SpineBackColor} - \bookcovercomponent{normal}{front}{ - \vspace{2.5cm} - \begin{center} - \fontsize{40pt}{7em}\selectfont\bfseries - CATEGORY THEORY \\FOR PROGRAMMERS - \vfil - \hspace*{-1cm}\includegraphics[width=8cm]{./piggie.png}% - \vfil - \normalfont\Huge - \textbf{Bartosz Milewski} - \vfil - \vspace*{1cm} - \end{center}} - \bookcovercomponent{center}{spine}{ - \rotatebox[origin=c]{-90}{\color{SpineFontColor}\bfseries\Huge Category Theory for Programmers \hspace{2em} Bartosz Milewski}} - \bookcovercomponent{normal}{back}{ - \centering - \vspace{1mm} - \begin{figure}[H] - \includegraphics[width=120mm]{bunnies.png} - \end{figure} - \parbox{130mm}{\color{black} - \Large - \lettrine[lhang=0.17]{C}{ategory Theory} - is one of the most abstract branches of mathematics. It is usually taught to - graduate students after they have mastered several other branches of mathematics, - like algebra, topology, and group theory. It might therefore come as a shock that - the basic concepts of category theory can be explained in relatively simple terms - to anybody with some experience in programming. \\ - - That's because, just like programming, - category theory is about structure. Mathematicians discover structure in mathematical - theories, programmers discover structure in computer programs. Well structured programs - are easier to understand and maintain, and are less likely to contain bugs. Category - theory provides the language to talk about structure, and learning it will make you - a better programmer. - \rule{130mm}{0.4pt} - \begin{tabular}[h]{p{3.6cm} p{10cm}} - \vspace{0pt} - \begin{figure}[H] - \centering - \shadowsize=2pt - \fboxrule=0pt - \fboxsep=0pt - \color{gray} - \shadowbox{\fboxsep=1pt\includegraphics[height=40.5mm]{bartosz.jpg}} - \end{figure} - & - \vspace{0pt} - \begin{minipage}[b]{8.5cm} - \fontsize{11pt}{1.4em}\selectfont\textit{Category Theory for Programmers} - by Bartosz Milewski is licensed under a Creative Commons Attribution 4.0 - International License.\\ - \break - \begin{minipage}[b]{4cm} - \whitebg{/fig/icons/by} - \whitebg{/fig/icons/cc} - \whitebg{/fig/icons/sa} - \end{minipage} - - \break - Edited by Igal Tabachnik - \end{minipage} - \end{tabular}}} - -\end{bookcover} +% \background +\begin{center} + \vbox{} + \vfill + \mbox{\coverpage{\backpage}\spine{\spinetext}\coverpage{\frontpage}} + \vfill +\end{center} \end{document} \ No newline at end of file diff --git a/src/cover/frontpage.tex b/src/cover/frontpage.tex new file mode 100644 index 0000000..e69de29 diff --git a/src/cover/isbn_barcode.png b/src/cover/isbn_barcode.png new file mode 100644 index 0000000..23061cb Binary files /dev/null and b/src/cover/isbn_barcode.png differ diff --git a/src/cover/opt-color.tex b/src/cover/opt-color.tex new file mode 100644 index 0000000..80cecbe --- /dev/null +++ b/src/cover/opt-color.tex @@ -0,0 +1,6 @@ +% Options for color book + +% BACKGROUND OF COVER PAGE +\def\OPTcovercolor{0.0122,0,0.0366,0.0353} % CMYK +\def\OPTspinecolor{0, 0, 0, 85} +\def\OPTcovertextcolor{60,50,50,100} \ No newline at end of file diff --git a/src/cover/opt-ustrade.tex b/src/cover/opt-ustrade.tex new file mode 100644 index 0000000..53d5020 --- /dev/null +++ b/src/cover/opt-ustrade.tex @@ -0,0 +1,84 @@ +%%% FORMATTING OPTIONS FOR USTRADE SIZE +%%% This file gets included by the hott-xxx.tex files. + +% MACROS FOR FINE TUNING +\newcommand{\narrowbreak}{\\} +\newcommand{\narrowamp}{&} +\newcommand{\narrowequation}[1]{\begin{equation*}#1\end{equation*}} +\newenvironment{narrowmultline*}{\csname multline*\endcsname}{\csname endmultline*\endcsname} +\newenvironment{narrowmultline}{\csname multline\endcsname}{\csname endmultline\endcsname} + +% FONTS +\def\OPTfontsize{10pt} % Font size +\delimiterfactor=800 + +% PAGE FORMAT +% +% These settings are for letter format +\def\OPTpagesize{6in,9in} % Page size +\def\OPTtopmargin{0.75in} % Margin at the top of the page +\def\OPTbottommargin{0.75in} % Margin at the bottom of the page +\def\OPTinnermargin{0.5in} % Margin on the inner side of the page +\def\OPTbindingoffset{0.35in} % Extra offset on the inner side +\def\OPToutermargin{0.75in} % Margin on the outer side of the page + +% FORMATTING OF COVER PAGE +%\def\OPTcoverwidth{8.45in} % width of text on cover page, not used for US trade +%\def\OPTcoverheight{10.95in} % height of text on cover page +\def\OPTtopskip{35pt} % Skip at top of cover and back page (with units) +\def\OPTbotskip{35pt} % Skip at bottom of cover and back page (with units) +\def\OPTcovertitlefont{40} % Size of title font (no unit, pt assumed) +\def\OPTcoverspinefont{32} % Size of title font on the book spine (no unit, pt assumed) +\def\OPTcovertitleskip{20pt} % Skip between title and subtitle (with units) +\def\OPTcoversubtitlefont{22} % Size of subtitle font (no unit, pt assumed) +\def\OPTcoverauthorfont{18} % Size of author font (no unit, pt assumed) +\def\OPTcoverauthorskip{6pt} % Skip betewen first and second line of author (with units) + +% FORMATTING OF BACK COVER PAGE +\def\OPTbacktitlefont{\Large} % Size of "From the introduction" and "Get this book ..." +\def\OPTbackfont{\normalsize} % Size of text font + +% FORMATTING OF BASTARD TITLE, IF PRESENT +% (see opt-no-bastard.tex and opt-bastard.tex) +\def\OPTbastardtitlefont{17} +\def\OPTbastardsubtitlefont{11} +\def\OPTbastardwidth{0.42\textwidth} % Width of bastard title +\def\OPTbastardtitleskip{6pt} + +% FORMATTING OF TITLE PAGE +\def\OPTtitletitlefont{26} % Size of title font (no unit, pt assumed) +\def\OPTtitletitleskip{7pt} % Skip between title and subtitle (with units) +\def\OPTtitlesubtitlefont{17} % Size of subtitle font (no unit, pt assumed) +\def\OPTtitlewidth{0.65\textwidth} % Width of title +\def\OPTtitleskip{21pt} % Skip between title and author (with units) +\def\OPTtitleauthorfont{13} % Size of author font (no unit, pt assumed) +\def\OPTtitleauthorskip{4pt} % Skip betewen first and second line of author (with units) + +% PART FONTS +\def\OPTpartfont{28} % Size of "Part X" (without unit, pt assumed) +\def\OPTpartskip{14pt} % Skip between Part and title (with unit) +\def\OPTparttitlefont{42} % Size of part title (without unit, pt assumed) + +% FORMATTING OF CHAPTER TITLE +\def\OPTchapterfont{20} % Size of "Chapter X" (without unit, pt assumed) +\def\OPTchapterskip{14pt} % Skip between Chapter and title (with unit) +\def\OPTchaptertitlefont{24} % Size of chapter title (without unit, pt assumed) + +% FORMATTING OF PREFACE +\def\OPTprefacecols{2} % Number of columns when listing people in Preface + +% GETTING RID OF THE WIDOW ON PAGE 2 IN LETTER FORMAT +\def\OPTwidow{} + +% FORMATTING OF TABLE 1 IN INTRODUCTION +\def\OPTsmalltable{\small} + +% FORMATTING OF TABLE 8.1 OF HOMOTOPY GROUPS OF SPHERES +\newcommand{\OPTspherescolwidth}{20pt} + +% FORMATTING THE BIBLIOGRAPHY +\newcommand{\OPTbibliographyfont}{\small} + +% FORMATTING OF INDEX +\newcommand{\OPTindexfont}{\footnotesize} % size of font in the index +\newcommand{\OPTindexcolumnsep}{15.0pt} % column separation in index (default is 10.0pt) \ No newline at end of file diff --git a/src/ctfp-print.tex b/src/ctfp-print.tex new file mode 100644 index 0000000..18df95f --- /dev/null +++ b/src/ctfp-print.tex @@ -0,0 +1,12 @@ +% !TEX root = ctfp-print.tex +% This is a main LaTeX file for generating the CTFP book +% for printing in US-trade format, suitable for binding. +% The links are black in this version. + +\input{opt-print-ustrade} + +\input{preamble} + +\hypersetup{hidelinks} + +\input{ctfp} \ No newline at end of file diff --git a/src/ctfp-reader.tex b/src/ctfp-reader.tex new file mode 100644 index 0000000..b60570d --- /dev/null +++ b/src/ctfp-reader.tex @@ -0,0 +1,10 @@ +% !TEX root = ctfp-reader.tex +% This is a main LaTeX file for generating the CTFP book +% for printing in US-trade format, suitable for binding. +% The links are black in this version. + +\input{opt-reader-10in} + +\input{preamble} + +\input{ctfp} \ No newline at end of file diff --git a/src/ctfp.tex b/src/ctfp.tex index b1b2c36..376ada8 100644 --- a/src/ctfp.tex +++ b/src/ctfp.tex @@ -1,16 +1,3 @@ -% ********************************************************** % -% Category Theory for Programmers by Bartosz Milewski % -% % -% Compiled by Igal Tabachnik % -% https://github.com/hmemcpy/milewski-ctfp-pdf % -% % -% This file is licensed under a Creative Commons % -% Attribution-ShareAlike 4.0 International License % -% (http://creativecommons.org/licenses/by-sa/4.0/). % -% ********************************************************** % - -\input{preamble} - \includepdf[scale=0.92]{coverpage.pdf} \input{copyright} \frontmatter @@ -20,7 +7,6 @@ \chapter*{Preface} \addcontentsline{toc}{chapter}{Preface} \label{Preface} - \subfile{content/0.0/Preface} \mainmatter diff --git a/src/opt-print-ustrade.tex b/src/opt-print-ustrade.tex new file mode 100644 index 0000000..8daaf79 --- /dev/null +++ b/src/opt-print-ustrade.tex @@ -0,0 +1,15 @@ +% !TEX root = ctfp-print.tex + +\def\OPTmodes{twoside,openright} + +% PAGE FORMAT +% +% These settings are for letter format +\def\OPTpagesize{6in,9in} % Page size +\def\OPTtopmargin{0.75in} % Margin at the top of the page +\def\OPTbottommargin{0.75in} % Margin at the bottom of the page +\def\OPTinnermargin{0.72in} % Margin on the inner side of the page +\def\OPToutermargin{0.72in} % Margin on the outer side of the page +\def\OPTbindingoffset{0.35in} % Extra offset on the inner side +\def\OPTtextwidth{4.4in} +\def\OPTtextheight{7.5in} \ No newline at end of file diff --git a/src/opt-reader-10in.tex b/src/opt-reader-10in.tex new file mode 100644 index 0000000..c7e6eaf --- /dev/null +++ b/src/opt-reader-10in.tex @@ -0,0 +1,19 @@ +% !TEX root = ctfp.tex + +% Options for reading on 10" tables (e.g. Kindle DX) + +\def\OPTmodes{oneside,openany} + +% PAGE FORMAT +% +% Page geometry for 10-inch tablets +\def\OPTpagesize{148mm,197mm} % Page size +\def\OPTtopmargin{21mm} % Margin at the top of the page +\def\OPTbottommargin{28mm} % Margin at the bottom of the page +\def\OPTinnermargin{18.5mm} % Margin on the inner side of the page +\def\OPToutermargin{18.5mm} % Margin on the outer side of the page +\def\OPTbindingoffset{0mm} % Extra offset on the inner side +\def\OPTtextwidth{111mm} +\def\OPTtextheight{148mm} + +\def\OPThidelinks{false} \ No newline at end of file diff --git a/src/preamble.tex b/src/preamble.tex index 65440a1..7b1de48 100644 --- a/src/preamble.tex +++ b/src/preamble.tex @@ -1,8 +1,16 @@ -% !TEX TS-program = xelatex -% !TEX encoding = UTF-8 Unicode % !TEX root = ctfp.tex -\documentclass[11pt,twoside]{book} +\documentclass[11pt,\OPTmodes]{book} + +\usepackage[papersize={\OPTpagesize}, + top=\OPTtopmargin, + bottom=\OPTbottommargin, + inner=\OPTinnermargin, + outer=\OPToutermargin, + textwidth=\OPTtextwidth, + textheight=\OPTtextheight, + bindingoffset=\OPTbindingoffset + ]{geometry} % New line height: 1.05 * 1.2 = 1.26 \renewcommand{\baselinestretch}{1.05} @@ -67,14 +75,6 @@ \pagestyle{plain} \usepackage[final]{pdfpages} % inserts pages from a pdf file -% Page geometry for 10-inch tablets: -\usepackage[papersize={148mm,197mm}, - top=21mm, - textwidth=111mm, % increase one or both of these by 1mm or so to - textheight=148mm, % make the source compile with TeX Live 2013 - hcentering, % if you get "Too many unprocessed floats" error -]{geometry} - \usepackage{titlesec} % to change the appearance of section titles \usepackage{listings} % for syntax highlighted code listings \usepackage{verbatim} % for simple verbatim and comment environments diff --git a/src/version.tex b/src/version.tex deleted file mode 100644 index 9f7204d..0000000 --- a/src/version.tex +++ /dev/null @@ -1 +0,0 @@ -\newcommand{\OPTVersion}{0.0.0.0 - DO NOT USE} \ No newline at end of file