📚 The CoCalc Library - books, templates and other resources
License: OTHER
\usepackage{geometry}
\geometry{
width=5.5in,
height=8.5in,
hmarginratio=3:2,
vmarginratio=1:1,
includehead=true,
headheight=15pt
}
% paragraph spacing
\setlength{\parindent}{0pt} % 17.62482pt
\setlength{\parskip}{12pt plus 4pt minus 4pt} % 0.0pt plus 1.0pt
\linespread{1.05}
\def\arraystretch{1.5}
% list spacing
\setlength{\topsep}{5pt plus 2pt minus 3pt} % 10.0pt plus 4.0pt minus 6.0pt
\setlength{\partopsep}{-6pt plus 2pt minus 2pt} % 3.0pt plus 2.0pt minus 2.0pt
\setlength{\itemsep}{0pt} % 5.0pt plus 2.5pt minus 1.0pt
% these are copied from tex/latex/base/book.cls
% all I changed is afterskip
\makeatletter
\renewcommand{\section}{\@startsection{section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{0.7ex \@plus.2ex}%
{\normalfont\Large\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{0.3ex \@plus .2ex}%
{\normalfont\large\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{0.3ex \@plus .2ex}%
{\normalfont\normalsize\bfseries}}
\makeatother
% table of contents vertical spacing
\usepackage{tocloft}
\setlength\cftparskip{8pt plus 4pt minus 4pt}
% balanced index with TOC entry
\usepackage[totoc]{idxlayout}
% The following line adds a little extra space to the column
% in which the Section numbers appear in the table of contents
\makeatletter
\renewcommand{\l@section}{\@dottedtocline{1}{1.5em}{3.0em}}
\makeatother
% customize page headers
\usepackage{fancyhdr}
\pagestyle{fancyplain}
\renewcommand{\chaptermark}[1]{\markboth{Chapter \thechapter ~~ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection ~~ #1}}
\lhead[\fancyplain{}{\bfseries\thepage}]%
{\fancyplain{}{\bfseries\rightmark}}
\rhead[\fancyplain{}{\bfseries\leftmark}]%
{\fancyplain{}{\bfseries\thepage}}
\cfoot{}
%\rfoot{\textcolor{gray}{\tiny ThinkJava Draft \today}}
%% tweak spacing of figures and captions
%\usepackage{floatrow}
%\usepackage{caption}
%\captionsetup{
% font=small,
% labelformat=empty,
% justification=centering,
% skip=4pt
%}
% colors for code listings and output
\usepackage{xcolor}
\definecolor{bgcolor}{HTML}{FAFAFA}
\definecolor{comment}{HTML}{007C00}
\definecolor{keyword}{HTML}{0000FF}
\definecolor{strings}{HTML}{B20000}
% syntax highlighting in code listings
\usepackage{textcomp}
\usepackage{listings}
\lstset{
language=python,
basicstyle=\ttfamily,
backgroundcolor=\color{bgcolor},
commentstyle=\color{comment},
keywordstyle=\color{keyword},
stringstyle=\color{strings},
columns=fullflexible,
emph={label}, % keyword?
keepspaces=true,
showstringspaces=false,
upquote=true,
xleftmargin=15pt, % \parindent
framexleftmargin=3pt,
aboveskip=\parskip,
belowskip=\parskip
}
% code listing environments
\lstnewenvironment{code}
{\minipage{\linewidth}}
{\endminipage}
\lstnewenvironment{stdout}
{\lstset{commentstyle=,keywordstyle=,stringstyle=}\minipage{\linewidth}}
{\endminipage}
% inline syntax formatting
\newcommand{\py}[1]{\lstinline{#1}}%{
% prevent hyphens in names
\hyphenation{GitHub}
% pdf hyperlinks, table of contents, and document properties
\usepackage{hyperref}
\hypersetup{%
pdftitle={\thetitle: \thesubtitle},
pdfauthor={\theauthors},
pdfsubject={Version \theversion},
pdfkeywords={},
bookmarksopen=false,
colorlinks=true,
citecolor=black,
filecolor=black,
linkcolor=black,
urlcolor=blue
}