From 225f3206f85c30bcdf2ac40876fe4496b7d1a490 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Sat, 2 Jul 2011 12:23:14 -0700 Subject: [PATCH] Initial layout of the book, going with TeX. --- .dexy | 7 + .gitignore | 1 + Makefile | 41 ++ README | 4 +- book.tex | 28 + clean.sed | 5 + code/ex1.c | 5 + commands.tex | 68 +++ introduction.tex | 22 + pastie.sty | 87 +++ preamble.tex | 51 ++ preface.tex | 3 + savetrees.bst | 1420 ++++++++++++++++++++++++++++++++++++++++++++++ savetrees.sty | 195 +++++++ 14 files changed, 1936 insertions(+), 1 deletion(-) create mode 100644 .dexy create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 book.tex create mode 100644 clean.sed create mode 100644 code/ex1.c create mode 100644 commands.tex create mode 100644 introduction.tex create mode 100644 pastie.sty create mode 100644 preamble.tex create mode 100644 preface.tex create mode 100644 savetrees.bst create mode 100644 savetrees.sty diff --git a/.dexy b/.dexy new file mode 100644 index 0000000..862f386 --- /dev/null +++ b/.dexy @@ -0,0 +1,7 @@ +{ + "*.tex|jinja" : { "allinputs" : true }, + "*.py|pyg|l": {}, + "*.c|pyg|l": {}, + "*.sh|pyg|l": {}, + "*.conf|dexy": {} +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..726c3ca --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.*.sw* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..75170bf --- /dev/null +++ b/Makefile @@ -0,0 +1,41 @@ +JUNK_FILES=$(FINAL).* *.aux *.log styles/*.aux +SOURCE=book +WEBSITE=$(USER)@mongrel2.org:/var/www/mongrel2.org/static/ +FINAL=book-final + +book: + dexy + cp Makefile output/ + cp pastie.sty output/ + ${MAKE} -C output clean book-final.pdf + rm -rf output/*.dvi output/*.pdf + ${MAKE} -C output $(FINAL).pdf + +draft: $(FINAL).dvi + +$(FINAL).dvi: + cp $(SOURCE).tex $(FINAL).tex + latex -halt-on-error $(FINAL).tex + +html: + htlatex $(FINAL).tex + tidy -quiet -ashtml -omit -ic -m $(FINAL).html || true + +$(FINAL).pdf: $(FINAL).dvi + dvipdf $(FINAL).dvi + +view: $(FINAL).pdf + evince $(FINAL).pdf + +clean: + rm -rf $(JUNK_FILES) + find . -name "*.aux" -exec rm {} \; + rm -rf output + +release: clean $(FINAL).pdf draft $(FINAL).pdf sync + +sync: + rsync -vz $(FINAL).pdf $(WEBSITE)/book/LearnCTheHardWay-preview.pdf + rsync -vz $(FINAL).html $(WEBSITE)/book/LearnCTheHardWay.html + rsync -vz $(FINAL).css $(FINAL)[0-9]*.html $(WEBSITE)/book/ + diff --git a/README b/README index 3d98ba3..e65aea3 100644 --- a/README +++ b/README @@ -1 +1,3 @@ -Nothing here yet. +This will be a book teaching C programming to anyone who has already learned +one other programming language. It will teach modern C with heavey emphasis +on reliable programming. diff --git a/book.tex b/book.tex new file mode 100644 index 0000000..74459bf --- /dev/null +++ b/book.tex @@ -0,0 +1,28 @@ +\include{preamble} +\include{commands} + +\title{ + Learn C The Hard Way\\ + \textit{A Clear \& Direct Guide To Modern C Programming} +} +\author{Zed A. Shaw} +\date{July 2011} + +\begin{document} + +\frontmatter + +\maketitle + +\tableofcontents + +\include{preface} + +\mainmatter + +\include{introduction} + +\appendix + +\end{document} + diff --git a/clean.sed b/clean.sed new file mode 100644 index 0000000..270daef --- /dev/null +++ b/clean.sed @@ -0,0 +1,5 @@ +s/\[/\[/g +s/\]/\]/g +s/‘/`/g +s/’/'/g +1,18d diff --git a/code/ex1.c b/code/ex1.c new file mode 100644 index 0000000..5f3655d --- /dev/null +++ b/code/ex1.c @@ -0,0 +1,5 @@ +void main() +{ + puts("Hello world."); +} + diff --git a/commands.tex b/commands.tex new file mode 100644 index 0000000..cda61db --- /dev/null +++ b/commands.tex @@ -0,0 +1,68 @@ +% Alter some LaTeX defaults for better treatment of figures: + % See p.105 of "TeX Unbound" for suggested values. + % See pp. 199-200 of Lamport's "LaTeX" book for details. + % General parameters, for ALL pages: + \renewcommand{\topfraction}{0.9} % max fraction of floats at top + \renewcommand{\bottomfraction}{0.8} % max fraction of floats at bottom + % Parameters for TEXT pages (not float pages): + \setcounter{topnumber}{2} + \setcounter{bottomnumber}{2} + \setcounter{totalnumber}{2} % 2 may work better + \renewcommand{\dbltopfraction}{0.9} % fit big float above 2-col. text + \renewcommand{\textfraction}{0.07} % allow minimal text w. figs + % Parameters for FLOAT pages (not text pages): + \renewcommand{\floatpagefraction}{0.7} % require fuller float pages + % N.B.: floatpagefraction MUST be less than topfraction !! + \renewcommand{\dblfloatpagefraction}{0.7} % require fuller float pages + + % remember to use [htp] or [htpb] for placement + + +\newcommand{\versal}[1]{\noindent{\Huge #1\kern-.10em}} +\newcommand{\file}[1]{{\bf\ttfamily #1}} +\newcommand{\ident}[1]{{\it\ttfamily #1}} +\newcommand{\shell}[1]{{\it\ttfamily #1}} +\newcommand{\python}[1]{{\it\ttfamily #1}} +\newcommand{\ruby}[1]{{\it\ttfamily #1}} +\newcommand{\book}[2]{{\it\ttfamily #1} by {\it #2}} +\newcommand{\program}[1]{\it\ttfamily #1} + +\newenvironment{aside}[1] +{ + \begin{note} + \caption{\hfill\it #1} + \begin{quote} + \parindent 7.2pt + \parskip 5pt +} +{ \end{quote} \end{note} } + +\newenvironment{code}[1] +{ + \begin{source} + \caption{\hfill\it #1} + \sffamily\small +} +{\end{source}} + +\floatstyle{ruled} +\newfloat{note}{thp}{lon} +\floatname{note}{Note} +\newfloat{source}{thp}{los} +\floatname{source}{Source} +\newcommand{\listofnotes}{\listof{note}{List Of Notes}} +\newcommand{\listofsource}{\listof{source}{List Of Source}} + +\newcommand{\rfc}[2] + { + \begin{center} + \ovalbox{ + \begin{minipage}{.8\textwidth} + \begin{center} + {\bf #1:} {\it #2} + \end{center} + \end{minipage} + } + \end{center} + } + diff --git a/introduction.tex b/introduction.tex new file mode 100644 index 0000000..c1a59c2 --- /dev/null +++ b/introduction.tex @@ -0,0 +1,22 @@ +\chapter{Introduction} + +The introduction to "Learn C The Hard Way". + +Here is a simple first program you can make in C: + +\begin{code}{Simple C Program} +<< d['code/ex1.c|pyg|l'] >> +\end{code} + +You can put this into a \file{ex1.c} then type: + +\begin{code}{Building ex1} +\begin{Verbatim} +make ex1 +./ex1 +\end{Verbatim} +\end{code} + +Try it and let me know if it worked. + + diff --git a/pastie.sty b/pastie.sty new file mode 100644 index 0000000..f8cf041 --- /dev/null +++ b/pastie.sty @@ -0,0 +1,87 @@ + +\makeatletter +\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax% + \let\PY@ul=\relax \let\PY@tc=\relax% + \let\PY@bc=\relax \let\PY@ff=\relax} +\def\PY@tok#1{\csname PY@tok@#1\endcsname} +\def\PY@toks#1+{\ifx\relax#1\empty\else% + \PY@tok{#1}\expandafter\PY@toks\fi} +\def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{% + \PY@it{\PY@bf{\PY@ff{#1}}}}}}} +\def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}} + +\def\PY@tok@gd{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.00}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.87,0.87}{##1}}} +\def\PY@tok@gu{\def\PY@tc##1{\textcolor[rgb]{0.38,0.38,0.38}{##1}}} +\def\PY@tok@gt{\def\PY@tc##1{\textcolor[rgb]{0.67,0.00,0.00}{##1}}} +\def\PY@tok@gs{\let\PY@bf=\textbf} +\def\PY@tok@gr{\def\PY@tc##1{\textcolor[rgb]{0.67,0.00,0.00}{##1}}} +\def\PY@tok@cm{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}} +\def\PY@tok@vg{\def\PY@tc##1{\textcolor[rgb]{0.87,0.47,0.00}{##1}}} +\def\PY@tok@m{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.87}{##1}}} +\def\PY@tok@mh{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.87}{##1}}} +\def\PY@tok@cs{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.80,0.00,0.00}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.94,0.94}{##1}}} +\def\PY@tok@ge{\let\PY@it=\textit} +\def\PY@tok@vc{\def\PY@tc##1{\textcolor[rgb]{0.20,0.40,0.60}{##1}}} +\def\PY@tok@il{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.87}{##1}}} +\def\PY@tok@go{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}} +\def\PY@tok@cp{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.80,0.00,0.00}{##1}}} +\def\PY@tok@gi{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.00}{##1}}\def\PY@bc##1{\colorbox[rgb]{0.87,1.00,0.87}{##1}}} +\def\PY@tok@gh{\def\PY@tc##1{\textcolor[rgb]{0.19,0.19,0.19}{##1}}} +\def\PY@tok@s2{\def\PY@tc##1{\textcolor[rgb]{0.87,0.13,0.00}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.94,0.94}{##1}}} +\def\PY@tok@nl{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.20,0.40,0.60}{##1}}} +\def\PY@tok@nn{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.00,0.40}{##1}}} +\def\PY@tok@no{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.20,0.40}{##1}}} +\def\PY@tok@na{\def\PY@tc##1{\textcolor[rgb]{0.20,0.40,0.60}{##1}}} +\def\PY@tok@nb{\def\PY@tc##1{\textcolor[rgb]{0.00,0.20,0.53}{##1}}} +\def\PY@tok@nc{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.00,0.40}{##1}}} +\def\PY@tok@nd{\def\PY@tc##1{\textcolor[rgb]{0.33,0.33,0.33}{##1}}} +\def\PY@tok@ne{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.00,0.40}{##1}}} +\def\PY@tok@nf{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.40,0.73}{##1}}} +\def\PY@tok@si{\def\PY@tc##1{\textcolor[rgb]{0.20,0.20,0.73}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.94,0.94}{##1}}} +\def\PY@tok@sh{\def\PY@tc##1{\textcolor[rgb]{0.87,0.13,0.00}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.94,0.94}{##1}}} +\def\PY@tok@vi{\def\PY@tc##1{\textcolor[rgb]{0.20,0.20,0.73}{##1}}} +\def\PY@tok@py{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.20,0.40,0.60}{##1}}} +\def\PY@tok@nt{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.00,0.40}{##1}}} +\def\PY@tok@nv{\def\PY@tc##1{\textcolor[rgb]{0.20,0.40,0.60}{##1}}} +\def\PY@tok@s1{\def\PY@tc##1{\textcolor[rgb]{0.87,0.13,0.00}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.94,0.94}{##1}}} +\def\PY@tok@gp{\def\PY@tc##1{\textcolor[rgb]{0.33,0.33,0.33}{##1}}} +\def\PY@tok@ow{\def\PY@tc##1{\textcolor[rgb]{0.00,0.53,0.00}{##1}}} +\def\PY@tok@sx{\def\PY@tc##1{\textcolor[rgb]{0.13,0.73,0.13}{##1}}\def\PY@bc##1{\colorbox[rgb]{0.94,1.00,0.94}{##1}}} +\def\PY@tok@bp{\def\PY@tc##1{\textcolor[rgb]{0.00,0.20,0.53}{##1}}} +\def\PY@tok@c1{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}} +\def\PY@tok@kc{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.53,0.00}{##1}}} +\def\PY@tok@c{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}} +\def\PY@tok@mf{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.87}{##1}}} +\def\PY@tok@err{\def\PY@tc##1{\textcolor[rgb]{0.65,0.09,0.09}{##1}}\def\PY@bc##1{\colorbox[rgb]{0.89,0.82,0.82}{##1}}} +\def\PY@tok@kd{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.53,0.00}{##1}}} +\def\PY@tok@ss{\def\PY@tc##1{\textcolor[rgb]{0.67,0.40,0.00}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.94,0.94}{##1}}} +\def\PY@tok@sr{\def\PY@tc##1{\textcolor[rgb]{0.00,0.53,0.00}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.94,1.00}{##1}}} +\def\PY@tok@mo{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.87}{##1}}} +\def\PY@tok@mi{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.87}{##1}}} +\def\PY@tok@kn{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.53,0.00}{##1}}} +\def\PY@tok@kr{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.53,0.00}{##1}}} +\def\PY@tok@s{\def\PY@tc##1{\textcolor[rgb]{0.87,0.13,0.00}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.94,0.94}{##1}}} +\def\PY@tok@kp{\def\PY@tc##1{\textcolor[rgb]{0.00,0.53,0.00}{##1}}} +\def\PY@tok@w{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}} +\def\PY@tok@kt{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}} +\def\PY@tok@sc{\def\PY@tc##1{\textcolor[rgb]{0.87,0.13,0.00}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.94,0.94}{##1}}} +\def\PY@tok@sb{\def\PY@tc##1{\textcolor[rgb]{0.87,0.13,0.00}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.94,0.94}{##1}}} +\def\PY@tok@k{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.53,0.00}{##1}}} +\def\PY@tok@se{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.94,0.94}{##1}}} +\def\PY@tok@sd{\def\PY@tc##1{\textcolor[rgb]{0.87,0.13,0.00}{##1}}\def\PY@bc##1{\colorbox[rgb]{1.00,0.94,0.94}{##1}}} + +\def\PYZbs{\char`\\} +\def\PYZus{\char`\_} +\def\PYZob{\char`\{} +\def\PYZcb{\char`\}} +\def\PYZca{\char`\^} +\def\PYZsh{\char`\#} +\def\PYZpc{\char`\%} +\def\PYZdl{\char`\$} +\def\PYZti{\char`\~} +% for compatibility with earlier versions +\def\PYZat{@} +\def\PYZlb{[} +\def\PYZrb{]} +\makeatother + diff --git a/preamble.tex b/preamble.tex new file mode 100644 index 0000000..a472748 --- /dev/null +++ b/preamble.tex @@ -0,0 +1,51 @@ +\documentclass{book} +\usepackage{iwona,palatino} +\usepackage{pastie} +%\usepackage{palatino} +\usepackage[ + pdftitle={Learn C The Hard Way: A Clear and Direct Introduction To Programming In C}, + pdfauthor={Zed A. Shaw}, + pdfsubject={An introduction to C programming for people who know one other language.}, + pdfkeywords={C, Programming}, + bookmarks, bookmarksopen, + pdfstartview=FitH, + colorlinks,linkcolor=blue,citecolor=blue, + urlcolor=red, +]{hyperref} +\usepackage{float} +\usepackage{fancybox} +\usepackage{savetrees} +\usepackage{fancyvrb} +\usepackage{color} +\usepackage{parskip} +\usepackage{textcomp} +\usepackage{listings} +\parskip 7.2pt + +\lstset{basicstyle=\ttfamily, +upquote=true, +breaklines=true, +postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\hookrightarrow}}, +breakatwhitespace=true +} + +% taken from http://mintaka.sdsu.edu/GF/bibliog/latex/floats.html +% Alter some LaTeX defaults for better treatment of figures: +% See p.105 of "TeX Unbound" for suggested values. +% See pp. 199-200 of Lamport's "LaTeX" book for details. +% General parameters, for ALL pages: +\renewcommand{\topfraction}{0.9} % max fraction of floats at top +\renewcommand{\bottomfraction}{0.8} % max fraction of floats at bottom +% Parameters for TEXT pages (not float pages): +\setcounter{topnumber}{2} +\setcounter{bottomnumber}{2} +\setcounter{totalnumber}{4} % 2 may work better +\setcounter{dbltopnumber}{2} % for 2-column pages +\renewcommand{\dbltopfraction}{0.9} % fit big float above 2-col. text +\renewcommand{\textfraction}{0.07} % allow minimal text w. figs +% Parameters for FLOAT pages (not text pages): +\renewcommand{\floatpagefraction}{0.7} % require fuller float pages +% N.B.: floatpagefraction MUST be less than topfraction !! +\renewcommand{\dblfloatpagefraction}{0.7} % require fuller float pages + +% remember to use [htp] or [htpb] for placement diff --git a/preface.tex b/preface.tex new file mode 100644 index 0000000..762abb1 --- /dev/null +++ b/preface.tex @@ -0,0 +1,3 @@ +\chapter{Preface} + +Preface to Learn C The Hard Way. diff --git a/savetrees.bst b/savetrees.bst new file mode 100644 index 0000000..fe015c5 --- /dev/null +++ b/savetrees.bst @@ -0,0 +1,1420 @@ +%% +%% This is file `savetrees.bst', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% savetrees.dtx (with options: `bibstyle') +%% +%% The original, *original* source files were: +%% +%% merlin.mbs (with options: `,lang,nm-init,ed-au,nmdash,nmlm,x2,m2,isbn,issn,pp,ed,abr,ednx,xedn,jabr,nfss') +%% +%% In addition, Scott Pakin slightly modified this +%% file by hand. +%% ---------------------------------------- +%% *** Extremely abbreviated BibTeX style *** +%% +%% Copyright 1994-1999 Patrick W Daly + % =============================================================== + % IMPORTANT NOTICE: + % This bibliographic style (bst) file has been generated from one or + % more master bibliographic style (mbs) files, listed above. + % + % This generated file can be redistributed and/or modified under the terms + % of the LaTeX Project Public License Distributed from CTAN + % archives in directory macros/latex/base/lppl.txt; either + % version 1 of the License, or any later version. + % =============================================================== + % Name and version information of the main mbs file: + % \ProvidesFile{merlin.mbs}[1999/05/28 3.89 (PWD)] + % For use with BibTeX version 0.99a or later + %------------------------------------------------------------------- + % This bibliography style file is intended for texts in ENGLISH + % This is a numerical citation style, and as such is standard LaTeX. + % It requires no extra package to interface to the main text. + % The form of the \bibitem entries is + % \bibitem{key}... + % Usage of \cite is as follows: + % \cite{key} ==>> [#] + % \cite[chap. 2]{key} ==>> [#, chap. 2] + % where # is a number determined by the ordering in the reference list. + % The order in the reference list is alphabetical by authors. + %--------------------------------------------------------------------- + +ENTRY + { address + author + booktitle + chapter + edition + editor + howpublished + institution + isbn + issn + journal + key + language + month + note + number + organization + pages + publisher + school + series + title + type + volume + year + } + {} + { label } + +INTEGERS { output.state before.all mid.sentence after.sentence after.block } + +FUNCTION {init.state.consts} +{ #0 'before.all := + #1 'mid.sentence := + #2 'after.sentence := + #3 'after.block := +} + +STRINGS { s t } + +FUNCTION {output.nonnull} +{ 's := + output.state mid.sentence = + { ", " * write$ } + { output.state after.block = + { add.period$ write$ + newline$ + "\newblock " write$ + } + { output.state before.all = + 'write$ + { add.period$ " " * write$ } + if$ + } + if$ + mid.sentence 'output.state := + } + if$ + s +} + +FUNCTION {output} +{ duplicate$ empty$ + 'pop$ + 'output.nonnull + if$ +} + +FUNCTION {output.check} +{ 't := + duplicate$ empty$ + { pop$ "empty " t * " in " * cite$ * warning$ } + 'output.nonnull + if$ +} + +FUNCTION {fin.entry} +{ add.period$ + write$ + newline$ +} + +FUNCTION {new.block} +{ output.state before.all = + 'skip$ + { after.block 'output.state := } + if$ +} + +FUNCTION {new.sentence} +{ output.state after.block = + 'skip$ + { output.state before.all = + 'skip$ + { after.sentence 'output.state := } + if$ + } + if$ +} + +FUNCTION {add.blank} +{ " " * before.all 'output.state := +} + +FUNCTION {date.block} +{ + new.block +} + +FUNCTION {not} +{ { #0 } + { #1 } + if$ +} + +FUNCTION {and} +{ 'skip$ + { pop$ #0 } + if$ +} + +FUNCTION {or} +{ { pop$ #1 } + 'skip$ + if$ +} + +FUNCTION {new.block.checka} +{ empty$ + 'skip$ + 'new.block + if$ +} + +FUNCTION {new.block.checkb} +{ empty$ + swap$ empty$ + and + 'skip$ + 'new.block + if$ +} + +FUNCTION {new.sentence.checka} +{ empty$ + 'skip$ + 'new.sentence + if$ +} + +FUNCTION {new.sentence.checkb} +{ empty$ + swap$ empty$ + and + 'skip$ + 'new.sentence + if$ +} + +FUNCTION {field.or.null} +{ duplicate$ empty$ + { pop$ "" } + 'skip$ + if$ +} + +FUNCTION {emphasize} +{ duplicate$ empty$ + { pop$ "" } + { "\emph{" swap$ * "}" * } + if$ +} + +FUNCTION {capitalize} +{ "u" change.case$ "t" change.case$ } + +FUNCTION {space.word} +{ " " swap$ * " " * } + + % Here are the language-specific definitions for explicit words. + % Each function has a name bbl.xxx where xxx is the English word. + % The language selected here is ENGLISH +FUNCTION {bbl.and} +{ "and"} + +FUNCTION {bbl.etal} +{ "et~al." } + +FUNCTION {bbl.editors} +{ "eds." } + +FUNCTION {bbl.editor} +{ "ed." } + +FUNCTION {bbl.edby} +{ "edited by" } + +FUNCTION {bbl.edition} +{ "ed." } + +FUNCTION {bbl.volume} +{ "vol." } + +FUNCTION {bbl.of} +{ "of" } + +FUNCTION {bbl.number} +{ "no." } + +FUNCTION {bbl.nr} +{ "no." } + +FUNCTION {bbl.in} +{ "in" } + +FUNCTION {bbl.pages} +{ "pp." } + +FUNCTION {bbl.page} +{ "p." } + +FUNCTION {bbl.chapter} +{ "chap." } + +FUNCTION {bbl.techrep} +{ "Tech. Rep." } + +FUNCTION {bbl.mthesis} +{ "Master's thesis" } + +FUNCTION {bbl.phdthesis} +{ "Ph.D. thesis" } + +MACRO {jan} {"Jan."} + +MACRO {feb} {"Feb."} + +MACRO {mar} {"Mar."} + +MACRO {apr} {"Apr."} + +MACRO {may} {"May"} + +MACRO {jun} {"Jun."} + +MACRO {jul} {"Jul."} + +MACRO {aug} {"Aug."} + +MACRO {sep} {"Sep."} + +MACRO {oct} {"Oct."} + +MACRO {nov} {"Nov."} + +MACRO {dec} {"Dec."} + +MACRO {acmcs} {"ACM Comput. Surv."} + +MACRO {acta} {"Acta Inf."} + +MACRO {cacm} {"Commun. ACM"} + +MACRO {ibmjrd} {"IBM J. Res. Dev."} + +MACRO {ibmsj} {"IBM Syst.~J."} + +MACRO {ieeese} {"IEEE Trans. Softw. Eng."} + +MACRO {ieeetc} {"IEEE Trans. Comput."} + +MACRO {ieeetcad} + {"IEEE Trans. Comput.-Aided Design Integrated Circuits"} + +MACRO {ipl} {"Inf. Process. Lett."} + +MACRO {jacm} {"J.~ACM"} + +MACRO {jcss} {"J.~Comput. Syst. Sci."} + +MACRO {scp} {"Sci. Comput. Programming"} + +MACRO {sicomp} {"SIAM J. Comput."} + +MACRO {tocs} {"ACM Trans. Comput. Syst."} + +MACRO {tods} {"ACM Trans. Database Syst."} + +MACRO {tog} {"ACM Trans. Gr."} + +MACRO {toms} {"ACM Trans. Math. Softw."} + +MACRO {toois} {"ACM Trans. Office Inf. Syst."} + +MACRO {toplas} {"ACM Trans. Prog. Lang. Syst."} + +MACRO {tcs} {"Theoretical Comput. Sci."} + +INTEGERS { nameptr namesleft numnames } + +FUNCTION {format.names} +{ 's := + "" 't := + #1 'nameptr := + s num.names$ 'numnames := + numnames 'namesleft := + { namesleft #0 > } + { s nameptr + "{f.~}{vv~}{ll}{, jj}" format.name$ + 't := + nameptr #1 > + { + nameptr #2 + #1 + = + numnames #2 + > and + { "others" 't := + #1 'namesleft := } + 'skip$ + if$ + namesleft #1 > + { ", " * t * } + { + numnames #2 > + { "," * } + 'skip$ + if$ + s nameptr "{ll}" format.name$ duplicate$ "others" = + { 't := } + { pop$ } + if$ + t "others" = + { + " " * bbl.etal * + } + { bbl.and + space.word * t * + } + if$ + } + if$ + } + 't + if$ + nameptr #1 + 'nameptr := + namesleft #1 - 'namesleft := + } + while$ +} + +FUNCTION {format.names.ed} +{ format.names } + +FUNCTION {format.authors} +{ author empty$ + { "" } + { author format.names } + if$ +} + +FUNCTION {format.editors} +{ editor empty$ + { "" } + { editor format.names + ", " * + editor num.names$ #1 > + 'bbl.editors + 'bbl.editor + if$ + * + } + if$ +} + +FUNCTION {format.in.editors} +{ editor empty$ + { "" } + { editor format.names.ed + editor num.names$ #1 > + { ", " * bbl.editors * } + { ", " * bbl.editor * } + if$ + } + if$ +} + +FUNCTION {format.isbn} +{ isbn empty$ + { "" } + { + new.block + "ISBN " isbn * } + if$ +} + +FUNCTION {format.issn} +{ issn empty$ + { "" } + { + new.block + "ISSN " issn * } + if$ +} + +FUNCTION {select.language} +{ duplicate$ empty$ + 'pop$ + { language empty$ + 'skip$ + { "{\selectlanguage{" language * "}" * swap$ * "}" * } + if$ + } + if$ +} +FUNCTION {format.note} +{ + note empty$ + { "" } + { "\savetreesbibnote{" + note #1 #1 substring$ + duplicate$ "{" = + 'skip$ + { output.state mid.sentence = + { "l" } + { "u" } + if$ + change.case$ + } + if$ + note #2 global.max$ substring$ * + "}" * * + } + if$ +} + +FUNCTION {format.title} +{ title empty$ + { "" } + { title "t" change.case$ + select.language + } + if$ +} + +FUNCTION {output.bibitem} +{ newline$ + "\bibitem{" write$ + cite$ write$ + "}" write$ + newline$ + "" + before.all 'output.state := +} + +FUNCTION {n.dashify} +{ + 't := + "" + { t empty$ not } + { t #1 #1 substring$ "-" = + { t #1 #2 substring$ "--" = not + { "--" * + t #2 global.max$ substring$ 't := + } + { { t #1 #1 substring$ "-" = } + { "-" * + t #2 global.max$ substring$ 't := + } + while$ + } + if$ + } + { t #1 #1 substring$ * + t #2 global.max$ substring$ 't := + } + if$ + } + while$ +} + +FUNCTION {word.in} +{ bbl.in capitalize + " " * } + +FUNCTION {format.date} +{ year empty$ + { month empty$ + { "" } + { "there's a month but no year in " cite$ * warning$ + month + } + if$ + } + { month empty$ + 'year + { month " " * year * } + if$ + } + if$ +} + +FUNCTION {format.btitle} +{ title emphasize + select.language +} + +FUNCTION {tie.or.space.connect} +{ duplicate$ text.length$ #3 < + { "~" } + { " " } + if$ + swap$ * * +} + +FUNCTION {either.or.check} +{ empty$ + 'pop$ + { "can't use both " swap$ * " fields in " * cite$ * warning$ } + if$ +} + +FUNCTION {format.bvolume} +{ volume empty$ + { "" } + { bbl.volume volume tie.or.space.connect + series empty$ + 'skip$ + { bbl.of space.word * series emphasize * } + if$ + "volume and number" number either.or.check + } + if$ +} + +FUNCTION {format.number.series} +{ volume empty$ + { number empty$ + { series field.or.null } + { output.state mid.sentence = + { bbl.number } + { bbl.number capitalize } + if$ + number tie.or.space.connect + series empty$ + { "there's a number but no series in " cite$ * warning$ } + { bbl.in space.word * series * } + if$ + } + if$ + } + { "" } + if$ +} + +FUNCTION {format.edition} +{ edition empty$ + { "" } + { output.state mid.sentence = + { edition "l" change.case$ " " * bbl.edition * } + { edition "t" change.case$ " " * bbl.edition * } + if$ + } + if$ +} + +INTEGERS { multiresult } + +FUNCTION {multi.page.check} +{ 't := + #0 'multiresult := + { multiresult not + t empty$ not + and + } + { t #1 #1 substring$ + duplicate$ "-" = + swap$ duplicate$ "," = + swap$ "+" = + or or + { #1 'multiresult := } + { t #2 global.max$ substring$ 't := } + if$ + } + while$ + multiresult +} + +FUNCTION {format.pages} +{ pages empty$ + { "" } + { pages multi.page.check + { bbl.pages pages n.dashify tie.or.space.connect } + { bbl.page pages tie.or.space.connect } + if$ + } + if$ +} + +FUNCTION {format.journal.pages} +{ pages empty$ + 'skip$ + { duplicate$ empty$ + { pop$ format.pages } + { + ":" * + pages n.dashify * + } + if$ + } + if$ +} + +FUNCTION {format.vol.num.pages} +{ volume field.or.null + number empty$ + 'skip$ + { + "(" number * ")" * * + volume empty$ + { "there's a number but no volume in " cite$ * warning$ } + 'skip$ + if$ + } + if$ + format.journal.pages +} + +FUNCTION {format.chapter.pages} +{ chapter empty$ + 'format.pages + { type empty$ + { bbl.chapter } + { type "l" change.case$ } + if$ + chapter tie.or.space.connect + pages empty$ + 'skip$ + { ", " * format.pages * } + if$ + } + if$ +} + +FUNCTION {format.in.ed.booktitle} +{ booktitle empty$ + { "" } + { editor empty$ + { word.in booktitle emphasize * } + { word.in format.in.editors * ", " * + booktitle emphasize * } + if$ + } + if$ +} + +FUNCTION {empty.misc.check} +{ author empty$ title empty$ howpublished empty$ + month empty$ year empty$ note empty$ + and and and and and + key empty$ not and + { "all relevant fields are empty in " cite$ * warning$ } + 'skip$ + if$ +} + +FUNCTION {format.thesis.type} +{ type empty$ + 'skip$ + { pop$ + type "t" change.case$ + } + if$ +} + +FUNCTION {format.tr.number} +{ type empty$ + { bbl.techrep } + 'type + if$ + number empty$ + { "t" change.case$ } + { number tie.or.space.connect } + if$ +} + +FUNCTION {format.article.crossref} +{ + key empty$ + { journal empty$ + { "need key or journal for " cite$ * " to crossref " * crossref * + warning$ + "" + } + { word.in journal emphasize * } + if$ + } + { word.in key * " " *} + if$ + " \cite{" * crossref * "}" * +} + +FUNCTION {format.crossref.editor} +{ editor #1 "{vv~}{ll}" format.name$ + editor num.names$ duplicate$ + #2 > + { pop$ + " " * bbl.etal * + } + { #2 < + 'skip$ + { editor #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" = + { + " " * bbl.etal * + } + { bbl.and space.word * editor #2 "{vv~}{ll}" format.name$ + * } + if$ + } + if$ + } + if$ +} + +FUNCTION {format.book.crossref} +{ volume empty$ + { "empty volume in " cite$ * "'s crossref of " * crossref * warning$ + word.in + } + { bbl.volume capitalize + volume tie.or.space.connect + bbl.of space.word * + } + if$ + editor empty$ + editor field.or.null author field.or.null = + or + { key empty$ + { series empty$ + { "need editor, key, or series for " cite$ * " to crossref " * + crossref * warning$ + "" * + } + { series emphasize * } + if$ + } + { key * } + if$ + } + { format.crossref.editor * } + if$ + " \cite{" * crossref * "}" * +} + +FUNCTION {format.incoll.inproc.crossref} +{ + editor empty$ + editor field.or.null author field.or.null = + or + { key empty$ + { booktitle empty$ + { "need editor, key, or booktitle for " cite$ * " to crossref " * + crossref * warning$ + "" + } + { word.in booktitle emphasize * } + if$ + } + { word.in key * " " *} + if$ + } + { word.in format.crossref.editor * " " *} + if$ + " \cite{" * crossref * "}" * +} + +FUNCTION {format.org.or.pub} +{ 't := + "" + address empty$ t empty$ and + 'skip$ + { + t empty$ + { address empty$ + 'skip$ + { address * } + if$ + } + { t * + address empty$ + 'skip$ + { ", " * address * } + if$ + } + if$ + } + if$ +} + +FUNCTION {format.publisher.address} +{ publisher empty$ + { "empty publisher in " cite$ * warning$ + "" + } + { publisher } + if$ + format.org.or.pub +} + +FUNCTION {format.organization.address} +{ organization empty$ + { "" } + { organization } + if$ + format.org.or.pub +} + +STRINGS {oldname} + +FUNCTION {name.or.dash} +{ 's := + oldname empty$ + { s 'oldname := s } + { s oldname = + { "---" } + { s 'oldname := s } + if$ + } + if$ +} + +FUNCTION {article} +{ output.bibitem + format.authors "author" output.check + name.or.dash + new.block + format.title "title" output.check + new.block + crossref missing$ + { journal + emphasize + "journal" output.check + format.vol.num.pages output + format.date "year" output.check + } + { format.article.crossref output.nonnull + format.pages output + } + if$ + format.issn output + new.block + format.note output + fin.entry +} + +FUNCTION {book} +{ output.bibitem + author empty$ + { format.editors "author and editor" output.check + name.or.dash + } + { format.authors output.nonnull + name.or.dash + crossref missing$ + { "author and editor" editor either.or.check } + 'skip$ + if$ + } + if$ + new.block + format.btitle "title" output.check + crossref missing$ + { format.bvolume output + new.block + format.number.series output + new.sentence + format.publisher.address output + } + { + new.block + format.book.crossref output.nonnull + } + if$ + format.edition output + format.date "year" output.check + format.isbn output + new.block + format.note output + fin.entry +} + +FUNCTION {booklet} +{ output.bibitem + format.authors output + name.or.dash + new.block + format.title "title" output.check + new.block + howpublished output + address output + format.date output + format.isbn output + new.block + format.note output + fin.entry +} + +FUNCTION {inbook} +{ output.bibitem + author empty$ + { format.editors "author and editor" output.check + name.or.dash + } + { format.authors output.nonnull + name.or.dash + crossref missing$ + { "author and editor" editor either.or.check } + 'skip$ + if$ + } + if$ + new.block + format.btitle "title" output.check + crossref missing$ + { + format.bvolume output + format.chapter.pages "chapter and pages" output.check + new.block + format.number.series output + new.sentence + format.publisher.address output + } + { + format.chapter.pages "chapter and pages" output.check + new.block + format.book.crossref output.nonnull + } + if$ + format.edition output + format.date "year" output.check + crossref missing$ + { format.isbn output } + 'skip$ + if$ + new.block + format.note output + fin.entry +} + +FUNCTION {incollection} +{ output.bibitem + format.authors "author" output.check + name.or.dash + new.block + format.title "title" output.check + new.block + crossref missing$ + { format.in.ed.booktitle "booktitle" output.check + format.bvolume output + format.number.series output + format.chapter.pages output + new.sentence + format.publisher.address output + format.edition output + format.date "year" output.check + format.isbn output + } + { format.incoll.inproc.crossref output.nonnull + format.chapter.pages output + } + if$ + new.block + format.note output + fin.entry +} + +FUNCTION {inproceedings} +{ output.bibitem + format.authors "author" output.check + name.or.dash + new.block + format.title "title" output.check + new.block + crossref missing$ + { format.in.ed.booktitle "booktitle" output.check + format.bvolume output + format.number.series output + format.pages output + new.sentence + publisher empty$ + { format.organization.address output } + { organization output + format.publisher.address output + } + if$ + format.date "year" output.check + format.isbn output + format.issn output + } + { format.incoll.inproc.crossref output.nonnull + format.pages output + } + if$ + new.block + format.note output + fin.entry +} + +FUNCTION {conference} { inproceedings } + +FUNCTION {manual} +{ output.bibitem + author empty$ + { organization empty$ + 'skip$ + { organization output.nonnull + address output + } + if$ + } + { format.authors output.nonnull } + if$ + name.or.dash + new.block + format.btitle "title" output.check + author empty$ + { organization empty$ + { + address new.block.checka + address output + } + 'skip$ + if$ + } + { + organization address new.block.checkb + organization output + address output + } + if$ + format.edition output + format.date output + new.block + format.note output + fin.entry +} + +FUNCTION {mastersthesis} +{ output.bibitem + format.authors "author" output.check + name.or.dash + new.block + format.btitle "title" output.check + new.block + bbl.mthesis format.thesis.type output.nonnull + school "school" output.check + address output + format.date "year" output.check + new.block + format.note output + fin.entry +} + +FUNCTION {misc} +{ output.bibitem + format.authors output + name.or.dash + title howpublished new.block.checkb + format.title output + howpublished new.block.checka + howpublished output + format.date output + new.block + format.note output + fin.entry + empty.misc.check +} + +FUNCTION {phdthesis} +{ output.bibitem + format.authors "author" output.check + name.or.dash + new.block + format.btitle "title" output.check + new.block + bbl.phdthesis format.thesis.type output.nonnull + school "school" output.check + address output + format.date "year" output.check + new.block + format.note output + fin.entry +} + +FUNCTION {proceedings} +{ output.bibitem + editor empty$ + { organization output } + { format.editors output.nonnull } + if$ + name.or.dash + new.block + format.btitle "title" output.check + format.bvolume output + format.number.series output + editor empty$ + { publisher empty$ + 'skip$ + { + new.sentence + format.publisher.address output + } + if$ + } + { publisher empty$ + { + new.sentence + format.organization.address output } + { + new.sentence + organization output + format.publisher.address output + } + if$ + } + if$ + format.date "year" output.check + format.isbn output + format.issn output + new.block + format.note output + fin.entry +} + +FUNCTION {techreport} +{ output.bibitem + format.authors "author" output.check + name.or.dash + new.block + format.title "title" output.check + new.block + format.tr.number output.nonnull + institution "institution" output.check + address output + format.date "year" output.check + new.block + format.note output + fin.entry +} + +FUNCTION {unpublished} +{ output.bibitem + format.authors "author" output.check + name.or.dash + new.block + format.title "title" output.check + format.date output + new.block + format.note "note" output.check + fin.entry +} + +FUNCTION {default.type} { misc } + +READ + +FUNCTION {sortify} +{ purify$ + "l" change.case$ +} + +INTEGERS { len } + +FUNCTION {chop.word} +{ 's := + 'len := + s #1 len substring$ = + { s len #1 + global.max$ substring$ } + 's + if$ +} + +FUNCTION {sort.format.names} +{ 's := + #1 'nameptr := + "" + s num.names$ 'numnames := + numnames 'namesleft := + { namesleft #0 > } + { s nameptr + "{vv{ } }{ll{ }}{ f{ }}{ jj{ }}" + format.name$ 't := + nameptr #1 > + { + nameptr #2 + #1 + = + numnames #2 + > and + { "others" 't := + #1 'namesleft := } + 'skip$ + if$ + " " * + namesleft #1 = t "others" = and + { "zzzzz" * } + { t sortify * } + if$ + } + { t sortify * } + if$ + nameptr #1 + 'nameptr := + namesleft #1 - 'namesleft := + } + while$ +} + +FUNCTION {sort.format.title} +{ 't := + "A " #2 + "An " #3 + "The " #4 t chop.word + chop.word + chop.word + sortify + #1 global.max$ substring$ +} + +FUNCTION {author.sort} +{ author empty$ + { key empty$ + { "to sort, need author or key in " cite$ * warning$ + "" + } + { key sortify } + if$ + } + { author sort.format.names } + if$ +} + +FUNCTION {author.editor.sort} +{ author empty$ + { editor empty$ + { key empty$ + { "to sort, need author, editor, or key in " cite$ * warning$ + "" + } + { key sortify } + if$ + } + { editor sort.format.names } + if$ + } + { author sort.format.names } + if$ +} + +FUNCTION {author.organization.sort} +{ author empty$ + { organization empty$ + { key empty$ + { "to sort, need author, organization, or key in " cite$ * warning$ + "" + } + { key sortify } + if$ + } + { "The " #4 organization chop.word sortify } + if$ + } + { author sort.format.names } + if$ +} + +FUNCTION {editor.organization.sort} +{ editor empty$ + { organization empty$ + { key empty$ + { "to sort, need editor, organization, or key in " cite$ * warning$ + "" + } + { key sortify } + if$ + } + { "The " #4 organization chop.word sortify } + if$ + } + { editor sort.format.names } + if$ +} + +FUNCTION {presort} +{ type$ "book" = + type$ "inbook" = + or + 'author.editor.sort + { type$ "proceedings" = + 'editor.organization.sort + { type$ "manual" = + 'author.organization.sort + 'author.sort + if$ + } + if$ + } + if$ + " " + * + year field.or.null sortify + * + " " + * + title field.or.null + sort.format.title + * + #1 entry.max$ substring$ + 'sort.key$ := +} + +ITERATE {presort} + +SORT + +STRINGS { longest.label } + +INTEGERS { number.label longest.label.width } + +FUNCTION {initialize.longest.label} +{ "" 'longest.label := + #1 'number.label := + #0 'longest.label.width := +} + +FUNCTION {longest.label.pass} +{ number.label int.to.str$ 'label := + number.label #1 + 'number.label := + label width$ longest.label.width > + { label 'longest.label := + label width$ 'longest.label.width := + } + 'skip$ + if$ +} + +EXECUTE {initialize.longest.label} + +ITERATE {longest.label.pass} + +FUNCTION {begin.bib} +{ preamble$ empty$ + 'skip$ + { preamble$ write$ newline$ } + if$ + "\begin{thebibliography}{" longest.label * "}" * + write$ newline$ + "\expandafter\ifx\csname selectlanguage\endcsname\relax" + write$ newline$ + " \def\selectlanguage#1{\relax}\fi" + write$ newline$ +} + +EXECUTE {begin.bib} + +EXECUTE {init.state.consts} + +ITERATE {call.type$} + +FUNCTION {end.bib} +{ newline$ + "\end{thebibliography}" write$ newline$ +} + +EXECUTE {end.bib} +%% End of customized bst file +%% +%% End of file `savetrees.bst'. diff --git a/savetrees.sty b/savetrees.sty new file mode 100644 index 0000000..b69c664 --- /dev/null +++ b/savetrees.sty @@ -0,0 +1,195 @@ +%% +%% This is file `savetrees.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% savetrees.dtx (with options: `package') +%% +%% This is a generated file. +%% +%% Copyright (C) 2010 by Scott Pakin +%% +%% This file may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.3c of this license +%% or (at your option) any later version. The latest version of this +%% license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3c or later is part of all distributions of LaTeX version +%% 2006/05/20 or later. +%% +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{savetrees} + [2010/06/03 v1.3 Pack as much text as possible onto each page] +\newif\if@st@normal@sections +\DeclareOption{normalsections}{\@st@normal@sectionstrue} +\newif\if@st@normal@margins +\DeclareOption{normalmargins}{\@st@normal@marginstrue} +\newif\if@st@normal@lists +\DeclareOption{normallists}{\@st@normal@liststrue} +\newif\if@st@normal@floats +\DeclareOption{normalfloats}{\@st@normal@floatstrue} +\newif\if@st@normal@indent +\DeclareOption{normalindent}{\@st@normal@indenttrue} +\newif\if@st@normal@title +\DeclareOption{normaltitle}{\@st@normal@titletrue} +\newif\if@st@normal@leading +\DeclareOption{normalleading}{\@st@normal@leadingtrue} +\newif\if@st@normal@looseness +\DeclareOption{normallooseness}{\@st@normal@loosenesstrue} +\newif\if@st@normal@char@widths +\DeclareOption{normalcharwidths}{\@st@normal@char@widthstrue} +\newif\if@st@normal@bib +\DeclareOption{normalbib}{\@st@normal@bibtrue} +\newif\if@st@normal@bibnotes +\DeclareOption{normalbibnotes}{\@st@normal@bibnotestrue} +\ProcessOptions\relax +\if@st@normal@sections +\else + \RequirePackage[tiny,compact]{titlesec} +\fi +\newlength{\@st@marginsize} +\setlength{\@st@marginsize}{1.5cm} +\if@st@normal@margins +\else + \RequirePackage[lmargin=\@st@marginsize, + rmargin=\@st@marginsize, + tmargin=\@st@marginsize, + bmargin=\@st@marginsize, + includefoot, + footskip=2ex]{geometry} +\fi +\if@st@normal@lists +\else + \RequirePackage{calc} + \def\itemize{% + \ifnum \@itemdepth >\thr@@\@toodeep\else + \advance\@itemdepth\@ne + \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}% + \expandafter + \list + \csname\@itemitem\endcsname + {\def\makelabel##1{\hss\llap{##1}}% + \settowidth{\leftmargin}{\csname\@itemitem\endcsname}% + \addtolength{\leftmargin}{\labelsep * \@itemdepth}% + \setlength{\topsep}{4pt plus 1pt minus 2pt}% + \setlength{\itemsep}{0pt}% + \setlength{\parsep}{0pt}% + }% + \fi} + \def\enumerate{% + \ifnum \@enumdepth >\thr@@\@toodeep\else + \advance\@enumdepth\@ne + \edef\@enumctr{enum\romannumeral\the\@enumdepth}% + \expandafter + \list + \csname label\@enumctr\endcsname + {\usecounter\@enumctr\def\makelabel##1{\hss\llap{##1}}% + \settowidth{\leftmargin}{\csname label\@enumctr\endcsname}% + \addtolength{\leftmargin}{\labelsep * \@enumdepth}% + \setlength{\topsep}{4pt plus 1pt minus 2pt}% + \setlength{\itemsep}{0pt}% + \setlength{\parsep}{0pt}% + } + \fi} + \renewenvironment{description}{% + \begin{list}{}{\setlength{\leftmargin}{1em}% + \labelwidth\z@ \itemindent-\leftmargin + \let\makelabel\descriptionlabel}% + }{% + \end{list} + } +\fi +\if@st@normal@floats +\else + \renewcommand{\topfraction}{0.85} + \renewcommand{\bottomfraction}{0.85} + \renewcommand{\textfraction}{0.1} + \renewcommand{\floatpagefraction}{0.85} + \renewcommand{\dbltopfraction}{0.85} + \renewcommand{\dblfloatpagefraction}{.85} + \setcounter{topnumber}{25} + \setcounter{bottomnumber}{25} + \setcounter{totalnumber}{25} + \setcounter{dbltopnumber}{25} +\fi +\if@st@normal@indent +\else + \setlength{\parindent}{1em} +\fi +\if@st@normal@title +\else + \def\@maketitle{% + \newpage + \null + \begin{center}% + \let \footnote \thanks + {\large \textbf{\@title}\par} + \vskip 0.5\baselineskip + \begin{tabular}[t]{c}% + \@author + \end{tabular}\par + \vskip 0.5\baselineskip + \@date + \end{center}% + \par + \vskip \baselineskip + } +\fi +\if@st@normal@leading +\else + \renewcommand{\baselinestretch}{0.9} +\fi +\if@st@normal@looseness +\else + \let\markeverypar\everypar + \newtoks\everypar + \everypar\markeverypar + \markeverypar{\the\everypar\looseness=-1\relax} +\fi +\if@st@normal@char@widths +\else + \RequirePackage[stretch=0,shrink=50]{microtype} +\fi +\if@st@normal@bib +\else + \renewenvironment{thebibliography}[1]{% + \@ifundefined{chapter}{% + \section*{\refname + \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}}% + }{% + \chapter*{\bibname + \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}}% + }% + \list{\@biblabel{\@arabic\c@enumiv}}% + {\settowidth\labelwidth{\@biblabel{#1}}% + \leftmargin\labelwidth + \advance\leftmargin\labelsep + \setlength{\parsep}{0pt}% + \setlength{\itemsep}{1pt}% + \@openbib@code + \usecounter{enumiv}% + \let\p@enumiv\@empty + \renewcommand\theenumiv{\@arabic\c@enumiv}}% + \small + \sloppy + \clubpenalty4000 + \@clubpenalty \clubpenalty + \widowpenalty4000% + \sfcode`\.\@m + }{% + \def\@noitemerr + {\@latex@warning{Empty `thebibliography' environment}}% + \endlist + } +\fi +\if@st@normal@bibnotes + \newcommand{\savetreesbibnote}[1]{#1} +\else + \newcommand{\savetreesbibnote}[1]{\@gobble} +\fi +\endinput +%% +%% End of file `savetrees.sty'.