| \documentclass[10pt,letterpaper]{pfbook} % book class customized for perfbook |
| % For arxiv.org, must be on or before line 5: |
| \pdfoutput=1 |
| |
| % To accomodate change in Ghostscript 9.26 (default output: PDF 1.7) |
| \pdfminorversion=7 |
| |
| % Suppress warning emitted when multiple figures drawn by inkscape appear |
| % within a page. See: https://tex.stackexchange.com/questions/183149/ |
| \ifdefined\pdfsuppresswarningpagegroup \pdfsuppresswarningpagegroup=1 \fi |
| |
| % standard packages |
| |
| % A more pleasant font |
| \usepackage[full]{textcomp} % use symbols in TS1 encoding |
| \usepackage{lmodern} |
| \usepackage[scale=0.9]{tgheros} |
| \usepackage[T1]{fontenc} % use postscript type 1 fonts |
| \usepackage[table,svgnames]{xcolor} % newtxtext v1.73 loads xcolor without options |
| \usepackage[defaultsups,helvratio=0.9]{newtxtext} % use nice, standard fonts for roman |
| |
| % Improves the text layout |
| \usepackage{microtype} |
| \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts |
| \usepackage{etoolbox} |
| |
| %\usepackage{fixltx2e} % for \textsubscript, nop since Tex Live 2015 |
| \usepackage{float} |
| \floatstyle{ruled} |
| \newfloat{listing}{tbp}{lst}[chapter] |
| \floatname{listing}{Listing} |
| \usepackage{lscape} |
| \usepackage{epsfig} |
| \usepackage{subfig} |
| \newsubfloat{listing} |
| \captionsetup{labelfont=bf} |
| \captionsetup[listing]{font=small,labelsep=colon} |
| \captionsetup[subfloat]{font=small} |
| % \usepackage{breakurl} |
| \usepackage{graphicx} |
| \usepackage{rotating} |
| \usepackage{setspace} |
| \usepackage[shortlabels,inline]{enumitem} |
| \setlist[description]{style=unboxed} |
| \newlist{sequence}{enumerate}{10} |
| \setlist[sequence]{label*=\arabic*} |
| %\usepackage{enumerate} |
| \usepackage{ifthen} |
| \usepackage[shortcuts]{extdash} |
| \usepackage{changepage} |
| \usepackage{listings} |
| \lstset{basicstyle=\ttfamily} |
| % \usepackage[strings]{underscore} |
| % \usepackage{underscore} |
| \usepackage{pifont} % symbols for qqz reference points and carriagereturn |
| \usepackage{gensymb} % symbols for both text and math modes such as \degree and \micro |
| \usepackage{verbatimbox}[2014/01/30] % for centering verbatim listing in figure environment |
| \usepackage{amsmath} % lineno v5.0 (loaded via fvextra) needs amsmath in front |
| \usepackage{fancyvrb} |
| \usepackage{fvextra}[2016/09/02] |
| \usepackage[bottom]{footmisc} % place footnotes under floating figures/tables |
| \usepackage{tabularx} |
| \usepackage[hyphens]{url} |
| \usepackage{threeparttable} |
| \usepackage{titlesec}[2016/03/21] % Suppress number in paragraph heading |
| \usepackage{fmtcount} |
| \usepackage{draftwatermark}[2015/02/19] |
| \SetWatermarkAngle{0.0} |
| \SetWatermarkFontSize{8pt} |
| \SetWatermarkScale{1.0} |
| \SetWatermarkLightness{.6} |
| \SetWatermarkHorCenter{.85\paperwidth} |
| \SetWatermarkVerCenter{.95\paperheight} |
| \SetWatermarkText{\texttt{\commitid}} |
| \usepackage[breakable,skins]{tcolorbox} |
| \usepackage[split,makeindex]{splitidx} |
| \usepackage[nottoc]{tocbibind} |
| \usepackage[columns=3,totoc,indentunit=12pt,justific=raggedright,font=small,columnsep=.15in]{idxlayout} |
| \usepackage{parnotes} % for footnotes in tabularx |
| \usepackage[bookmarks=true,bookmarksnumbered=true,pdfborder={0 0 0},linktoc=all,pdfusetitle]{hyperref} |
| \usepackage{footnotebackref} % to enable cross-ref of footnote |
| \usepackage[all]{hypcap} % for going to the top of figure and table |
| \usepackage{mfirstuc}[=v2.07] % v2.08 or later is not compatible with our |
| % indexing macros |
| % rollback glossaries related packages as well |
| \usepackage[toc,nopostdot,acronym]{glossaries}[=v4.49] |
| \usepackage{glossaries-extra}[=v1.48] |
| \usepackage[longragged]{glossaries-extra-stylemods}[=v1.48] |
| |
| \usepackage{epigraph}[2020/01/02] % latest version prevents orphaned epigraph |
| \setlength{\epigraphwidth}{2.6in} |
| \usepackage[xspace]{ellipsis} |
| \usepackage{braket} % for \ket{} macro in QC section |
| \usepackage{siunitx} % for \num{} macro |
| \sisetup{group-minimum-digits=4,group-separator={,},group-digits=integer} |
| \usepackage{multirow} |
| \usepackage{noindentafter} |
| \NoIndentAfterCmd{\epigraph} |
| \usepackage[all]{nowidow} |
| \titleformat{\paragraph}[runin]{\normalfont\normalsize\bfseries}{}{0pt}{} |
| |
| % custom packages |
| \newboolean{qqzbg} |
| \setboolean{qqzbg}{true} % overriden by target specific setting |
| \newcommand{\IfQqzBg}[2]{\ifthenelse{\boolean{qqzbg}}{#1}{#2}} |
| \newboolean{noqqz} |
| \setboolean{noqqz}{false} |
| \newcommand{\IfNoQqz}[2]{\ifthenelse{\boolean{noqqz}}{#1}{#2}} |
| |
| \input{autodate} % need to input here to reflect tag state |
| \usepackage{qqz} |
| \usepackage{origpub} |
| |
| % custom booleans |
| |
| \newboolean{inbook} |
| \setboolean{inbook}{true} |
| \newcommand{\IfInBook}[2]{\ifthenelse{\boolean{inbook}}{#1}{#2}} |
| \newboolean{twocolumn} |
| \setboolean{twocolumn}{true} |
| \newcommand{\IfTwoColumn}[2]{\ifthenelse{\boolean{twocolumn}}{#1}{#2}} |
| \newboolean{hardcover} |
| \setboolean{hardcover}{false} |
| \newcommand{\IfHardCover}[2]{\ifthenelse{\boolean{hardcover}}{#1}{#2}} |
| \newboolean{ebooksize} |
| \setboolean{ebooksize}{false} |
| \newcommand{\IfEbookSize}[2]{\ifthenelse{\boolean{ebooksize}}% |
| {\ignorespaces#1\ignorespaces}{\ignorespaces#2\ignorespaces}} |
| \newboolean{afourpaper} |
| \setboolean{afourpaper}{false} |
| \newcommand{\IfAfourPaper}[2]{\ifthenelse{\boolean{afourpaper}}{#1}{#2}} |
| \newboolean{sansserif} |
| \setboolean{sansserif}{false} |
| \newcommand{\IfSansSerif}[2]{\ifthenelse{\boolean{sansserif}}% |
| {\ignorespaces#1\ignorespaces}{\ignorespaces#2\ignorespaces}} |
| \newboolean{lmttforcode} |
| \setboolean{lmttforcode}{true} |
| \newcommand{\IfLmttForCode}[2]{\ifthenelse{\boolean{lmttforcode}}{#1}{#2}} |
| \newboolean{tblcptop} |
| \setboolean{tblcptop}{true} |
| \newcommand{\IfTblCpTop}[2]{\ifthenelse{\boolean{tblcptop}}{#1}{#2}} |
| \newboolean{nimbusavail} |
| \setboolean{nimbusavail}{false} |
| \newcommand{\IfNimbusAvail}[2]{\ifthenelse{\boolean{nimbusavail}}{#1}{#2}} |
| \newboolean{colorlinks} |
| \setboolean{colorlinks}{false} |
| \newcommand{\IfColorLinks}[2]{\ifthenelse{\boolean{colorlinks}}{#1}{#2}} |
| \newboolean{toarxiv} |
| \setboolean{toarxiv}{false} |
| \newcommand{\IfToArxiv}[2]{\ifthenelse{\boolean{toarxiv}}{#1}{#2}} |
| \newboolean{indexon} |
| \setboolean{indexon}{true} |
| \newcommand{\IfIndexOn}[2]{\ifthenelse{\boolean{indexon}}{#1}{#2}} |
| \newboolean{indexhl} |
| \setboolean{indexhl}{false} |
| \newcommand{\IfIndexHl}[2]{\ifthenelse{\boolean{indexhl}}{#1}{#2}} |
| \newboolean{indexhier} |
| \setboolean{indexhier}{true} |
| \newcommand{\IfIndexHier}[2]{\ifthenelse{\boolean{indexhier}}{#1}{#2}} |
| |
| % Tweak width params of TOC |
| \makeatletter |
| \IfEbookSize{ % for ebook size build (more than 1000 pages) |
| \renewcommand*\@pnumwidth{2.2em} |
| }{} |
| % default params defined in book.sty: |
| % width of chapter (two digits): 1.5em |
| % indent of section: 1.5em |
| % width of section (three digits + one periods): 2.3em |
| % indent of subsection: 3.8em |
| % width of subsection (four digits + two periods): 3.2em |
| \IfSansSerif{ % sans serif (Helvetica clone) |
| % to cover section "E.10" and subsection "15.5.10", |
| % width of section: 2.4em |
| % width of subsection: 3.7em |
| \renewcommand*\l@section{\@dottedtocline{1}{1.5em}{2.4em}} |
| \renewcommand*\l@subsection{\@dottedtocline{2}{3.9em}{3.7em}} |
| }{ % serif (Times Roman clone) |
| % to cover subsection "15.5.10", |
| % width of subsection: 3.4em |
| \renewcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.4em}} |
| } |
| \makeatother |
| |
| \IfEbookSize{ |
| \usepackage[section]{placeins} |
| }{ |
| \usepackage{placeins} |
| } |
| % Custom commands for index |
| \newindex[API Index]{api} % index for API |
| \newindex[People Name Index]{ppl} % index for People Name |
| \newcommand{\categapi}[1]{~{\scriptsize (#1)}} |
| \IfIndexHl{ |
| \newcommand{\hlindex}[1]{\textcolor{DarkGreen}{#1}} |
| }{ |
| \newcommand{\hlindex}[1]{#1} |
| } |
| % For consistent index entries of capitalization of "Index entry" |
| \newcommand{\ucindex}[1]{% |
| \lowercase{\def\temp{#1}}% |
| \expandafter\index\expandafter{\temp@\makefirstuc{\temp}}% |
| } |
| \newcommand{\ucindexh}[2]{% |
| \lowercase{\def\temp{#1}}% |
| \lowercase{\def\tempb{#2}}% |
| \expandafter\index\expandafter{\temp@\makefirstuc{\temp}!\tempb}% |
| } |
| \newcommand{\ucindexhm}[2]{% |
| \lowercase{\def\temp{#1}}% |
| \expandafter\index\expandafter{\temp@\makefirstuc{\temp}!#2}% |
| } |
| \newcommand{\indexhraw}[2]{% |
| \expandafter\index\expandafter{#1!#2}% |
| } |
| \IfIndexHier{ |
| \newcommand{\indexh}[3]{\ucindexh{#2}{#3}} |
| \newcommand{\indexhr}[3]{\indexhraw{#2}{#3}} |
| \newcommand{\indexhmr}[3]{\ucindexhm{#2}{#3}} |
| }{ |
| \newcommand{\indexh}[3]{\ucindex{#3 #2}} |
| \newcommand{\indexhr}[3]{\index{#1}} |
| \newcommand{\indexhmr}[3]{\index{#1}} |
| } |
| |
| \newcommand{\IX}[1]{\ucindex{#1}\hlindex{#1}} % put with first letter capitalized into general index |
| \newcommand{\IXr}[1]{\index{#1}\hlindex{#1}} % put as is into general index |
| \newcommand{\IXpl}[1]{\ucindex{#1}\hlindex{#1s}} % put with first letter capitalized into general index for plural |
| \newcommand{\IXplr}[1]{\index{#1}\hlindex{#1s}} % put as is into general index for plural |
| \newcommand{\IXplx}[2]{\ucindex{#1}\hlindex{#1#2}} % put as is into general index for plural of exeptional form |
| \newcommand{\IXalt}[2]{\ucindex{#2}\hlindex{#1}} % put alternative with first letter capitalized into general index |
| \newcommand{\IXaltr}[2]{\index{#2}\hlindex{#1}} % put alternative as is into general index |
| \newcommand{\IXh}[2]{\indexh{#1 #2}{#2}{#1}\hlindex{#1 #2}} |
| \newcommand{\IXhpl}[2]{\indexh{#1 #2}{#2}{#1}\hlindex{#1 #2s}} |
| \newcommand{\IXhr}[2]{\indexhr{#1 #2}{#2}{#1}\hlindex{#1 #2}} |
| \newcommand{\IXhrpl}[2]{\indexhr{#1 #2}{#2}{#1}\hlindex{#1 #2s}} |
| \newcommand{\IXhmr}[2]{\indexhmr{#1 #2}{#2}{#1}\hlindex{#1 #2}} |
| \newcommand{\IXhmrpl}[2]{\indexhmr{#1 #2}{#2}{#1}\hlindex{#1 #2s}} |
| \newcommand{\IXalth}[3]{\indexh{#1}{#3}{#2}\hlindex{#1}} |
| \newcommand{\IXalthr}[3]{\indexhr{#1}{#3}{#2}\hlindex{#1}} |
| \newcommand{\IXalthmr}[3]{\indexhmr{#1}{#3}{#2}\hlindex{#1}} |
| % page number in bold face |
| \newcommand{\BF}[1]{\textbf{#1}} |
| \newcommand{\IXB}[1]{\ucindex{#1|BF}\hlindex{#1}} % put with first letter capitalized into general index |
| \newcommand{\IXBr}[1]{\index{#1|BF}\hlindex{#1}} % put as is into general index |
| \newcommand{\IXBpl}[1]{\ucindex{#1|BF}\hlindex{#1s}} % put with first letter capitalized into general index for plural |
| \newcommand{\IXBplr}[1]{\index{#1|BF}\hlindex{#1s}} % put as is into general index for plural |
| \newcommand{\IXBplx}[2]{\ucindex{#1|BF}\hlindex{#1#2}} % put as is into general index for plural of exeptional form |
| \newcommand{\IXBalt}[2]{\ucindex{#2|BF}\hlindex{#1}} % put alternative with first letter capitalized into general index |
| \newcommand{\IXBaltr}[2]{\index{#2|BF}\hlindex{#1}} % put alternative as is into general index |
| \newcommand{\IXBh}[2]{\indexh{#1 #2|BF}{#2|BF}{#1}\hlindex{#1 #2}} |
| \newcommand{\IXBhpl}[2]{\indexh{#1 #2|BF}{#2|BF}{#1}\hlindex{#1 #2s}} |
| \newcommand{\IXBhr}[2]{\indexhr{#1 #2|BF}{#2|BF}{#1}\hlindex{#1 #2}} |
| \newcommand{\IXBhrpl}[2]{\indexhr{#1 #2|BF}{#2|BF}{#1}\hlindex{#1 #2s}} |
| \newcommand{\IXBhmr}[2]{\indexhmr{#1 #2|BF}{#2|BF}{#1}\hlindex{#1 #2}} |
| \newcommand{\IXBhmrpl}[2]{\indexhmr{#1 #2|BF}{#2|BF}{#1}\hlindex{#1 #2s}} |
| \newcommand{\IXBalth}[3]{\indexh{#1|BF}{#3|BF}{#2}\hlindex{#1}} |
| \newcommand{\IXBalthr}[3]{\indexhr{#1|BF}{#3|BF}{#2}\hlindex{#1}} |
| \newcommand{\IXBalthmr}[3]{\indexhmr{#1|BF}{#3|BF}{#2}\hlindex{#1}} |
| % page number for Glossary items or the likes |
| \newcommand{\GL}[1]{\underline{#1}} |
| \newcommand{\IXG}[1]{\ucindex{#1|GL}\hlindex{#1}} % put with first letter capitalized into general index |
| \newcommand{\IXGr}[1]{\index{#1|GL}\hlindex{#1}} % put as is into general index |
| \newcommand{\IXGpl}[1]{\ucindex{#1|GL}\hlindex{#1s}} % put with first letter capitalized into general index for plural |
| \newcommand{\IXGplr}[1]{\index{#1|GL}\hlindex{#1s}} % put as is into general index for plural |
| \newcommand{\IXGplx}[2]{\ucindex{#1|GL}\hlindex{#1#2}} % put as is into general index for plural of exeptional form |
| \newcommand{\IXGalt}[2]{\ucindex{#2|GL}\hlindex{#1}} % put alternative with first letter capitalized into general index |
| \newcommand{\IXGaltr}[2]{\index{#2|GL}\hlindex{#1}} % put alternative as is into general index |
| \newcommand{\IXGh}[2]{\indexh{#1 #2|GL}{#2|GL}{#1}\hlindex{#1 #2}} |
| \newcommand{\IXGhpl}[2]{\indexh{#1 #2|GL}{#2|GL}{#1}\hlindex{#1 #2s}} |
| \newcommand{\IXGhr}[2]{\indexhr{#1 #2|GL}{#2|GL}{#1}\hlindex{#1 #2}} |
| \newcommand{\IXGhrpl}[2]{\indexhr{#1 #2|GL}{#2|GL}{#1}\hlindex{#1 #2s}} |
| \newcommand{\IXGhmr}[2]{\indexhmr{#1 #2|GL}{#2|GL}{#1}\hlindex{#1 #2}} |
| \newcommand{\IXGhmrpl}[2]{\indexhmr{#1 #2|GL}{#2|GL}{#1}\hlindex{#1 #2s}} |
| \newcommand{\IXGalth}[3]{\indexh{#1|GL}{#3|GL}{#2}\hlindex{#1}} |
| \newcommand{\IXGalthr}[3]{\indexhr{#1|GL}{#3|GL}{#2}\hlindex{#1}} |
| \newcommand{\IXGalthmr}[3]{\indexhmr{#1|GL}{#3|GL}{#2}\hlindex{#1}} |
| % |
| \newcommand{\apic}[1]{\hlindex{\co{#1}}\sindex[api]{#1@\co{#1}\categapi{c}}} |
| \newcommand{\apig}[1]{\hlindex{\co{#1}}\sindex[api]{#1@\co{#1}\categapi{g}}} |
| \newcommand{\apipx}[1]{\hlindex{\co{#1}}\sindex[api]{#1@\co{#1}\categapi{px}}} |
| \newcommand{\apik}[1]{\hlindex{\co{#1}}\sindex[api]{#1@\co{#1}\categapi{k}}} |
| \newcommand{\apikh}[1]{\hlindex{\co{#1}}\sindex[api]{#1@\co{#1}\categapi{kh}}} |
| \newcommand{\apipf}[1]{\hlindex{\co{#1}}\sindex[api]{#1@\co{#1}\categapi{pf}}} |
| \newcommand{\apiur}[1]{\hlindex{\co{#1}}\sindex[api]{#1@\co{#1}\categapi{ur}}} |
| \newcommand{\api}[1]{\hlindex{\co{#1}}\sindex[api]{#1@\co{#1}}} |
| \newcommand{\apialtc}[2]{\hlindex{\co{#1}}\sindex[api]{#2@\co{#2}\categapi{c}}} |
| \newcommand{\apialtg}[2]{\hlindex{\co{#1}}\sindex[api]{#2@\co{#2}\categapi{g}}} |
| \newcommand{\apialtk}[2]{\hlindex{\co{#1}}\sindex[api]{#2@\co{#2}\categapi{k}}} |
| \newcommand{\ppl}[2]{\hlindex{#1 #2}\index{#2, #1}} % forename surname in text, "surname, forename" into ppl index |
| \newcommand{\pplmdl}[2]{\hlindex{#1~#2}\index{#2, #1}} % for abbreviated middle name |
| \newcommand{\pplsur}[2]{\hlindex{#2}\index{#2, #1}} % surname in text, "surname, givenname" into ppl index |
| \newcommand{\pplalt}[2]{\hlindex{#1}\index{#2}} % put 1st arg in text, put 2nd arg into ppl index |
| |
| \IfTwoColumn{}{ |
| \setboolean{colorlinks}{true} |
| \IfEbookSize{}{ |
| \renewcommand\footnotelayout{% |
| \advance\leftskip 0.0in |
| \advance\rightskip 0.7in |
| } |
| }} |
| |
| \IfColorLinks{ |
| \hypersetup{colorlinks=true,allcolors=MediumBlue} |
| }{} |
| |
| \IfToArxiv{ |
| \hypersetup{ |
| colorlinks=true, |
| linkcolor=black, |
| citecolor=black, |
| filecolor=black, |
| urlcolor=black, |
| } |
| }{} |
| |
| \IfNimbusAvail{ |
| \usepackage{nimbusmononarrow} |
| }{} |
| \renewcommand*\ttdefault{lmtt} |
| %msfontstub |
| |
| \IfEbookSize{ |
| \newcommand{\OneColumnHSpace}[1]{} |
| }{ |
| \newcommand{\OneColumnHSpace}[1]{\IfTwoColumn{}{\hspace*{#1}}} |
| } |
| |
| \IfSansSerif{ |
| \renewcommand{\familydefault}{\sfdefault} |
| \normalfont |
| \usepackage[slantedGreek,scaled=.96]{newtxsf} |
| % Silence inevitable warnings on missing slanted shape |
| \RequirePackage[save]{silence} |
| \WarningFilter[sansslant]{latexfont}{Font shape `T1/qhv/m/sl'} |
| \ActivateWarningFilters[sansslant] |
| }{ |
| \usepackage[slantedGreek]{newtxmath} % math package to be used with newtxtext |
| % Poor person's slanted shape for roman --- newtxtext lacks slanted shape |
| \AtBeginDocument{% |
| \DeclareFontShape{\encodingdefault}{\rmdefault}{m}{sl}{<-> ptmro7t}{}% |
| \DeclareFontShape{\encodingdefault}{\rmdefault}{b}{sl}{<-> ptmbo7t}{}% |
| \DeclareFontShape{\encodingdefault}{\rmdefault}{bx}{sl}{<->ssub * ptm/b/sl}{}% |
| } |
| } |
| \usepackage{biolinum} |
| % restore \sfdefault of newtxtext |
| \renewcommand{\sfdefault}{qhv} |
| |
| \newcommand{\LstLineNo}{\makebox[5ex][r]{\arabic{VerbboxLineNo}\hspace{2ex}}} |
| |
| \usepackage{bm} % for bold math mode fonts --- should be after math mode font choice |
| \usepackage{booktabs} |
| \usepackage{arydshln} |
| \definecolor{lightgray}{gray}{0.9} % for coloring alternate rows in table |
| |
| \fvset{fontsize=\scriptsize,obeytabs=true} |
| \IfTwoColumn{ |
| \fvset{tabsize=2} |
| }{ |
| \fvset{tabsize=8} |
| } |
| \DefineVerbatimEnvironment{VerbatimL}{Verbatim}% |
| {numbers=left,numbersep=5pt,xleftmargin=9pt} |
| \AfterEndEnvironment{VerbatimL}{\vspace*{-9pt}} |
| \DefineVerbatimEnvironment{VerbatimLL}{Verbatim}% for snippet inside list |
| {numbers=left,numbersep=5pt,xleftmargin=9pt} |
| \AfterEndEnvironment{VerbatimLL}{\vspace*{-5pt}} |
| \DefineVerbatimEnvironment{VerbatimN}{Verbatim}% |
| {numbers=left,numbersep=3pt,xleftmargin=5pt,xrightmargin=5pt,frame=single} |
| \DefineVerbatimEnvironment{VerbatimU}{Verbatim}% |
| {numbers=none,xleftmargin=5pt,xrightmargin=5pt,samepage=true,frame=single} |
| |
| \IfLmttForCode{ |
| \AtBeginEnvironment{verbatim}{\renewcommand{\ttdefault}{lmtt}} |
| \AtBeginEnvironment{verbbox}{\renewcommand{\ttdefault}{lmtt}} |
| \AtBeginEnvironment{table}{\renewcommand{\ttdefault}{lmtt}} |
| \AtBeginEnvironment{table*}{\renewcommand{\ttdefault}{lmtt}} |
| \AtBeginEnvironment{sidewaystable*}{\renewcommand{\ttdefault}{lmtt}} |
| \AtBeginEnvironment{minipage}{\renewcommand{\ttdefault}{lmtt}} |
| \AtBeginEnvironment{listing}{\renewcommand{\ttdefault}{lmtt}} |
| \AtBeginEnvironment{listing*}{\renewcommand{\ttdefault}{lmtt}} |
| \fvset{fontfamily=lmtt} |
| }{} |
| |
| \IfTblCpTop{ |
| \floatstyle{plaintop} |
| \restylefloat{table} |
| \addtolength{\abovecaptionskip}{-2.5pt} |
| \setlength{\abovetopsep}{-2pt} |
| }{} |
| \captionsetup{hangindent=20pt} |
| \captionsetup[listing]{hangindent=20pt} |
| |
| \usepackage[capitalise,noabbrev,nosort]{cleveref} |
| \crefname{subsubsubappendix}{Appendix}{Appendices} |
| \crefname{sublisting}{Listing}{Listings} |
| \crefname{sequencei}{step}{steps} |
| \Crefname{sequencei}{Step}{Steps} |
| \crefname{enumi}{item}{items} |
| \Crefname{enumi}{Item}{Items} |
| \crefname{page}{page}{pages} |
| \Crefname{page}{Page}{Pages} |
| \Crefformat{equation}{Equation~#2#1#3} |
| \crefformat{equation}{Eq.~#2#1#3} |
| \newcommand{\crefrangeconjunction}{--} |
| \newcommand{\creflastconjunction}{, and~} |
| |
| % Define \crefthro{} for "Sections~m.n through~m.p" |
| \newcommand{\crefthro}[2]{% |
| \namecrefs{#1}~\ref{#1} through~\ref{#2}% |
| } |
| \newcommand{\Crefthro}[2]{% |
| \nameCrefs{#1}~\ref{#1} through~\ref{#2}% |
| } |
| |
| % Define \clnref{} and \Clnref{} for reference to line labels |
| \newcounter{lblcount} |
| \newcommand{\clnrefp}[2]{% |
| \setcounter{lblcount}{0}% Restart label count |
| \renewcommand*{\do}[1]{\stepcounter{lblcount}}% Count label |
| \docsvlist{#1}% Process list and count labels |
| \def\nextitem{\def\nextitem{, }}% Separator |
| \ifnum\value{lblcount}=1 #2~\lnref{#1}% |
| \else\ifnum\value{lblcount}=2 {#2}s~% |
| \renewcommand*{\do}[1]{% |
| \addtocounter{lblcount}{-1}% |
| \ifnum\value{lblcount}=0 { }and~\else\nextitem\fi\lnref{##1}}% How to process each label |
| \else {#2}s~% |
| \renewcommand*{\do}[1]{% |
| \addtocounter{lblcount}{-1}% |
| \ifnum\value{lblcount}=0 , and~\else\nextitem\fi\lnref{##1}}% How to process each label |
| \fi% |
| \docsvlist{#1}% Process list |
| \fi% |
| } |
| \newcommand{\clnrefpraw}[2]{% |
| \setcounter{lblcount}{0}% Restart label count |
| \renewcommand*{\do}[1]{\stepcounter{lblcount}}% Count label |
| \docsvlist{#1}% Process list and count labels |
| \def\nextitem{\def\nextitem{, }}% Separator |
| \ifnum\value{lblcount}=1 #2~\lnrefraw{#1}% |
| \else\ifnum\value{lblcount}=2 {#2}s~% |
| \renewcommand*{\do}[1]{% |
| \addtocounter{lblcount}{-1}% |
| \ifnum\value{lblcount}=0 { }and~\else\nextitem\fi\lnrefraw{##1}}% How to process each label |
| \else {#2}s~% |
| \renewcommand*{\do}[1]{% |
| \addtocounter{lblcount}{-1}% |
| \ifnum\value{lblcount}=0 , and~\else\nextitem\fi\lnrefraw{##1}}% How to process each label |
| \fi% |
| \docsvlist{#1}% Process list |
| \fi% |
| } |
| \newcommand{\clnref}[1]{\clnrefp{#1}{line}} |
| \newcommand{\Clnref}[1]{\clnrefp{#1}{Line}} |
| \newcommand{\clnrefr}[1]{\clnrefpraw{#1}{line}} |
| \newcommand{\Clnrefr}[1]{\clnrefpraw{#1}{Line}} |
| \newcommand{\clnrefrange}[2]{lines~\lnref{#1}\==\lnref{#2}} |
| \newcommand{\Clnrefrange}[2]{Lines~\lnref{#1}\==\lnref{#2}} |
| \newcommand{\clnrefthro}[2]{lines~\lnref{#1} through~\lnref{#2}} |
| \newcommand{\Clnrefthro}[2]{Lines~\lnref{#1} through~\lnref{#2}} |
| \newcommand{\pararef}[1]{Paragraph ``\nameref{#1}'' on Page~\pageref{#1}} |
| \newcommand{\Pararef}[1]{Paragraph ``\nameref{#1}'' on Page~\pageref{#1}} |
| |
| % geometry setting |
| \newlength{\twocolumnwidth} |
| \newlength{\onecolumntextwidth} |
| \setlength{\onecolumntextwidth}{4.75in} |
| \setlength{\twocolumnwidth}{3.125in} |
| \IfTwoColumn{ |
| \renewcommand\floatpagefraction{.75} |
| \IfHardCover{ |
| \usepackage[papersize={8.25in,10.75in},body={6.5in,8.25in},twocolumn,columnsep=0.25in]{geometry} |
| }{ |
| \IfAfourPaper{ |
| \usepackage[a4paper,body={6.5in,8.25in},twocolumn,columnsep=0.25in]{geometry} |
| }{ |
| \usepackage[letterpaper,body={6.5in,8.25in},twocolumn,columnsep=0.25in]{geometry} |
| }} |
| % Adjust indents/margins set in book.cls for twocolumn |
| \setlength{\parindent}{1em} |
| \setlength{\leftmargini}{2em} |
| \setlength{\leftmarginv}{.5em} |
| \setlength{\leftmarginvi}{.5em} |
| \sloppy % prefer wide inter-word spaces to occasional horizontal overfulls |
| }{ % One Column |
| \IfEbookSize { |
| % From https://tex.stackexchange.com/questions/16735/latex-options-for-kindle |
| \usepackage[papersize={4.5in,6.3in},margin=0.2in,footskip=0.2in, |
| headsep=0.0335in,headheight=0.1665in,onecolumn,twoside=false]{geometry} |
| \sloppy % prefer wide inter-word spaces to occasional horizontal overfulls |
| \setlength{\onecolumntextwidth}{4.1in} |
| \usepackage{fancyhdr} |
| \fancypagestyle{plain}{% |
| \fancyhf{} % clear all header and footer fields |
| \renewcommand{\headrulewidth}{0pt} |
| \rhead{\textcolor{Grey}{\scriptsize\thepage}} |
| } |
| \pagestyle{plain} |
| %\pagestyle{empty} |
| %\usepackage[scaled]{helvet} |
| %\renewcommand{\familydefault}{\sfdefault} |
| % Smaller font and tighter space for chapter title |
| \titleformat{\chapter}[display]{\normalfont\bfseries} |
| {\Large\chaptertitlename~\thechapter}{0pt}{\LARGE} |
| \titlespacing*{\chapter}{0pt}{*1}{*2} |
| }{ |
| \IfHardCover{ |
| \usepackage[papersize={8.25in,10.75in},body={4.75in,8.25in},onecolumn]{geometry} |
| }{ |
| \IfAfourPaper{ |
| \usepackage[a4paper,body={4.75in,8.25in},onecolumn]{geometry} |
| }{ |
| \usepackage[letterpaper,body={4.75in,8.25in},onecolumn]{geometry} |
| }}} |
| \geometry{hcentering=true} % horizontal centering for 1c layouts |
| } |
| \IfAfourPaper{ |
| \geometry{vcentering=true} % vertical centering for A4 paper |
| }{ |
| \geometry{vmarginratio=3:4} |
| } |
| |
| \setcounter{topnumber}{3} |
| \renewcommand\topfraction{.75} |
| \setcounter{bottomnumber}{2} |
| \renewcommand\bottomfraction{.3} |
| \setcounter{totalnumber}{5} |
| \renewcommand\textfraction{.15} |
| \renewcommand\floatpagefraction{.6} |
| \setcounter{dbltopnumber}{3} |
| \renewcommand\dbltopfraction{.75} |
| \renewcommand\dblfloatpagefraction{.5} |
| |
| \IfAfourPaper{ |
| \SetWatermarkVerCenter{.92\paperheight} |
| }{} |
| |
| \IfHardCover{ |
| \SetWatermarkVerCenter{.95\paperheight} |
| }{} |
| |
| \IfEbookSize{ |
| \SetWatermarkHorCenter{.8\paperwidth} |
| \SetWatermarkVerCenter{.99\paperheight} |
| \newsavebox\ebbox |
| \newcommand{\ebresizewidth}[1]{\resizebox{\textwidth}{!}{#1}} |
| \newcommand{\ebresizewidthsw}[1]{\resizebox{.95\textheight}{!}{#1}} |
| \newcommand{\ebresizeverb}[2]{% |
| \begin{lrbox}{\ebbox}% |
| \begin{minipage}{\textwidth}% |
| {#2}% |
| \end{minipage}% |
| \end{lrbox}% |
| \resizebox{#1\textwidth}{!}{\usebox{\ebbox}}% |
| } |
| \newcommand\ebFloatBarrier{\FloatBarrier} |
| }{ |
| \newcommand{\ebresizewidth}[1]{#1} |
| \newcommand{\ebresizewidthsw}[1]{#1} |
| \newcommand{\ebresizeverb}[2]{#2} |
| \newcommand\ebFloatBarrier{} |
| } |
| |
| \IfTwoColumn{ |
| \newcommand{\tcresizewidth}[1]{\resizebox{\columnwidth}{!}{#1}} |
| }{ |
| \newcommand{\tcresizewidth}[1]{#1} |
| } |
| |
| % Glossaries dictionary and custom settings |
| \input{glsdict} |
| |
| \begin{document} |
| |
| %%HTMLSKIP |
| \lstset{ |
| literate={\_}{}{0\discretionary{\_}{}{\_}}% |
| {\_\_}{}{0\discretionary{\_\_}{}{\_\_}}% |
| {->}{}{0\discretionary{->}{}{->}}% |
| } |
| %%HTMLNOSKIP |
| \newcommand{\co}[1]{\lstinline[breaklines=true,breakatwhitespace=true]{#1}} |
| \newcommand{\nbco}[1]{\hbox{\lstinline[breaklines=false,breakatwhitespace=false]{#1}}} % no break lines for short snippet |
| \newcommand{\qco}[1]{``\nbco{#1}''} % \nbco with quotation marks |
| \newcommand{\tco}[1]{\texttt{\detokenize{#1}}} % for code in tabular environment |
| % \tco{} will break at spaces but not at underscores |
| \newcommand{\qtco}[1]{``\hbox{\tco{#1}}''} % \tco with quotation marks |
| \newcommand{\lopt}[1]{\tco{-}\tco{-}\tco{#1}} % to avoid "--" to endash conversion |
| \newcommand{\nf}[1]{\textnormal{#1}} % to return to normal font |
| \newcommand{\qop}[1]{{\sffamily #1}} % QC operator such as H, T, S, etc. |
| |
| \DeclareRobustCommand{\euler}{\ensuremath{\mathrm{e}}} |
| \DeclareRobustCommand{\O}[1]{\ensuremath{\mathcal{O}\left(#1\right)}} |
| \DeclareRobustCommand{\Node}[1]{Node~{\ensuremath{#1}}} |
| \newcommand{\Power}[1]{POWER#1} |
| \newcommand{\ARM}[1]{Arm{#1}} |
| \newcommand{\ARMv}[1]{Armv{#1}} |
| \newcommand{\GNUC}{GNU~C} |
| \newcommand{\GCC}{GCC} |
| %\newcommand{\GCC}{\co{gcc}} % For those who prefer "gcc" |
| \newcommand{\IRQ}{IRQ} |
| %\newcommand{\IRQ}{irq} % For those who prefer "irq" |
| \newcommand{\rt}{\mbox{-rt}} % to prevent line break behind "-" |
| |
| \let\epigraphorig\epigraph |
| \renewcommand{\epigraph}[2]{\epigraphorig{\biolinum\emph{#1}}{\biolinum\scshape\footnotesize #2}} |
| \IfEbookSize{ |
| \newcommand{\Epigraph}[2]{\epigraph{#1}{#2}} |
| \raggedbottom |
| }{ |
| \newcommand{\Epigraph}[2]{\epigraphhead[65]{\epigraph{#1}{#2}}} |
| } |
| |
| \input{ushyphex} % Hyphenation exceptions for US English from hyphenex package |
| \input{pfhyphex} % Hyphenation exceptions for perfbook |
| |
| \title{ |
| Is Parallel Programming Hard, And, If So, \\ |
| What Can You Do About It?} |
| \author{ |
| Edited by: \\ |
| \\ |
| Paul E. McKenney \\ |
| Meta Platforms, Inc. \\ |
| \href{mailto:paulmck@kernel.org}{paulmck@kernel.org} \\ |
| } % end author |
| % \date{\ } |
| |
| \setcounter{secnumdepth}{4} % Enable counter for paragraph |
| %\fvset{fontsize=\scriptsize,numbers=left,numbersep=5pt,xleftmargin=9pt,obeytabs=true,tabsize=2} |
| \newcommand{\lnlblbase}{} |
| \newcommand{\lnlbl}[1]{\phantomsection\label{\lnlblbase:#1}} |
| \newlength{\lnlblraise} |
| \setlength{\lnlblraise}{6pt} |
| \AtBeginEnvironment{VerbatimN}{% |
| \renewcommand{\lnlbl}[1]{% |
| \raisebox{\lnlblraise}{\phantomsection\label{\lnlblbase:#1}}}% |
| } |
| \newcommand{\lnrefbase}{} |
| \newcommand{\lnref}[1]{\ref{\lnrefbase:#1}} |
| \newcommand{\lnrefraw}[1]{\ref{#1}} |
| |
| \newenvironment{fcvlabel}[1][]{\renewcommand{\lnlblbase}{#1}% |
| \ignorespaces}{\ignorespacesafterend} |
| \newenvironment{fcvref}[1][]{\renewcommand{\lnrefbase}{#1}% |
| \ignorespaces}{\ignorespacesafterend} |
| |
| \frontmatter |
| |
| \IfEbookSize{\hypersetup{pageanchor=false}}{} |
| \maketitle |
| \IfEbookSize{\hypersetup{pageanchor=true}}{} |
| |
| \IfTwoColumn{ |
| \onecolumn\begin{adjustwidth*}{.95in}{.8in} |
| \addtolength{\parindent}{6pt} |
| }{} |
| \input{legal} |
| \tableofcontents |
| \IfTwoColumn{ |
| \end{adjustwidth*}\twocolumn |
| }{} |
| |
| \mainmatter |
| |
| \input{howto/howto} |
| \input{intro/intro} |
| \input{cpu/cpu} |
| \input{toolsoftrade/toolsoftrade} |
| \input{count/count.tex} |
| \input{SMPdesign/SMPdesign} |
| \input{locking/locking.tex} |
| \input{owned/owned.tex} |
| \input{defer/defer.tex} |
| \input{datastruct/datastruct.tex} |
| \input{debugging/debugging} |
| \input{formal/formal} |
| \input{together/together.tex} |
| \input{advsync/advsync.tex} |
| \input{memorder/memorder.tex} |
| \input{easy/easy.tex} |
| \input{future/future.tex} |
| \input{summary.tex} |
| |
| \appendix |
| |
| \input{appendix/appendix.tex} |
| |
| \backmatter |
| |
| % Glossary |
| %% Reset footnote count |
| \setcounter{footnote}{0} |
| \input{glossary.tex} |
| |
| % Bibliograpy |
| \IfTwoColumn{ |
| \onecolumn\begin{adjustwidth*}{.8in}{.7in} |
| %\bibliographystyle{alpha} % Use genuine alpha style (In case of build failure, use this instead) |
| \bibliographystyle{alphapf} % Use alpha style customized by urlbst with --inlinelinks option |
| }{ |
| \bibliographystyle{alphapf} % Use alpha style customized by urlbst with --inlinelinks option |
| } |
| \IfColorLinks{}{ |
| \hypersetup{pdfborder=0 0 1,urlbordercolor=0.4 1 1} |
| } |
| \bibliography{bib/RCU,bib/WFS,bib/hw,bib/os,bib/parallelsys,bib/patterns,bib/perfmeas,bib/refs,bib/syncrefs,bib/search,bib/swtools,bib/realtime,bib/TM,bib/standards,bib/OSS,bib/maze,bib/energy,bib/QC,bib/NP,bib/memorymodel} |
| \IfColorLinks{}{ |
| \hypersetup{pdfborder=0 0 0} |
| } |
| \IfTwoColumn{ |
| \end{adjustwidth*}\twocolumn |
| }{ |
| } |
| |
| % Credits |
| \setcounter{secnumdepth}{-1} % surpress section numbering in backmatter |
| \input{ack} |
| |
| % Index if enabled |
| \IfIndexOn{ |
| \IfIndexHier{ |
| \input{indexsee} |
| }{} |
| \phantomsection |
| \IfEbookSize{ |
| \idxlayout{columns=2} |
| }{ |
| \newgeometry{body={6.5in,8.25in},centering=true,twocolumn,columnsep=0.25in} |
| } |
| \printglossary[type=\acronymtype] |
| \phantomsection |
| \setindexprenote{% |
| \hfill\begin{minipage}{1in} |
| \footnotesize% |
| \BF{Bold}: Major reference. |
| \GL{Underline}: Definition. |
| \vspace*{1ex} |
| \end{minipage} |
| } |
| \printindex |
| \phantomsection |
| \setindexprenote{% |
| \hfill\begin{minipage}{2.6in} |
| \footnotesize (c):~Cxx standard, (g):~GCC extension, |
| (k):~Linux kernel, (kh):~Linux kernel historic, (pf):~perfbook CodeSamples, |
| (px):~POSIX, (ur):~userspace RCU\@. |
| \vspace*{1ex} |
| \end{minipage} |
| } |
| \printindex[api] |
| \IfEbookSize{}{ |
| \restoregeometry |
| } |
| }{} |
| |
| % page-layout dimensions |
| % \cleardoublepage |
| % ~ \\ |
| % paperheight: \the\paperheight \\ |
| % paperwidth: \the\paperwidth \\ |
| % topmargin: \the\topmargin \\ |
| % headheight: \the\headheight \\ |
| % headsep: \the\headsep \\ |
| % textheight: \the\textheight \\ |
| % textwidth: \the\textwidth \\ |
| % oddsidemargin: \the\oddsidemargin \\ |
| % evensidemargin: \the\evensidemargin \\ |
| % footskip: \the\footskip \\ |
| % topskip: \the\topskip \\ |
| |
| \end{document} |