Advertisement
bolster

preamble.sty

Oct 18th, 2011
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 11.30 KB | None | 0 0
  1. %!TEX root = thesis.tex
  2. \ProvidesPackage{thesis-preamble}
  3.  
  4. %%% PACKAGES
  5.  
  6. \RequirePackage[T1]{fontenc} % sane font encoding
  7. \RequirePackage{textcomp} % provide lots of new symbols
  8. \RequirePackage{lmodern} % for sensible sans and tt font
  9. \RequirePackage[sc,osf]{mathpazo}% for math
  10. \RequirePackage{microtype}
  11. \RequirePackage{pifont}
  12. \newcommand\diameter{\Pisymbol{psy}{'306}}
  13. \linespread{1.1} % Palatino needs more leading
  14. \frenchspacing
  15. \normalfont
  16.  
  17. \RequirePackage[utf8]{inputenc}% sane input encoding
  18. \DeclareUnicodeCharacter{2014}{\dash}
  19. \DeclareUnicodeCharacter{2022}{\item}
  20.  
  21. \RequirePackage[noload=abbr]{siunitx}
  22. \protected\def\sipi{\mbox{\ensuremath{\pi}}}
  23. \sisetup{numaddn=\sipi}
  24.  
  25. \RequirePackage{
  26.  calc,
  27.  colortbl,
  28.  graphicx,
  29.  epstopdf,
  30.  etex,
  31.  import,
  32.  flafter,
  33.  minibox,
  34.  multicol,
  35.  psfrag,
  36.  refstyle,
  37.  soul,
  38.  suffix,
  39.  varioref,
  40.  xcolor,
  41.  zref,
  42. }
  43. \RequirePackage[draft,inline,nomargin]{fixme}
  44.  
  45. \RequirePackage[
  46. crop=pdfcrop,
  47. ps2pdf-options={-dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress},
  48. cleanup={.tex,.dvi,.ps,.pdf,.log,.aux,-blx.bib,%
  49.          .nav,.out,.out.ps,.pfg,.snm,.toc,.mp}
  50. ]{pstool}
  51. \RequirePackage[process=auto]{asyfig}
  52. \RequirePackage[inline]{asymptote}
  53. \renewcommand\asydir{asy/}
  54.  
  55. \RequirePackage{caption}
  56. \captionsetup[table]{position=top}
  57.  
  58. \RequirePackage{csquotes}
  59. \MakeOuterQuote{"}
  60.  
  61. %% Hyperref
  62. \RequirePackage[ocgcolorlinks,breaklinks,
  63.          plainpages=false,pdfpagelabels,linktocpage]{hyperref}
  64. \hypersetup{linkcolor=black,citecolor=black,filecolor=black,urlcolor=black}
  65.  
  66. \definecolor{darkred}{rgb}{0.4,0,0}
  67. \definecolor{darkgreen}{rgb}{0,0.4,0}
  68. \definecolor{darkblue}{rgb}{0,0,0.4}
  69. \hypersetup{
  70. linkcolor=darkred,
  71. citecolor=darkblue,
  72. filecolor=black,
  73. urlcolor=black
  74. }
  75. \AtBeginDocument{\hypersetup{pdfauthor={\@author},pdftitle={\@title}}}
  76.  
  77.  
  78. \@ifpackageloaded{hyperref}{}{%
  79. \PackageError{hyperref}{I am not loaded!}
  80.  {\string\pdfdef\space requires hyperref.}}
  81. \def\pdfdef#1{%
  82. \def\@tempa{#1}%
  83. \afterassignment\@pdfdef
  84. \expandafter\def\csname pdfdef@\string#1\endcsname}
  85. \def\@pdfdef{%
  86.   \expandafter\expandafter\expandafter\pdfstringdefDisableCommands
  87.   \expandafter\expandafter\expandafter{%
  88.   \expandafter\expandafter\expandafter\let\expandafter\@tempa
  89.     \csname pdfdef@\expandafter\string\@tempa\endcsname}}
  90.  
  91. \RequirePackage[open,openlevel=4]{bookmark}
  92. \RequirePackage{hypcap}
  93.  
  94. %% biblatex
  95. \usepackage[
  96.  hyperref,backref,sortcites,
  97.  defernums=true,
  98.  date=short,
  99.  bibencoding=inputenc,
  100.  maxnames=3,
  101.  minnames=2,
  102.  firstinits=true,
  103.  sorting=nyt,
  104.  bibstyle=numeric,
  105.  citestyle=numeric-comp,
  106. ]{biblatex}
  107. \def\bibfont{\small}
  108. \bibliography{journals,phd,library}
  109. \renewcommand\bibname{References}
  110.  
  111.  
  112. %%%%%%%%%%%%%%%%%%%%
  113.  
  114. %% MATHS
  115. \RequirePackage{amsmath,amssymb,bm,cool}
  116. \RequirePackage{mlist}
  117. %\RequirePackage{thesis-maths}
  118. \@ifpackageloaded{mathpazo}{\PassOptionsToPackage{mathpazo}{flexisym}}{}
  119. \@ifpackageloaded{mathptmx}{\PassOptionsToPackage{mathptmx}{flexisym}}{}
  120. \RequirePackage{breqn}
  121. \setkeys{breqn}{labelprefix=eq:}
  122.  
  123. %%%%%%%%%%%%%%%%%
  124. %%% FIGURES
  125.  
  126. \def\phdpath{}
  127. \asypath{\phdpath Figures/}
  128. \def\coilpath{\phdpath Coil/fig/}
  129.  
  130. \newcommand\grf[2][]{\includegraphics[#1]{\phdpath #2}}
  131.  
  132. \newcommand\ImportIfFileExists[4]{%
  133.   \IfFileExists{#1#2}
  134.    {\import{#1}{#2}#3}
  135.    {#4}}
  136.  
  137. % Symmetric ragged commands
  138. \newcommand\IfOddPage{%
  139.   \checkoddpage
  140.   \ifoddpage\expandafter\@firstoftwo
  141.   \else\expandafter\@secondoftwo\fi}
  142. \newcommand\raggedout{\IfOddPage\raggedright\raggedleft}
  143. \newcommand\raggedin{\IfOddPage\raggedleft\raggedright}
  144.  
  145. % Subfigures
  146. \newsubfloat{figure}
  147. \newenvironment{subfigure}[1][0.4]{%
  148.   \begin{minipage}[t]{#1\linewidth}
  149.    \centering
  150.    \let\caption\subcaption
  151. }{%
  152.   \end{minipage}%
  153. }
  154. \newenvironment{sidefigure}[1][0.4]{%
  155.   \begin{minipage}[t]{#1\linewidth}
  156.    \centering
  157. }{%
  158.   \end{minipage}%
  159. }
  160.  
  161. % wide:
  162. \newenvironment{wide}{%
  163.   \strictpagecheck
  164.   \begin{adjustwidth*}{0pt}{-\marginparsep-\marginparwidth}
  165.    \raggedout
  166. }{%
  167.   \end{adjustwidth*}%
  168. }
  169.  
  170. %% Force font sizes in MathPSfrag & matlabfrag:
  171. \def\PFGstyle{\footnotesize}
  172. \def\matlabtextA{\footnotesize}
  173. \def\matlabtextB{\footnotesize}
  174. \def\matlabtextC{\footnotesize}
  175.  
  176. %%
  177. \newcommand\gridIV[5][1em]{%
  178.   #2\hspace{#1}#3\\
  179.  [#1]#4\hspace{#1}#5}
  180. \newcommand\gridVI[7][0.5em]{%
  181.   #2\hspace{#1}#3\hspace{#1}#4\\[#1]
  182.  #5\hspace{#1}#6\hspace{#1}#7}
  183.  
  184.  
  185.  
  186. \strictpagecheck
  187.  
  188. % Make maths use lining numbers: (old-style look bad most-times)
  189. \DeclareMathSymbol{0}{0}{letters}{'060}
  190. \DeclareMathSymbol{1}{0}{letters}{'061}
  191. \DeclareMathSymbol{2}{0}{letters}{'062}
  192. \DeclareMathSymbol{3}{0}{letters}{'063}
  193. \DeclareMathSymbol{4}{0}{letters}{'064}
  194. \DeclareMathSymbol{5}{0}{letters}{'065}
  195. \DeclareMathSymbol{6}{0}{letters}{'066}
  196. \DeclareMathSymbol{7}{0}{letters}{'067}
  197. \DeclareMathSymbol{8}{0}{letters}{'070}
  198. \DeclareMathSymbol{9}{0}{letters}{'071}
  199.  
  200. %%%%%%%%%%%%%
  201. %! FLOATS
  202. \renewcommand{\topfraction}{.8}
  203. \renewcommand{\bottomfraction}{.3}
  204. \renewcommand{\textfraction}{.15}
  205. \renewcommand{\floatpagefraction}{.66}
  206. \renewcommand{\dbltopfraction}{.66}
  207. \renewcommand{\dblfloatpagefraction}{.66}
  208. \setcounter{topnumber}{9}
  209. \setcounter{bottomnumber}{9}
  210. \setcounter{totalnumber}{20}
  211. \setcounter{dbltopnumber}{9}
  212.  
  213. \renewenvironment{figure}[1][\fps@figure]
  214.                 {\edef\@tempa{\noexpand\@float{figure}[#1]}
  215.                  \@tempa\capstart\centering}
  216.                 {\end@float}
  217. \renewenvironment{table}[1][\fps@table]
  218.                 {\edef\@tempa{\noexpand\@float{table}[#1]}
  219.                  \@tempa\capstart\centering}
  220.                 {\end@float}
  221.  
  222.  
  223. %% Floats & captions
  224. \captionnamefont{\scshape}
  225. %\setlength\captionwidth{0.9\linewidth}
  226. %\changecaptionwidth
  227.  
  228. \newcommand\lofcaption[2]{\caption[#1]{#1#2}}
  229. \DeclareRobustCommand\periodifnocomma{\@ifnextchar,{}{.}}
  230.  
  231. %%%%%%%%%%%%
  232. % These are the varioref definitions:
  233. % \newcommand{\varioprefix}{See~}
  234. % \newcommand{\myvariohook}[1]{\marginpar{\small\centering \varioprefix #1}}
  235. % \def\reftextcurrent{}
  236. % \def\reftextfaceafter{}
  237. % \def\reftextfacebefore{}
  238. % \def\reftextafter{~on the \reftextvario{following}{next} page}
  239. % \def\reftextbefore{~on the \reftextvario{previous page}{preceding page}}
  240. % \def\reftextafter{}
  241. % \def\reftextbefore{}
  242. % \def\reftextfaraway#1{\myvariohook{p.\,\pageref{#1}}}
  243. % \def\reftextpagerange#1#2{\myvariohook{pp.\,\pageref{#1}--\pageref{#2}}}
  244.  
  245. %%%%%%%%%%%%%%%%%%%%%
  246. %! MEMOIR CUSTOMISE
  247.  
  248. \maxsecnumdepth{subsection} % number  subsections
  249. \maxtocdepth{subsection}    % include subsections in ToC
  250.  
  251. \renewcommand{\cftchapterpagefont}{}
  252. \renewcommand{\cftchapterfont}{}     % no bold!
  253. \renewcommand\cftdotsep{999} % no dots
  254.  
  255. % for page numbers:
  256. \newcommand\thesispage{\normalfont p.\,\thepage}
  257.  
  258. %%% CHAPTERS
  259. \makechapterstyle{wspr}{%
  260.   \setlength\beforechapskip{0pt}
  261.  \setlength\midchapskip{0pt}
  262.  \setlength\afterchapskip{40pt}
  263.   \renewcommand\chapnamefont{%
  264.     \normalfont\centering\large\scshape\MakeLowercase}
  265.   \renewcommand\chapnumfont{%
  266.     \normalfont\centering\fontsize{60pt}{0pt}\selectfont}
  267.   \renewcommand\chaptitlefont{%
  268.     \normalfont\HUGE\bfseries\centering}
  269.   \renewcommand\printchaptername{%
  270.     \marginpar{\chapnamefont{\@chapapp}}}
  271.  \renewcommand\chapternamenum{}
  272.   \renewcommand\printchapternum{%
  273.     \marginpar{\chapnumfont\thechapter}}
  274.    \makeoddfoot{plain}{}{\thesispage}{}
  275. }
  276. \chapterstyle{wspr}
  277.  
  278.  
  279. %%% SECTIONS
  280. \newcommand\marginnum[2]{%
  281.   \noindent
  282.   \let\@tempa\relax
  283.   \savebox\@tempboxa{#2}%
  284.   %\null\marginpar{#1\@tempa}%
  285.   #1\@tempa\quad#2}
  286.  
  287. \def\secstyle{\centering\scshape}
  288. \def\subsecstyle{\centering\itshape}
  289. \def\subsubsecstyle{\centering\small\itshape}
  290.  
  291. \setsecheadstyle{\marginnum\secstyle}
  292. \setsubsecheadstyle{\marginnum\subsecstyle}
  293. \setsubsubsecheadstyle{\marginnum\subsubsecstyle}
  294.  
  295. \setsecnumformat{\unexpanded{%
  296.   \protected@xdef\@tempa{{\upshape\S\csname the#1\endcsname}}}}
  297.  
  298. %%%%%
  299.  
  300. \def\printtoctitle#1{\section*{#1}}
  301.  
  302. %%%%%
  303.  
  304. %% Page headers
  305. \setlength{\headheight}{\baselineskip}
  306. \setlength{\headwidth}{\textwidth+\marginparsep+0.5\marginparwidth}
  307. \makepagestyle{wspr}
  308. \makepsmarks{wspr}{%
  309.   \let\@mkboth\markboth%
  310.   \def\chaptermark##1{%
  311.     \markboth{%
  312.       \if@mainmatter
  313.         \textsc{Chapter \thechapter:} %
  314.       \fi
  315.       ##1}{##1}}%
  316.   \def\sectionmark##1{%
  317.     \markright{%
  318.       \if@mainmatter
  319.         \textsc{\S\thesection:} %
  320.       \fi
  321.       ##1}}}
  322. \makerunningwidth{wspr}{\headwidth}
  323. \makeheadposition{wspr}{flushright}{flushleft}{}{}
  324. \makeevenhead{wspr}{\makebox[0pt][c]{\thesispage}} {} {\small\leftmark}
  325. \makeoddhead{wspr} {\small\rightmark}              {} {\thesispage}
  326. \pagestyle{wspr}
  327.  
  328.  
  329. %%% LISTS
  330. \renewcommand*{\descriptionlabel}[1]{\hspace\labelsep\normalfont\itshape #1}
  331. \tightlists
  332.  
  333. \newif   \ifshorttoc
  334. \newenvironment {hideshorttoc} {
  335.  \addtocontents{toc}{ \protect\ifshorttoc \protect\else }
  336. }{
  337.  \addtocontents{toc}{ \protect\fi }
  338. }
  339.  
  340. \newcommand*{\setupshorttoc}{%
  341.   \shorttoctrue
  342.   \renewcommand*{\contentsname}{Short contents}
  343.  \let\oldchangetocdepth\changetocdepth
  344.  \renewcommand{\precistoctext}[1]{%
  345.     \nobreak
  346.     \begin{quote}
  347.      \leftskip    = 0cm plus  0.5fil
  348.      \rightskip   = 0cm plus -0.5fil
  349.      \parfillskip = 0cm plus    1fil
  350.      \footnotesize ##1
  351.    \end{quote}
  352.  }
  353.  \let\oldcftchapterfillnum\cftchapterfillnum
  354.  \renewcommand*{\changetocdepth}[1]{}
  355.  \setcounter{tocdepth}{0}% chapters
  356.   %
  357.   \renewcommand*{\cftchapterfont}{\hfill}
  358.  \renewcommand*{\cftchapterfillnum}[1]{%
  359.     \quad \nobreak p.\,##1\hfill \null \par
  360.   }
  361.   %
  362.   \renewcommand*{\cftpartfont}{\hfill \bfseries}
  363.  \renewcommand*{\cftpartfillnum}[1]{\hfill\null\par}
  364. }
  365.  
  366. \newcommand*{\setupparasubsecs}{%
  367.   \shorttocfalse
  368.   \let\oldnumberline\numberline
  369.   \renewcommand \cftsubsectionfont     {\small}
  370.  \renewcommand \cftsubsectionpagefont {\upshape\small}
  371.   \renewcommand \l@subsection [2] {%
  372.     \ifnum\c@tocdepth > 1
  373.       \def\numberline####1{\parsesubsection####1\@nil}%
  374.       \leftskip=\cftsubsectionindent
  375.       \rightskip=\@tocrmarg
  376.       \advance\rightskip 0pt plus 2em
  377.       \parfillskip=\fill
  378.       \ifhmode
  379.         \unskip\unskip\unskip\unskip\unskip\unskip\unskip\unskip \unskip\unskip\unskip\unskip\unskip\unskip\unskip\unskip\,,\space
  380.       \else
  381.         \noindent
  382.       \fi
  383.       \ignorespaces
  384.       {\cftsubsectionfont ##1}~{\cftsubsectionpagefont##2}%
  385.        \let\numberline\oldnumberline\expandafter\ignorespaces
  386.     \fi
  387.   }%
  388. }
  389.  
  390. \def\parsesubsection#1.#2.#3\@nil{#3 \itshape}
  391.  
  392. \AtEndDocument{\addtocontents{toc}{\par}}%%% OK
  393.  
  394. \newcommand*{\setupmaintoc}{%
  395.   \renewcommand{\contentsname}{Contents}
  396.  \let\changetocdepth\oldchangetocdepth
  397.  \renewcommand{\precistoctext}[1]{}
  398.  \let\cftchapterfillnum\oldcftchapterfillnum
  399.  \addtodef{\cftchapterbreak}{\par}{}
  400.  \renewcommand*{\cftchapterfont}{\normalfont}
  401.  \renewcommand*{\cftchapterleader}{\cftdotfill{\cftchapterdotsep}}
  402.  \renewcommand*{\cftchapterafterpnum}{}
  403.  \renewcommand{\cftchapterbreak}{\par\addpenalty{-\@highpenalty}}
  404.  \setpnumwidth{2.55em}
  405.  \setrmarg{3.55em}
  406.  \setcounter{tocdepth}{2}
  407.  \let\cftpartformatpnum\oldcftpartformatpnum
  408.  \addtodef{\cftpartbreak}{\par}{}
  409.  \let\cftbookformatpnum\oldcftbookformatpnum
  410.  \addtodef{\cftbookbreak}{\par}{}
  411. }
  412.  
  413. \renewcommand\chapterprecistoc[1]{%
  414.   \addtocontents{toc}{\protect\precistoctext{#1}}%
  415. }
  416.  
  417. \renewcommand\chapterprecishere[1]{}
  418.  
  419.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement