# Theory book style

This is the style for a book on literary theory that I'm publishing with Blackwell. It will hopefully appear in spring 2007. The environment is rather long and evolved; perhaps it is useful to beginners.

% first, the most basic stuff: input regime, font encoding, language

\enableregime[utf]

\setupencoding[default=texnansi]

\setupbodyfontenvironment[default][em=italic]

\mainlanguage[en]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% PAPERSIZE, MARGINS, SETUP %%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% the book uses a paper size of 6 in x 9 in which I typeset on A4 paper

\definepapersize[theory][width=6in,height=9in]

\setuppapersize[theory][A4]

% for copy editing, I added line numbers in the margin

\setupcolors[state=start]

\setuplinenumbering[color=red,style=\tt\tfxx,step=1,location=inmargin]

% margins etc.

\setuplayout[location=middle,
marking=off,
topspace=1.8cm,
backspace=1.6cm,
height=fit,
width=fit,
rightmargin=2cm,
leftmargin=2cm,
footer=.1cm,
setup=strict,
grid=yes]

\def\defaultwidowpenalty{0}

\def\defaultclubpenalty{0}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% REGISTERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% this is a special index: "important" references will have a bold page number,
% it's called in this form: \index[imp::]{someword}

\setupregister[index][imp][pagestyle=bold]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% PAGENUMBERING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setuppagenumbering[alternative=doublesided,location=]

\setuppagenumber[number=5]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Definitinos for the different headers. I use chapter, section, and subsection
% and "title" for the acknowledgements because they should not be included in the TOC

% The publisher wanted the chapter headings centered and split over two lines:

command=\MyChapterCommand,
style=\bfc,
number=yes,
before={\strut\blank[line]},
after={\blank[4*line]}]

style=\bfc,
align=middle,
before={\strut\blank[line]},
after={\blank[4*line]}]

style=\tfa,
align=right,
number=no,
before={\blank[line]},
after={\blank[line]}]

style=\it,
align=right,
number=no,
before={\blank[line]},
after={\blank[line]}]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% BIBLIOGRAPHY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Very long section to set up the bibliographic references and the style of the \cite
% commands (I use numbered references).

\usemodule[bib]

\setupbibtex[database={biblio}]

\setupcite
[num]
[pubsep={, },
lastpubsep={ and },
compress=yes,
inbetween={--},
left={[},
right={]}]

\setupcite
[year]
[pubsep={, },
lastpubsep={ and },
compress=yes,
inbetween={},
left={(},
right={)}]

\setupcite
[authoryears]
[pubsep={, },
lastpubsep={ and },
compress=yes,
inbetween={ },
left={(},
right={)}]

\setupcite
[key,number,page,short,type,doi]
[pubsep={, },
lastpubsep={ and },
compress=no,
inbetween={ },
left={[},
right={]}]

\def\bracketed#1{\hbox to 20pt{\hfill [\TNum{#1}]}}

\setuppublications
[sorttype=bbl,
autohang=no,
refcommand=num,
criterium=all,
numbering=bib,
numbercommand=\bracketed]

\def\tasinvertedauthor#1#2#3#4#5%
{#3%
\bibdoif{#1}{\bibalternative{surnamesep}#1\unskip}%
\bibdoifelse{#2}{\bibalternative{vonsep}#2\unskip}{\unskip}%
\bibdoifelse{#5}{\bibalternative{juniorsep}#5\unskip}{\unskip}%
}

\setuppublicationlist
[width=24pt,
maybeyear=off,
artauthor=\tasinvertedauthor,
editor=\tasinvertedauthor,
author=\tasinvertedauthor,
namesep={, },
lastnamesep={, and },
finalnamesep={, and },
firstnamesep={, },
juniorsep={, },
vonsep={ },
surnamesep={, },
authoretallimit=5,
editoretallimit=5,
artauthoretallimit=5,
authoretaldisplay=5,
editoretaldisplay=5,
artauthoretaldisplay=5,
authoretaltext={ et al.},
editoretaltext={ et al.},
artauthoretaltext={ et al.},
distance=3pt]

\newif\ifeditedbook
\setuppublicationlayout[book]{%
\insertauthors{}{: }{\inserteditors{}{, editor%
\ifnum\getvalue{editor@num}> 1 s\fi
\ \global\editedbooktrue
\unskip: }{\unskip}}%
\inserttitle{\bgroup\it }{\/\egroup}{}%
\insertseries{ (}{)}{}%
\insertedition{, }{\insertmonth{}{}{} edn. }{, }%
\insertcity{}{: }{}%
\insertpubname{}{, }{}%
\insertpubyear{}{}{}%
\insertnote{ [}{].}{.}%
}

\setuppublicationlayout[article]{%
\insertartauthors{}{: }{\insertthekey{}{ }{}}%
\insertarttitle{\bgroup }{\egroup,'' }{}%
\insertjournal{\bgroup \it}{\egroup}{\insertcrossref{in }{}{}}%
\insertvolume{ }{}{}%
\insertpubyear{ (}{) }{\unskip.}%
\insertpages{}{\insertnote{ [}{].}{.}}{.}%
\insertcomment{[}{].}{}%
}

\setuppublicationlayout[incollection]{%
\insertartauthors{}{: }{\insertthekey{}{. }{}}%
\insertarttitle{\bgroup }{\egroup,'' }{}%
\insertcrossref{in }{}{}%
\insertpages{, }{}{}%
\insertnote{ [}{].}{.}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% CROPMARKS & VISUAL AIDS %%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% during the copy-editing and production phase, I need to add some tools for visual debugging.
% They were of course commented out for the final run.

% \usemodule[t-crop][Mark=Camera,Info=yes] % this is a custom module I wrote myself

% \showgrid

% \showframe

% \showsetups

% \showlayout

% \version[temporary]

% \enablemode[transdraft] % this mode is defined later

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% FONTS & SIZES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% first we define our Normal Size and our Small Size

\define\NSize{11pt}
\define\SSize{9.5pt}

\starttypescript [serif] [default] [size]
\definebodyfont [\NSize,\SSize] [rm] [default]
\stoptypescript

% My custom typescripts for the font Garamond Premier Pro from Adobe.

\usetypescriptfile[type-garmprem]
\usetypescript[AGaramondPrem] [texnansi]
\usetypescript[AGaramondPremcpsp] [texnansi]
\usetypescript[AGaramondPrempnum] [texnansi]
\setupbodyfont[MyAGaramondPrempnum,\NSize]

% this switches between proportional numbers (for normal bodytext) and tabular numbers
% (for tables, bibliography etc.)

\define\PNum{\switchtobodyfont[MyAGaramondPrempnum]}
\define\TNum{\switchtobodyfont[MyAGaramondPrem]}

\setupinterlinespace[line=3.1ex]

% I had some (very few) Metapost pictures and wanted of course to use the same font.

\startMPenvironment
\usetypescriptfile[type-garmprem]
\usetypescript[AGaramondPrempnum] [texnansi]
\setupbodyfont[MyAGaramondPrempnum,11pt]
\stopMPenvironment

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% MODE FOR COPY-EDITING %%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% double-spaced for copy-editing

\startmode[transdraft]
\setupinterlinespace[line=24pt]
\stopmode

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% CUSTOM ENVIRONMENTS %%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% I used tikz for one picture with arrows (its default arrows are nicer than the metapost ones)

\usemodule[tikz]
\usetikzlibrary[arrows,snakes,backgrounds]

% the Greek module with Monotype Porson as font, scaled just a bit

\usemodule[t-ancientgreek][font=GreekPorson,scale=1.03]

% a very nice symbol from Garamond Premier Pro for unnumbered itemizations

\definesymbol[8][{\getglyph{orn-GaramondPremrPro}{6}}]

% custom definitions for unnumbered and numbered lists

\define\myitem{\setupitemize[1][atmargin][alignment=left]\startitemize[8,packed]}

\define\mynumber{\setupitemize[1][stopper={}]\startitemize[n,packed]}

% textbar doesn't seem to have a name in the texnansi-encoding?

\define\textbar{\getglyph{Serif}{\char124}}

% I had only four or five tables, so I wanted them numbered across the entire book

\setupreferencing[partnumber=no]

% In the table of contents, I wanted tabular numerals

\setuplist[chapter,section][pagecommand=\TNum]

% and finally, indenting

\setupindenting[1.5em]
\setupindenting[yes]



C O N T E X T G A R D E N