cv

latex to pdf cv
git clone git://git.pyratebeard.net/cv.git
Log | Files | Refs | README

commit ea73f1b56b239eeba646772e08cc36891ceac21d
Author: pyratebeard <root@pyratebeard.net>
Date:   Fri, 15 Nov 2019 00:37:08 +0000

inital commit

latex cv file and pdf. enumitem and titlesec packages used.

Diffstat:
A.gitignore | 5+++++
AREADME.md | 6++++++
Acv.pdf | 0
Acv.tex | 144+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aenumitem.sty | 1909+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atitlesec.sty | 1719+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 3783 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,5 @@ +*.aux +*.cls +*.fdb_latexmk +*.fls +*.log diff --git a/README.md b/README.md @@ -0,0 +1,6 @@ +# personal cv + +## usage +``` +latexmk -pvc -pdf cv.tex +``` diff --git a/cv.pdf b/cv.pdf Binary files differ. diff --git a/cv.tex b/cv.tex @@ -0,0 +1,144 @@ +% Dudley Burrows - Curriculum Vitae + +% https://en.wikibooks.org/wiki/LaTeX/Basics + +\documentclass[10pt,a4paper]{article} + +\usepackage[margin=1.5cm]{geometry} +\usepackage[utf8]{inputenc} + +% section title formatting +\usepackage[explicit]{titlesec} +\titleformat{\section} + {\normalfont\normalsize\bfseries}{\thesection}{1em}{\MakeUppercase{#1}} +\titleformat{\subsection} + {\normalfont\small\bfseries}{\thesection}{1em}{\MakeUppercase{#1}} + +% horizontal rule +\newcommand{\HRule}[1][\medskipamount]{\par + \vspace*{\dimexpr-\parskip-\baselineskip+#1} + \noindent\rule{\linewidth}{0.4pt}\par + \vspace*{\dimexpr-\parskip-.5\baselineskip+#1}} + +% list formatting +\usepackage{enumitem} +\setlist{noitemsep,after=\vspace{\baselineskip}} % https://tex.stackexchange.com/a/199204 + +% text alignment +% https://tex.stackexchange.com/a/55503 +\newcommand{\textline}[3]{% + \par\medskip\noindent + \makebox[0pt][l]{#1}% + \makebox[\textwidth][c]{#2}% + \makebox[0pt][r]{\texttt{#3}}\par\medskip} +\newcommand\tab[1][1cm]{\hspace*{#1}} + +\setlength{\parindent}{0pt} + +% footer formatting (http://linorg.usp.br/CTAN/macros/latex/contrib/fancyhdr/fancyhdr.pdf) +\usepackage{fancyhdr} +\pagestyle{fancy} +\fancyhead{} +\fancyfoot[L]{} +\fancyfoot[C]{Dudley Burrows} +\fancyfoot[R]{} + +\begin{document} +\thispagestyle{empty} +\textline{}{\Large{\uppercase{\textbf{Dudley Burrows}}}}{} +\textline{}{\large{\uppercase{octotech limited}}}{} +\textline{}{http://octo.tech\tab[2cm]dudley@octo.tech}{} + +\section*{Profile} +\HRule +\vspace{10pt} +An enthusiastic and professional Linux and Unix systems engineer. Highly motivate and pro-active with a high level of technical expertise. Extensive experience working in a customer and end user environment. Enjoys working autonomously or as part of a successful and productive team. Outstanding communication skills and quick to grasp new ideas and concepts, able to develop innovative and creative solutions to problems. + +\section*{Key Skills} +\HRule + +\begin{itemize} + \item Experience on various Linux and Unix based operating systems, specialising in Red Hat + \item Comprehensive DevOps ideology with an agile and dynamic working mindset, focused on application development and automation of tasks + \item Support and maintenance of highly available, critical systems + \item Extensive insight into aspects of computer and network security, having worked in highly security conscious roles throughout career + \item Knowledge of cloud platforms (AWS, Azure, DigitalOcean) + \item Maintains up-to-date with technology and security news, and best working practices + \item Analytical with attention to detail; regularly dealing with various complex technical problems prioritising to ensure effectiveness against deadline dependant issues + \item Managerial skills within a small team, including work load and time management +\end{itemize} + +\section*{Career History} +\HRule + +\subsection*{Global Payments} +\textline{\textbf{Production Operations Engineer}}{}{\textnormal{2019 - present}} +John Rogerson Quay, Dublin + +\begin{itemize} + \item Provide day to day support for a large Linux Server estate including system administration tasks, application fault finding, and helping to improve work efficiency + \item Developed DNS failover automation script using third party DNS provider's API + \item Deployed Kubernetes clusters in Azure using AKS engine + \item Supported high priority application incidents using realtime data through ElasticSearch, Logstash, and Kibana +\end{itemize} + +\subsection*{Ward Solutions} +\textline{\textbf{Linux Engineer}}{}{\textnormal{2017 - 2019}} +Citywest Business Campus, Dublin + +\begin{itemize} + \item Carried out technical lead roles on a number of incidents of high severity for a range of customers + \item Improved managerial skills by working extensively with customers on various projects, acting as technical subject matter expert and ensuring projects meet their required deadlines + \item As a Cloud Technical Engineer for out internal support moved various services and platforms to Azure, including the company website + \item As part of a large ongoing project implemented an extensive, dynamic Ansible configuration management solution to allow for control and assurance on multiple environments + \item Encouraged the development of a company knowledgebase for information centralisation and improvement of knowledge transfer + \item Advised customers on ways to utilise automation to reduce workload and improve efficiency + \item Helped roll out the use of an automation tools and methods for the company's internal Linux estate regarding patching, user account administration, and engineer system access +\end{itemize} +\renewcommand\headrulewidth{0pt} +\subsection*{CSC Sciences} +\textline{\textbf{Linux/Unix Engineer}}{}{\textnormal{2013 - 2017}} +Gloucester and London + +\begin{itemize} + \item Designed an automated Virtual Machine provisioning solution for VMWare vSphere. Using Python and a web based form was able to automate provisioning for Linux and Windows servers, reducing engineer workload dramatically and providing the customer with a quick provisioning service + \item Began development and enhancement of the current configuration management system using Puppet technology. Utilised current tools with improvements implemented after training course + \item Successfully designed and implemented a Python based website to assist with checking multiple applications from one webpage to improve work efficiency. Applications include DNS, SSH, Opsware, VSphere, and LDAP +\end{itemize} + +\subsection*{HM Forces, Royal Air Force} +\textline{\textbf{Eng Tech EL / CIS Tech}}{}{\textnormal{2003 - 2013}} + +\textline{\textbf{ICS Support and Project Supervisor}}{}{\textnormal{2011 - 2013}} +GOSCC, MOD Corsham + +\begin{itemize} + \item Due to line manager being deployed to the Middle East, acted as primary liaison between users and contractors during the tech refresh of a global network configuration database system + \item Worked closely with third party contractors to resolve a fault with a terminal in Afghanistan. Using remote access and working at DOS command level, assisted in the diagnosis and rectification of the fault +\end{itemize} + +\textline{\textbf{Information Hub Junior Manager}}{}{\textnormal{2010 - 2011}} +RAF Cottesmore + +\begin{itemize} + \item Led a team involved with the controlling of the recently implemented DII system and providing information on its use to the customers + \item As the main customer focal point used effective communication skills to convey a positive impression of the section +\end{itemize} + +\textline{\textbf{Earlier career}}{}{\textnormal{2003 - 2010}} +RAF Cosford and RAF Lossiemouth +\newline +\newline +After I joined the Royal Air Force in 2003 I undertook an 18 month course in Electronics Engineering. Once I had completed my training in 2005 I worked as an IT Maintenance Support technician at RAF Lossiemouth. As part of the IT team I was responsible for the repair and configuration of all IS equipment, license control, and system administration to a user base of over 2000 personnel. This also involved maintaining, fault finding, procurement, and installation of new systems, and expanding the physical local network. I then moved on to working as an Airfield Communication and Navigation Equipment Technician, maintaining all airfield navigational equipment for a 24 hour airfield. In 2009 I was deployed to Camp Bastion, Afghanistan as a maintenance technician for the Air Defence Radar. +\section*{Training and Professional Development} +\HRule +\vspace{10pt} +\begin{tabular}{ l l } + ONC Electronics Engineering BTEC & SUSE Certified Linux Engineer (CLE)\\ + NVQ Level 3 Electronic Engineering & Watchman Radar System Maintenance\\ + CompTIA Linux+ & Type 101 Air Defence Radar Maintenance\\ + Linux Professional Institute Certification (LPIC-1) & Junior Management and Leadership training\\ + ITIL ver3 Foundation & RAF Mountain Rescue team member (2007 - 2008)\\ +\end{tabular} + +\end{document} diff --git a/enumitem.sty b/enumitem.sty @@ -0,0 +1,1909 @@ +% +% Copyright (C) 2003-2019 Javier Bezos http://www.texnia.com +% +% This file may be distributed and/or modified under the conditions of +% the MIT License. A version can be found at the end of this file. +% +% Repository: https://github.com/jbezos/enumitem +% +% Release +% ~~~~~~~ + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{enumitem}[2019/06/20 v3.9 Customized lists] + +% Notes +% ~~~~~ +% +% The tag enit@ is used through the style +% +% To do: +% ~~~~~~ +% - ref*, for adding stuff in the same fashion as label* +% - labelled descriptions (ie, label, title, body) +% - A true nextline (far from trivial and perhaps solved with +% labelled descriptions). +% - Improved \AddEnumerateCounter +% - Compatibility with interfaces and zref-enumitem +% - "Pausing" somehow inline boxed text. +% - \@enumctr <-> \@listctr? +% - Define keys with values +% - Revise @nobreak +% - bottomsep +% - \SetEnumerateCounter - must define syntax +% - option verbose +% - collect sizes in \SetEnumitemSizes? +% - series=explicit / resume +% - package option inlinenew, to define "new" inline lists +% +% +=============================+ +% | EMULATING KEYVAL | +% +=============================+ +% +% "Thanks" to xkeyval, which uses the same macro names as keyval :-(, +% the latter has to be replicated in full here to ensure it works as +% intended. The original work is by David Carlisle, under license LPPL. +% Once the code is here, it could be optimized by adapting it to the +% specific needs of enumitem (to do). + +\def\enitkv@setkeys#1#2{% + \def\enitkv@prefix{enitkv@#1@}% + \let\@tempc\relax + \enitkv@do#2,\relax,} + +\def\enitkv@do#1,{% + \ifx\relax#1\empty\else + \enitkv@split#1==\relax + \expandafter\enitkv@do\fi} + +\def\enitkv@split#1=#2=#3\relax{% + \enitkv@@sp@def\@tempa{#1}% + \ifx\@tempa\@empty\else + \expandafter\let\expandafter\@tempc + \csname\enitkv@prefix\@tempa\endcsname + \ifx\@tempc\relax + \enitkv@errx{\@tempa\space undefined}% + \else + \ifx\@empty#3\@empty + \enitkv@default + \else + \enitkv@@sp@def\@tempb{#2}% + \expandafter\@tempc\expandafter{\@tempb}\relax + \fi + \fi + \fi} + +\def\enitkv@default{% + \expandafter\let\expandafter\@tempb + \csname\enitkv@prefix\@tempa @default\endcsname + \ifx\@tempb\relax + \enitkv@err{No value specified for \@tempa}% + \else + \@tempb\relax + \fi} + +\def\enitkv@errx#1{\enit@error{#1}\@ehc} + +\let\enitkv@err\enitkv@errx + +\def\@tempa#1{% + \def\enitkv@@sp@def##1##2{% + \futurelet\enitkv@tempa\enitkv@@sp@d##2\@nil\@nil#1\@nil\relax##1}% + \def\enitkv@@sp@d{% + \ifx\enitkv@tempa\@sptoken + \expandafter\enitkv@@sp@b + \else + \expandafter\enitkv@@sp@b\expandafter#1% + \fi}% + \def\enitkv@@sp@b#1##1 \@nil{\enitkv@@sp@c##1}} + +\@tempa{ } + +\def\enitkv@@sp@c#1\@nil#2\relax#3{\enitkv@toks@{#1}\edef#3{\the\enitkv@toks@}} + +\@ifundefined{KV@toks@} + {\newtoks\enitkv@toks@} + {\let\enitkv@toks@\KV@toks@} + +\def\enitkv@key#1#2{% + \@ifnextchar[% + {\enitkv@def{enumitem#1}{#2}}% + {\@namedef{enitkv@enumitem#1@#2}####1}} + +\def\enitkv@def#1#2[#3]{% + \@namedef{enitkv@#1@#2@default\expandafter}\expandafter + {\csname enitkv@#1@#2\endcsname{#3}}% + \@namedef{enitkv@#1@#2}##1} + +% This ends the code copied from keyval (under LPPL). + +% +=============================+ +% | DEFINITIONS | +% +=============================+ +% +% (1) The package uses a token register very often. To be on the +% safe side, instead of \toks@, etc., a new one is declared. +% (2) \enit@inbox is the box storing the items in boxed inline +% lists. +% (3) \enit@outerparindent is used to save the outer parindent +% so that it can be used in the key parindent +% (4) \enit@type has three values: 0 = enum, 1 = item, 2 = desc. +% (5) \enit@calc stores which dimen is to be computed: +% 0=labelindent, 1=labelwidth, 2=labelsep, 3=leftmargin, +% 4=itemindent +% (6) \enit@resuming has four values: 0 = none, 1 = series, +% 2 = resume* series (computed in group enumitem-resume), +% 3 = resume* list (ie, with no value). + +\chardef \enit@iv=4 +\newlength\labelindent +\newdimen \enit@outerparindent +\newtoks \enit@toks +\newbox \enit@inbox + +\newif\ifenit@boxmode +\newif\ifenit@sepfrommargin +\newif\ifenit@lblfrommargin +\newif\ifenit@calcwidest +\newif\ifenit@nextline +\newif\ifenit@boxdesc + +% An alias (calc-savvy): + +\let\c@enit@cnt\@tempcnta + +\def\enit@meaning{\expandafter\strip@prefix\meaning} +\def\enit@noexcs#1{\expandafter\noexpand\csname#1\endcsname} + +\long\def\enit@afterelse#1\else#2\fi{\fi#1} +\long\def\enit@afterfi#1\fi{\fi#1} +\def\enit@ifunset#1{% + \expandafter\ifx\csname#1\endcsname\relax + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi} +\enit@ifunset{ifcsname}% + {}% + {\def\enit@ifunset#1{% + \ifcsname#1\endcsname + \expandafter\ifx\csname#1\endcsname\relax + \enit@afterelse\expandafter\@firstoftwo + \else + \enit@afterfi\expandafter\@secondoftwo + \fi + \else + \expandafter\@firstoftwo + \fi}} + +% Miscelaneous errors +% =================== + +\def\enit@error{\PackageError{enumitem}} + +\def\enit@checkerror#1#2{% + \enit@error{Unknown value '#2' for key '#1'}% + {See the manual for valid values}} + +\def\enit@itemerror{% + \enit@error{Misplaced \string\item}% + {Either there is some text before the first\MessageBreak + item or the last item has no text}} + +\def\enit@noserieserror#1{% + \enit@error{Series '#1' not started}% + {You are trying to continue a series\MessageBreak + which has not been started with 'series'}} + +\def\enit@checkseries#1{% + \ifcase\enit@resuming + \enit@error{Misplaced key '#1'}% + {'series' and 'resume*' must be used\MessageBreak + in the optional argument of lists}% + \fi} + +\def\enit@checkseries@m{% + \ifcase\enit@resuming\else + \enit@error{Uncompatible series settings}% + {'series' and 'resume*' must not be used\MessageBreak + at the same time}% + \fi} + +\let\enit@toodeep\@toodeep + +\def\@toodeep{% + \ifnum\@listdepth>\enit@listdepth\relax + \enit@toodeep + \else + \count@\@listdepth + \global\advance\@listdepth\@ne + \enit@ifunset{@list\romannumeral\the\@listdepth}% + {\expandafter\let + \csname @list\romannumeral\the\@listdepth\expandafter\endcsname + \csname @list\romannumeral\the\count@\endcsname}{}% + \fi} + +% +=============================+ +% | KEYS | +% +=============================+ +% +% Including code executed by keys. +% +% There are 2 keyval groups: enumitem, and enumitem-delayed. +% The latter is used to make sure a prioritary key is the latest one; +% eg, ref, so that the ref format set by label is overriden. So, when +% this key is found in enumitem, nothing is done, except the key/value +% is moved to enumitem-delayed. +% +% A further group (enumitem-resume) catches resume* and series in +% optional arguments in lists. +% +% Vertical spacing +% ================ + +\enitkv@key{}{topsep}{% + \enit@setlength\topsep{#1}} + +\enitkv@key{}{itemsep}{% + \enit@setlength\itemsep{#1}} + +\enitkv@key{}{parsep}{% + \enit@setlength\parsep{#1}} + +\enitkv@key{}{partopsep}{% + \enit@setlength\partopsep{#1}} + +% Horizontal spacing +% ================== +% +% There are 3 cases: *, ! and a value. The latter also +% cancels widest with the sequence key=* ... key=value +% \string is used, just in case some package changes the +% catcodes. + +\def\enit@calcset#1#2#3{% + \if\string*\string#3% + \enit@calcwidesttrue + \let\enit@calc#2% + \else\if\string!\string#3% + \enit@calcwidestfalse + \let\enit@calc#2% + \else + \ifnum\enit@calc=#2% + \enit@calcwidestfalse + \let\enit@calc\z@ + \fi + \enit@setlength#1{#3}% + \fi\fi} + +\def\enitkv@enumitem@widest#1{% + \ifcase\enit@type % enumerate + \expandafter\let\csname enit@cw@\@enumctr\endcsname\relax + \@namedef{enit@widest@\@enumctr}##1{\enit@format{#1}}% + \else % itemize / description + \def\enit@widest@{\enit@format{#1}}% + \fi} + +\def\enitkv@enumitem@widest@default{% + \expandafter\let\csname enit@cw@\@enumctr\endcsname\relax + \expandafter\let\csname enit@widest@\@enumctr\endcsname\relax} + +\enitkv@key{}{widest*}{% + \setcounter{enit@cnt}{#1}% + \expandafter\edef\csname enit@cw@\@enumctr\endcsname + {\the\c@enit@cnt}% + \expandafter\edef\csname enit@widest@\@enumctr\endcsname##1% + {##1{\the\c@enit@cnt}}} + +\enitkv@key{}{labelindent*}{% + \enit@lblfrommargintrue + \ifnum\enit@calc=\z@ + \enit@calcwidestfalse + \fi + \enit@setlength\labelindent{#1}% + \advance\labelindent\leftmargin} + +\enitkv@key{}{labelindent}{% + \enit@lblfrommarginfalse + \enit@calcset\labelindent\z@{#1}} + +\enitkv@key{}{labelwidth}{% + \enit@calcset\labelwidth\@ne{#1}} + +\enitkv@key{}{leftmargin}{% + \edef\enit@c{\the\leftmargin}% + \enit@calcset\leftmargin\thr@@{#1}% + \ifenit@lblfrommargin + \advance\labelindent-\enit@c\relax + \advance\labelindent\leftmargin + \fi} + +\enitkv@key{}{itemindent}{% + \edef\enit@c{\the\itemindent}% + \enit@calcset\itemindent\enit@iv{#1}% + \ifenit@sepfrommargin + \advance\labelsep-\enit@c\relax + \advance\labelsep\itemindent + \fi} + +\enitkv@key{}{listparindent}{% + \enit@setlength\listparindent{#1}} + +\enitkv@key{}{rightmargin}{% + \enit@setlength\rightmargin{#1}} + +% labelsep, from itemindent; labelsep*, from leftmargin + +\enitkv@key{}{labelsep*}{% + \enit@sepfrommargintrue + \ifnum\enit@calc=\tw@ + \enit@calcwidestfalse + \let\enit@calc\z@ + \fi + \enit@setlength\labelsep{#1}% + \advance\labelsep\itemindent} + +\enitkv@key{}{labelsep}{% + \enit@sepfrommarginfalse + \enit@calcset\labelsep\tw@{#1}} + +\enitkv@key{}{left}{% + \enit@setleft#1..\@empty..\@@} + +\def\enit@setleft#1..#2..#3\@@{% + \enit@setlength\labelindent{#1}% + \edef\enit@a{#3}% + \ifx\enit@a\@empty + \enit@calcset\leftmargin\thr@@*% + \else + \enit@setlength\leftmargin{#2}% + \enit@calcset\labelsep\tw@*% + \fi} + +% Series, resume and start +% ======================== + +\enitkv@key{-resume}{series}{% + \enit@checkseries@m + \let\enit@resuming\@ne %%% TODO - default check also \Set..Key + \ifcase\enit@seriesopt + \enit@ifunset{enitkv@enumitem@#1}{}% + {\enit@error + {Invalid series name '#1'}% + {Do not name a series with an existing key}}% + \else % series=override + \global\@namedef{enitkv@enumitem@#1}% with value + {\enit@error + {Key '#1' has been overriden by a series}% + {Change the series name and/or deactivate series=override}}% + \global\@namedef{enitkv@enumitem@#1@default}{}% + \fi + \def\enit@series{#1}} + +\enitkv@key{}{series}{% + \enit@checkseries{series}} + +\def\enitkv@enumitem@resume#1{% + \edef\enit@series{#1}% + \@nameuse{enit@resume@series@#1}\relax} + +\def\enitkv@enumitem@resume@default{% + \@nameuse{enit@resume@\@currenvir}\relax} + +\@namedef{enitkv@enumitem-resume@resume*}#1{% + \enit@checkseries@m + \let\enit@resuming\tw@ + \edef\enit@series{#1}% + \enit@ifunset{enit@resumekeys@series@#1}% + {\enit@noserieserror{#1}}% + {\expandafter\let\expandafter\enit@resumekeys + \csname enit@resumekeys@series@#1\endcsname}} + +\@namedef{enitkv@enumitem-resume@resume*@default}{% + \let\enit@resuming\thr@@ + \expandafter\let\expandafter\enit@resumekeys + \csname enit@resumekeys@\@currenvir\endcsname + \@nameuse{enit@resume@\@currenvir}\relax} + +\enitkv@key{}{resume*}[]{% + \enit@checkseries{resume*}} + +\newcommand\restartlist[1]{% + \enit@ifunset{end#1}% + {\enit@error{Undefined list '#1'}% + {No list has been defined with that name.}}% + {\expandafter\let + \csname enit@resume@#1\endcsname\@empty}} + +\enitkv@key{}{start}[\@ne]{% + \setcounter{\@listctr}{#1}% + \advance\@nameuse{c@\@listctr}\m@ne} + +% Penalties +% ========= + +\enitkv@key{}{beginpenalty}{% + \@beginparpenalty#1\relax} + +\enitkv@key{}{midpenalty}{% + \@itempenalty#1\relax} + +\enitkv@key{}{endpenalty}{% + \@endparpenalty#1\relax} + +% Font/Format +% =========== + +\enitkv@key{}{format}{% + \def\enit@format{#1}} + +\enitkv@key{}{font}{% + \def\enit@format{#1}} + +% Description styles +% ================== + +\enitkv@key{}{style}[normal]{% + \enit@ifunset{enit@style@#1}% + {\enit@checkerror{style}{#1}}% + {\enit@nextlinefalse + \enit@boxdescfalse + \@nameuse{enit@style@#1}% + \edef\enit@descstyle{\enit@noexcs{enit@#1style}}}} + +\def\enit@style@standard{% + \enit@boxdesctrue + \enit@calcset\itemindent\enit@iv!} + +\let\enit@style@normal\enit@style@standard + +\def\enit@style@unboxed{% + \enit@calcset\itemindent\enit@iv!} + +\def\enit@style@sameline{% + \enit@calcset\labelwidth\@ne!} + +\def\enit@style@multiline{% + \enit@align@parleft + \enit@calcset\labelwidth\@ne!} + +\def\enit@style@nextline{% + \enit@nextlinetrue + \enit@calcset\labelwidth\@ne!} + +% Labels and refs +% =============== + +% Aligment +% -------- + +\enitkv@key{}{align}{% + \enit@ifunset{enit@align@#1}% + {\enit@checkerror{align}{#1}}% + {\csname enit@align@#1\endcsname}} + +% \nobreak for unboxed label with color. See below. + +\newcommand\SetLabelAlign[2]{% + \enit@toks{#2}% + \expandafter\edef\csname enit@align@#1\endcsname + {\def\noexpand\enit@align####1{\nobreak\the\enit@toks}}} + +\def\enit@align@right{% + \def\enit@align##1{\nobreak\hss\llap{##1}}} + +\def\enit@align@left{% + \def\enit@align##1{\nobreak##1\hfil}} + +\def\enit@align@parleft{% + \def\enit@align##1{% + \nobreak + \strut\smash{\parbox[t]\labelwidth{\raggedright##1}}}} + +% \enit@ref has three possible definitions: +% (1) \relax, if there is neither label nor ref (ie, use +% LaTeX settings). +% (2) set ref to @itemlabel, if there is label but not ref +% (3) set ref to ref, if there is ref (with or without label) + +\enitkv@key{}{label}{% + \expandafter\def\@itemlabel{#1}% + \def\enit@ref{\expandafter\enit@reflabel\@itemlabel\z@}} + +\enitkv@key{}{label*}{% + \ifnum\enit@depth=\@ne + \expandafter\def\@itemlabel{#1}% + \else % no level 0 + \advance\enit@depth\m@ne + \enit@toks{#1}% + \expandafter\edef\@itemlabel{% + \enit@noexcs{label\enit@prevlabel}% + \the\enit@toks}% + \advance\enit@depth\@ne + \fi + \def\enit@ref{\expandafter\enit@reflabel\@itemlabel\z@}} + +% ref is set by label, except if there is an explicit ref in the same +% hierarchy level. Explicit refs above the current hierarchy level are +% overriden by label (besides ref), too. Since an explicit ref has +% preference, it's delayed. + +\enitkv@key{}{ref}{% + \g@addto@macro\enit@delayedkeys{,ref=#1}} + +\enitkv@key{-delayed}{ref}{% + \def\enit@ref{\enit@reflabel{#1}\@ne}} + +% #2=0 don't "normalize" (ie, already normalized) +% =1 "normalize" (in key ref) +% Used thru \enit@ref + +\def\enit@reflabel#1#2{% + \ifnum\enit@depth=\@ne\else % no level 0 + \advance\enit@depth\@ne + \@namedef{p@\@enumctr}{}% Don't accumulate labels + \advance\enit@depth\m@ne + \fi + \ifcase#2% + \@namedef{the\@enumctr}{{#1}}% + \else + \enit@normlabel{\csname the\@enumctr\endcsname}{#1}% + \fi} + +% \xxx* in counters (refstar) and widest (calcdef) +% ------------------------------------------------ +% \enit@labellist contains a list of +% \enit@elt{widest}\count\@count\enit@sc@@count +% \enit@elt is either \enit@getwidth or \enit@refstar, defined +% below +% The current implementation is sub-optimal -- labels are stored in +% labellist, counters defined again when processing labels, and +% modifying it is almost impossible. + +\let\enit@labellist\@empty + +\newcommand\AddEnumerateCounter{% + \@ifstar\enit@addcounter@s\enit@addcounter} + +\def\enit@addcounter#1#2#3{% + \enit@toks\expandafter{% + \enit@labellist + \enit@elt{#3}}% + \edef\enit@labellist{% + \the\enit@toks + \enit@noexcs{\expandafter\@gobble\string#1}% + \enit@noexcs{\expandafter\@gobble\string#2}% + \enit@noexcs{enit@sc@\expandafter\@gobble\string#2}}} + +\def\enit@addcounter@s#1#2#3{% + \enit@addcounter{#1}{#2}% + {\@nameuse{enit@sc@\expandafter\@gobble\string#2}{#3}}} + +% The 5 basic counters: + +\AddEnumerateCounter\arabic\@arabic{0} +\AddEnumerateCounter\alph\@alph{m} +\AddEnumerateCounter\Alph\@Alph{M} +\AddEnumerateCounter\roman\@roman{viii} +\AddEnumerateCounter\Roman\@Roman{VIII} + +% Inline lists +% ============ +% +% Labels +% ------ + +\enitkv@key{}{itemjoin}{% + \def\enit@itemjoin{#1}} + +\enitkv@key{}{itemjoin*}{% + \def\enit@itemjoin@s{#1}} + +\enitkv@key{}{afterlabel}{% + \def\enit@afterlabel{#1}} + +% Mode +% ---- + +\enitkv@key{}{mode}{% + \enit@ifunset{enit@mode#1}% + {\enit@checkerror{mode}{#1}}% + {\csname enit@mode#1\endcsname}} + +\let\enit@modeboxed\enit@boxmodetrue +\let\enit@modeunboxed\enit@boxmodefalse + +% Short Labels +% ============ + +\let\enit@marklist\@empty + +% shorthand, expansion: + +\newcommand\SetEnumerateShortLabel[2]{% + \let\enit@a\@empty + \def\enit@elt##1##2{% + \def\enit@b{#1}\def\enit@c{##1}% + \ifx\enit@b\enit@c\else + \expandafter\def\expandafter\enit@a\expandafter{% + \enit@a + \enit@elt{##1}{##2}}% + \fi}% + \enit@marklist + \expandafter\def\expandafter\enit@a\expandafter{% + \enit@a + \enit@elt{#1}{#2}}% + \let\enit@marklist\enit@a} + +\SetEnumerateShortLabel{a}{\alph*} +\SetEnumerateShortLabel{A}{\Alph*} +\SetEnumerateShortLabel{i}{\roman*} +\SetEnumerateShortLabel{I}{\Roman*} +\SetEnumerateShortLabel{1}{\arabic*} + +% This is called \enit@first one,two,three,\@nil\@@nil. If there +% are just one element #2 is \@nil, otherwise we have to remove +% the trailing ,\@nil with enit@first@x +% Called with the keys in \enit@c +% Returns enit@toks + +\def\enit@first#1,#2\@@nil{% + \in@{=}{#1}% Quick test, if contains =, it's key=value + \ifin@\else + \enitkv@@sp@def\enit@a{#1}% + \enit@ifunset{enitkv@enumitem@\enit@meaning\enit@a}% + {\ifnum\enit@type=\z@ + \def\enit@elt{\enit@replace\enit@a}% + \enit@marklist % Returns \enit@toks + \else + \enit@toks{#1}% + \fi + \ifx\@nil#2% + \ifx,#1,\else + \edef\enit@c{label=\the\enit@toks}% + \fi + \else + \@temptokena\expandafter{\enit@first@x#2}% + \edef\enit@c{label=\the\enit@toks,\the\@temptokena}% + \fi}% + {}% + \fi + \enit@toks\expandafter{\enit@c}} + +\def\enit@first@x#1,\@nil{#1} + +\def\enit@replace#1#2#3{% + \enit@toks{}% + \def\enit@b##1#2##2\@@nil{% + \ifx\@nil##2% + \addto@hook\enit@toks{##1}% + \else + \edef\enit@a{\the\enit@toks}% + \ifx\enit@a\@empty\else + \enit@error{Extra short label ignored}% + {There are more than one short label}% + \fi + \addto@hook\enit@toks{##1#3}% + \enit@b##2\@@nil + \fi}% + \expandafter\enit@b#1#2\@nil\@@nil + \edef#1{\the\enit@toks}} + +% Pre and post code +% ================= + +\enitkv@key{}{before}{% + \def\enit@before{#1}} + +\enitkv@key{}{before*}{% + \expandafter\def\expandafter\enit@before\expandafter + {\enit@before#1}} + +\enitkv@key{}{after}{% + \def\enit@after{#1}} + +\enitkv@key{}{after*}{% + \expandafter\def\expandafter\enit@after\expandafter + {\enit@after#1}} + +\enitkv@key{}{first}{% + \def\enit@keyfirst{#1}} + +\enitkv@key{}{first*}{% + \expandafter\def\expandafter\enit@keyfirst\expandafter + {\enit@keyfirst#1}} + +% Miscelaneous keys +% ================ + +\enitkv@key{}{nolistsep}[true]{% + \partopsep=\z@skip + \topsep=\z@ plus .1pt + \itemsep=\z@skip + \parsep=\z@skip} + +\enitkv@key{}{nosep}[true]{% + \partopsep=\z@skip + \topsep=\z@skip + \itemsep=\z@skip + \parsep=\z@skip} + +\enitkv@key{}{noitemsep}[true]{% + \itemsep=\z@skip + \parsep=\z@skip} + +\enitkv@key{}{wide}[\parindent]{% + \enit@align@left + \leftmargin\z@ + \labelwidth\z@ + \enit@setlength\labelindent{#1}% + \listparindent\labelindent + \enit@calcset\itemindent\enit@iv!} + +% The following is deprecated in favour of wide: + +\enitkv@key{}{fullwidth}[true]{% + \leftmargin\z@ + \labelwidth\z@ + \def\enit@align##1{\hskip\labelsep##1}} + +% "Abstract" layer +% ================ +% +% Named values +% ------------ + +\newcommand\SetEnumitemValue[2]{% Implicit #3 + \enit@ifunset{enit@enitkv@#1}% + {\enit@ifunset{enitkv@enumitem@#1}% + {\enit@error{Wrong key '#1' in \string\SetEnumitemValue}% + {Perhaps you have misspelled it}}{}% + \expandafter\let\csname enit@enitkv@#1\expandafter\endcsname + \csname enitkv@enumitem@#1\endcsname}{}% + \@namedef{enitkv@enumitem@#1}##1{% + \def\enit@a{##1}% + \enit@ifunset{enit@enitkv@#1@\enit@meaning\enit@a}% + {\@nameuse{enit@enitkv@#1}{##1}}% + {\@nameuse{enit@enitkv@#1\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter + {\csname enit@enitkv@#1@##1\endcsname}}{}}% + \@namedef{enit@enitkv@#1@#2}} + +% Defining keys +% ------------- + +\newcommand\SetEnumitemKey[2]{% + \enit@ifunset{enitkv@enumitem@#1}% + {\enitkv@key{}{#1}[]{\enitkv@setkeys{enumitem}{#2}}}% + {\enit@error{Duplicated key '#1' in \string\SetEnumitemKey}% + {There already exists a key with that name}}} + +% +=============================+ +% | PROCESSING KEYS | +% +=============================+ +% +% Set keys +% ======== +% +% Default definition. Modified below with package option 'sizes'. + +\def\enit@setkeys#1{% + \enit@ifunset{enit@@#1}{}% + {\expandafter\expandafter\expandafter + \enit@setkeys@i\csname enit@@#1\endcsname\@@}} + +% The following is used directly in resumeset: + +\def\enit@setkeys@i#1\@@{% + \let\enit@delayedkeys\@empty + \enit@shl{#1}% is either \enit@toks or returns it + \expandafter\enit@setkeys@ii\the\enit@toks\@@} + +\def\enit@setkeys@ii#1\@@{% + \enitkv@setkeys{enumitem}{#1}% + \enit@toks\expandafter{\enit@delayedkeys}% + \edef\enit@a{% + \noexpand\enitkv@setkeys{enumitem-delayed}{\the\enit@toks}}% + \enit@a} + +% Handling * and ! values +% ======================= +% +% \@gobbletwo removes \c from \c@counter. + +\def\enit@getwidth#1#2#3#4{% + \let#4#3% + \def#3##1{% + \enit@ifunset{enit@widest\expandafter\@gobbletwo\string##1}% if no widest=key + {#1}% + {\csname enit@widest\expandafter\@gobbletwo\string##1\endcsname{#4}}}} + +\def\enit@valueerror#1{\z@ % if after an assignment, but doesn't catch \ifnum + \enit@error{No default \string\value\space for '#1'}% + {You can provide one with widest*}}% + +\let\enit@values\@empty + +\def\enit@calcwidth{% + \ifenit@calcwidest + \ifcase\enit@type % ie, enum + \enit@ifunset{enit@cw@\@enumctr}% + {\@namedef{enit@cv@\@enumctr}{\enit@valueerror\@enumctr}}% + {\edef\enit@values{% + \enit@values + \@nameuse{c@\@enumctr}\@nameuse{enit@cw@\@enumctr}\relax}% + \expandafter + \edef\csname enit@cv@\@enumctr\endcsname + {\@nameuse{c@\@enumctr}}}% + \begingroup + \enit@values + \def\value##1{\csname enit@cv@##1\endcsname}% + \let\enit@elt\enit@getwidth + \enit@labellist + \settowidth\labelwidth{\@itemlabel}% + \xdef\enit@a{\labelwidth\the\labelwidth\relax}% + \endgroup + \enit@a + \or % ie, item + \ifx\enit@widest@\relax + \settowidth\labelwidth{\@itemlabel}% + \else + \settowidth\labelwidth{\enit@widest@}% + \fi + \else % ie, desc + \ifx\enit@widest@\relax + \settowidth\labelwidth{\@itemlabel}% + \else + \settowidth\labelwidth{\makelabel{\enit@widest@}}% + \fi + \advance\labelwidth-\labelsep + \fi + \fi + \advance\dimen@-\labelwidth} + +\def\enit@calcleft{% + \dimen@\leftmargin + \advance\dimen@\itemindent + \advance\dimen@-\labelsep + \advance\dimen@-\labelindent + \ifcase\enit@calc % = 0 = labelindent + \enit@calcwidth + \advance\labelindent\dimen@ + \or % = 1 = labelwidth, so no \enit@calcwidth + \labelwidth\dimen@ + \or % = 2 = labelsep + \enit@calcwidth + \advance\labelsep\dimen@ + \or % = 3 = leftmargin + \enit@calcwidth + \advance\leftmargin-\dimen@ + \or % = 4 =itemindent + \enit@calcwidth + \advance\itemindent-\dimen@ + \fi} + +\def\enit@negwidth{% + \ifdim\labelwidth<\z@ + \PackageWarning{enumitem}% + {Negative labelwidth. This does not make much\MessageBreak + sense,}% + \fi} + +% "Normalizing" labels +% ==================== +% +% Replaces \counter* by \counter{level} (those in \enit@labellist). +% +% #1 is either \csname...\endcsmame or the container \@itemlabel -- +% hence \expandafter + +\def\enit@refstar@i#1#2{% + \if*#2\@empty + \noexpand#1{\@enumctr}% + \else + \noexpand#1{#2}% + \fi}% + +\def\enit@refstar#1#2#3#4{% + \def#2{\enit@refstar@i#2}% + \def#3{\enit@refstar@i#3}} + +\def\enit@normlabel#1#2{% + \begingroup + \def\value{\enit@refstar@i\value}% + \let\enit@elt\enit@refstar + \enit@labellist + \protected@xdef\enit@a{{#2}}% Added braces as \ref is in the + \endgroup + \expandafter\let#1\enit@a} % global scope. + +% Preliminary settings and default values +% ======================================= + +\def\enit@prelist#1#2#3{% + \let\enit@type#1% + \def\enit@depth{#2}% + \edef\enit@prevlabel{#3\romannumeral#2}% + \advance#2\@ne} + +\newcount\enit@count@id + +\def\enit@tagid{% + \global\advance\enit@count@id\@ne + \edef\EnumitemId{\number\enit@count@id}} + +\def\enit@preset#1#2#3{% + \enit@tagid + \enit@sepfrommarginfalse + \enit@calcwidestfalse + \let\enit@widest@\relax + \let\enit@resuming\z@ + \let\enit@series\relax + \enit@boxmodetrue + \def\enit@itemjoin{ }% + \let\enit@itemjoin@s\relax + \let\enit@afterlabel\nobreakspace + \let\enit@before\@empty + \let\enit@after\@empty + \let\enit@keyfirst\@empty + \let\enit@format\@firstofone % and NOT empty + \let\enit@ref\relax + \labelindent\z@skip + \ifnum\@listdepth=\@ne + \enit@outerparindent\parindent + \else + \parindent\enit@outerparindent + \fi + \enit@setkeys{list}% + \enit@setkeys{list\romannumeral\@listdepth}% + \enit@setkeys{#1}% + \enit@setkeys{#1\romannumeral#2}% + \enit@setresume{#3}} + +% keyval "error" in enumitem-resume: all undefined keys (ie, all +% except resume*) are ignored, but <series> is treated like +% resume*=<series> + +\def\enitkv@err@a#1{% + \enit@ifunset{enit@resumekeys@series@\@tempa}{}% + {\@nameuse{enitkv@enumitem-resume@resume*\expandafter}% + \expandafter{\@tempa}}} + +% keyval "error" in the optional argument: all undefined keys are +% passed to the keyval error, but <series> is ignored (already +% processed in enumitem-resume) + +\def\enitkv@err@b#1{% + \enit@ifunset{enit@resumekeys@series@\@tempa}% + {\enit@savekverr{#1}}% + {}} + +% Process keys in optional argument: + +\def\enit@setresume#1{% + \enit@shl{#1}% Returns enit@toks + \edef\enit@savekeys{\the\enit@toks}% + \let\enit@savekverr\enitkv@errx + \let\enitkv@errx\enitkv@err@a + \edef\enit@b{% + \noexpand\enitkv@setkeys{enumitem-resume}{\the\enit@toks}}% + \enit@b + \let\enitkv@errx\enitkv@err@b + \ifcase\enit@resuming\or\or % = 2, resume* series + \expandafter + \enit@setkeys@i\enit@resumekeys,resume=\enit@series\@@ + \or % = 3 + \expandafter + \enit@setkeys@i\enit@resumekeys,resume\@@ + \fi + \expandafter\enit@setkeys@i\enit@savekeys\@@ + \let\enitkv@errx\enit@savekverr} + +% Handling <> sytax for font sizes +% ================================ +% The following code is based on LaTeX (\DeclareFontShape). Only the +% code for <> is preserved (no functions), and a default value can be +% set before the first <>. In addition, here single values take +% precedende over ranges. The original work is by the LaTeX Team, +% under license LPPL. + +\def\enit@ifnot@nil#1{% + \def\enit@a{#1}% + \ifx\enit@a\@nnil + \expandafter\@gobble + \else + \expandafter\@firstofone + \fi} + +\def\enit@remove@to@nnil#1\@nnil{} +\def\enit@remove@angles#1>{\enit@simple@size} + +\def\enit@simple@size#1<{% + \if<#1<% + \expandafter\enit@remove@angles + \else + \def\enit@c{#1}% + \expandafter\enit@remove@to@nnil + \fi} + +\def\enit@extractrange#1<#2>{% + \ifx\enit@c\relax + \def\enit@c{#1}% + \fi + \enit@isrange#2->\@nil#2>} + +\def\enit@isrange#1-#2\@nil{% + \if>#2% + \expandafter\enit@check@single + \else + \expandafter\enit@check@range + \fi} + +\def\enit@check@range#1-#2>#3<#4\@nnil{% + \enit@ifnot@nil{#3}{% + \def\enit@b{\enit@extractrange<#4\@nnil}% + \upper@bound=% + \enit@ifunset{enit@sizefor@#2}{0#2\p@}{\@nameuse{enit@sizefor@#2}\p@}% + %%% usar count@ + \ifdim\upper@bound=\z@ \upper@bound\maxdimen \fi + \ifdim\f@size\p@<\upper@bound + \lower@bound=% + \enit@ifunset{enit@sizefor@#1}{0#1\p@}{\@nameuse{enit@sizefor@#1}\p@}% + \ifdim\f@size\p@<\lower@bound + \else + \enit@simple@size#3<#4\@nnil + \fi + \fi + \enit@b}} + +\def\enit@check@single#1>#2<#3\@nnil{% + \def\enit@b{\enit@extractrange<#3\@nnil}% + \ifdim\f@size\p@= + \enit@ifunset{enit@sizefor@#1}{0#1\p@}{\@nameuse{enit@sizefor@#1}\p@}% + \enit@simple@size#2<#3\@nnil + \let\enit@d\enit@c + \fi + \enit@b} + +\def\enit@try@size@range#1{% + \def\enit@a{#1}% + \let\enit@c\relax % last in range + \let\enit@d\relax % single + \expandafter\enit@extractrange\enit@a <-*>\@nil<\@nnil + \ifx\enit@d\relax\else\let\enit@c\enit@d\fi} + +% \enit@setlength is defined in the options section + +% This ends the code adapted from latex (under LPPL). + +\def\SetEnumitemSize#1#2{% + {\let\selectfont\relax + #2% + \expandafter\xdef\csname enit@sizefor@#1\endcsname{\f@size}}} + +\SetEnumitemSize{script}\scriptsize +\SetEnumitemSize{tiny}\tiny +\SetEnumitemSize{footnote}\footnotesize +\SetEnumitemSize{small}\small +\SetEnumitemSize{normal}\normalsize +\SetEnumitemSize{large}\large +\SetEnumitemSize{Large}\Large +\SetEnumitemSize{LARGE}\LARGE +\SetEnumitemSize{huge}\huge +\SetEnumitemSize{Huge}\Huge + +% +=============================+ +% | LIST TYPES | +% +=============================+ +% +% Displayed lists +% =============== +% #1 #2 implicit + +\def\enit@dylist{% + \enit@align@right + \list} + +\def\enit@endlist{% + \enit@after + \endlist + \ifx\enit@series\relax\else % discards resume*, too + \ifnum\enit@resuming=\@ne % ie, series= + \enit@setresumekeys{series@\enit@series}\global\global + \else % ie, resume=, resume*= (save count, but not keys) + \enit@setresumekeys{series@\enit@series}\@gobblefour\global + \fi + \enit@afterlist + \fi + \ifnum\enit@resuming=\thr@@ % ie, resume* list (save count only) + \enit@setresumekeys\@currenvir\@gobblefour\global + \else + \enit@setresumekeys\@currenvir\@empty\@empty + \fi + \aftergroup\enit@afterlist} + +% #1 = either \@currenvir or series@<series> +% #2(keys) #3(counter) are \global, \@gobblefour or \@empty + +\def\enit@setresumekeys#1#2#3{% + \enit@toks\expandafter{\enit@savekeys}% + \xdef\enit@afterlist{% + #2\def\enit@noexcs{enit@resumekeys@#1}{\the\enit@toks}% + \ifnum\enit@type=\z@ % ie, enum + #3\def\enit@noexcs{enit@resume@#1}{% + \csname c@\@listctr\endcsname + \the\csname c@\@listctr\endcsname}% + \fi}} + +% Inline lists +% ============ + +% Definition of \@trivlist inside inline lists. So, when +% \@trivlist is found in any displayed list (including quote, +% center, verbatim...) the default \@item is restored. + +\def\enit@intrivlist{% + \enit@changed@itemfalse + \let\@item\enit@outer@item + \let\par\@@par + \let\@trivlist\enit@outer@triv + \@trivlist} + +% Keep track of \@item and \item changes + +\newif\ifenit@changed@item +\enit@changed@itemfalse + +\newif\ifenit@changeditem +\enit@changeditemfalse + +% List +% ---- + +% Arguments, as before: +% \enitdp@<name>, <name>, <max-depth>, <format> +% About @newlist, see @initem. + +\def\enit@inlist#1#2{% + \ifnum\@listdepth>\enit@listdepth\relax + \@toodeep + \else + \global\advance\@listdepth\@ne + \fi + \let\enit@align\@firstofone + \def\@itemlabel{#1}% + \@nmbrlistfalse + \ifenit@changed@item\else + \enit@changed@itemtrue + \let\enit@outer@triv\@trivlist + \let\@trivlist\enit@intrivlist + \@setpar\@empty + \let\enit@outer@item\@item + \fi + #2\relax + \global\@newlisttrue + \ifenit@boxmode + \ifenit@changeditem\else + \enit@changeditemtrue + \let\enit@outeritem\item + \fi + \let\@item\enit@boxitem + \else + \let\@item\enit@noboxitem + \ifx\enit@itemjoin@s\relax\else + \PackageWarning{enumitem}% + {itemjoin* discarded in mode unboxed\MessageBreak}% + \fi + \fi + \let\enit@calcleft\relax + \let\enit@afteritem\relax + \ifenit@boxmode + \global\setbox\enit@inbox\hbox\bgroup\color@begingroup + \let\item\enit@endinbox + \fi + \ignorespaces} + +\def\enit@endinlist{% + \ifenit@boxmode + \unskip + \xdef\enit@afteritem{% + \ifhmode\spacefactor\the\spacefactor\relax\fi}% + \color@endgroup + \egroup + \ifdim\wd\enit@inbox=\z@ + \enit@itemerror + \else + \ifenit@noinitem\else + \ifhmode\unskip\fi + \enit@ifunset{enit@itemjoin@s}% + {\enit@itemjoin}% + {\enit@itemjoin@s}% + \fi + \unhbox\@labels + \enit@afterlabel + \unhbox\enit@inbox + \enit@afteritem + \fi + \else + \unskip + \if@newlist + \enit@itemerror + \fi + \fi + \enit@after + \global\advance\@listdepth\m@ne + \global\@inlabelfalse + \if@newlist + \global\@newlistfalse + \@noitemerr + \fi + \ifx\enit@series\relax\else % discards resume* list, too + \ifnum\enit@resuming=\@ne % ie, series + \enit@setresumekeys{series@\enit@series}\global\global + \else % ie, resume, resume* (save count, but not keys) + \enit@setresumekeys{series@\enit@series}\@gobblefour\global + \fi + \enit@afterlist + \fi + \ifnum\enit@resuming=\thr@@ % ie, resume* list (save count only) + \enit@setresumekeys\@currenvir\@gobblefour\global + \else + \enit@setresumekeys\@currenvir\@empty\@empty + \fi + \aftergroup\enit@afterlist} + +% \@item: unboxed +% --------------- + +\def\enit@noboxitem[#1]{% + \if@newlist + \leavevmode % ships pending labels out + \global\@newlistfalse + \else + \ifhmode + \unskip + \enit@itemjoin + \else + \noindent + \fi + \fi + \if@noitemarg + \@noitemargfalse + \if@nmbrlist + \refstepcounter{\@listctr}% after \unskip (hyperref) + \fi + \fi + \mbox{\makelabel{#1}}% + \enit@afterlabel + \ignorespaces} + +% \@item: boxed +% ------------ +% +% We don't want \item to be executed locally, because it sets a flag +% (and hyperref adds another flag, too). So, we redefine it inside +% the box to \enit@endinbox which ends the box and then use the actual +% (outer) \item. labels are stored in another box, to detect empty +% boxes, ie, misplaced \item's. Note the 2nd \item ends collecting +% the 1st item and ships it out, while the 3rd \item ends collecting +% the 2nd item, puts the itemjoin and then ships the 2nd item out. +% The flag enit@noinitem keeps track of that. + +\newif\ifenit@noinitem + +\def\enit@endinbox{% + \unskip + \xdef\enit@afteritem{% + \ifhmode\spacefactor\the\spacefactor\relax\fi}% + \color@endgroup + \egroup + \enit@outeritem} + +\def\enit@boxitem[#1]{% + \if@newlist + \global\@newlistfalse + \ifdim\wd\enit@inbox>\z@ + \enit@itemerror + \fi + \enit@noinitemtrue + \leavevmode % ships pending labels out + \else + \ifdim\wd\enit@inbox=\z@ + \enit@itemerror + \else + \ifenit@noinitem + \enit@noinitemfalse + \else + \ifhmode\unskip\fi + \enit@itemjoin + \fi + \unhbox\@labels + \enit@afterlabel + \unhbox\enit@inbox + \enit@afteritem + \fi + \fi + \if@noitemarg + \@noitemargfalse + \if@nmbrlist + \refstepcounter{\@listctr}% + \fi + \fi + \sbox\@labels{\makelabel{#1}}% + \let\enit@afteritem\relax + \setbox\enit@inbox\hbox\bgroup\color@begingroup + \let\item\enit@endinbox + \hskip1sp % in case the first thing is \label + \ignorespaces} + +% Pause item +% ---------- +% +% To do. +% +% The three types +% =============== +% +% enumerate and enumerate* +% ------------------------ +% +% The following has 4 arguments, which in enumerate are: +% \@enumdepth, enum, \thr@@, <format>. +% In user defined environments they are: +% \enitdp@<name>, <name>, <max-depth>, <format> + +\def\enit@enumerate{% + \let\enit@list\enit@dylist + \enit@enumerate@i} + +\@namedef{enit@enumerate*}{% + \let\enit@list\enit@inlist + \enit@enumerate@i} + +\def\enit@enumerate@i#1#2#3#4{% + \ifnum#1>#3\relax + \enit@toodeep + \else + \enit@prelist\z@{#1}{#2}% + \edef\@enumctr{#2\romannumeral#1}% + \expandafter + \enit@list + \csname label\@enumctr\endcsname + {\usecounter\@enumctr + \let\enit@calc\z@ + \def\makelabel##1{\enit@align{\enit@format{##1}}}% + \enit@preset{#2}{#1}{#4}% + \enit@normlabel\@itemlabel\@itemlabel + \enit@ref + \enit@calcleft + \enit@before + \enit@negwidth}% + \enit@keyfirst + \fi} + +\let\enit@endenumerate\enit@endlist +\@namedef{enit@endenumerate*}{\enit@endinlist} + +% itemize and itemize* +% -------------------- +% +% The following has 4 arguments, which in itemize are: +% \@itemdepth, item, \thr@@, <format>. +% In user defined environments they are: +% \enitdp@<name>, <name>, <max-depth>, <format> + +\def\enit@itemize{% + \let\enit@list\enit@dylist + \enit@itemize@i} + +\@namedef{enit@itemize*}{% + \let\enit@list\enit@inlist + \enit@itemize@i} + +\def\enit@itemize@i#1#2#3#4{% + \ifnum#1>#3\relax + \enit@toodeep + \else + \enit@prelist\@ne{#1}{#2}% + \edef\@itemitem{label#2\romannumeral#1}% + \expandafter + \enit@list + \csname\@itemitem\endcsname + {\let\enit@calc\z@ + \def\makelabel##1{\enit@align{\enit@format{##1}}}% + \enit@preset{#2}{#1}{#4}% + \enit@calcleft + \enit@before + \enit@negwidth}% + \enit@keyfirst + \fi} + +\let\enit@enditemize\enit@endlist +\@namedef{enit@enditemize*}{\enit@endinlist} + +% description and description* +% ---------------------------- +% +% Make sure \descriptionlabel exists: + +\providecommand*\descriptionlabel[1]{% + \hspace\labelsep + \normalfont\bfseries#1} + +\@namedef{enit@description*}{% + \let\enit@list\enit@inlist + \enit@description@i} + +\def\enit@description{% + \let\enit@list\enit@dylist + \enit@description@i} + +\def\enit@description@i#1#2#3#4{% + \ifnum#1>#3\relax + \enit@toodeep + \else + \enit@list{}% + {\let\enit@type\tw@ + \advance#1\@ne + \labelwidth\z@ + \enit@align@left + \let\makelabel\descriptionlabel + \enit@style@standard + \enit@preset{#2}{#1}{#4}% + \enit@calcleft + \let\enit@svlabel\makelabel + \def\makelabel##1{% + \labelsep\z@ + \ifenit@boxdesc + \enit@svlabel{\enit@align{\enit@format{##1}}}% + \else + \nobreak + \enit@svlabel{\enit@format{##1}}% + \aftergroup\enit@postlabel + \fi}% + \enit@before + \enit@negwidth}% + \enit@keyfirst + \fi} + +\let\enit@enddescription\enit@endlist +\@namedef{enit@enddescription*}{\enit@endinlist} + +% trivlist +% ======== + +\def\enit@trivlist{% + \let\enit@type\tw@ + \parsep\parskip + \csname @list\romannumeral\the\@listdepth\endcsname + \@nmbrlistfalse + \enit@tagid + \enit@setglobalkeys % ie, list and list<num> + \enit@setkeys{trivlist}% + \enit@setkeys{trivlist\romannumeral\@listdepth}% + \@trivlist + \labelwidth\z@ + \leftmargin\z@ + \itemindent\z@ + \let\@itemlabel\@empty + \def\makelabel##1{##1}} + +% Description styles +% ================== +% +% the next definition is somewhat tricky because labels are boxed. +% That's fine when the label is just placed at the begining of a line +% of text, but when the box is placed without horizontal material, +% leading is killed. So, we need change somehow \box to \unhbox, but +% I don't want to modify \@item. The code below presumes \@item has +% not been changed and arguments gobble the part setting \@labels, +% which is replaced by a new one. +% +% The default value in description is itemindent=!, but some styles +% (those whose item text begin at a fixed place, ie, nextline, +% multiline and sameline) change it to labelwidth=!. +% +% We must be careful with the group and the whatsit added by color to +% boxes. Alignment is applied here and some adjustments in skips are +% necessary to get proper line breaks (including a \nobreak at the +% beginning of \enit@align, ie, after the first whatsit, see above). +% To "pass" the inner group added by color to the box, \enit@postlabel +% ckecks if the following is }. ie, \egroup -- if not, the box has +% not reached yet its end. + +\def\enit@postlabel{% + \@ifnextchar\egroup + {\aftergroup\enit@postlabel}% + {\enit@postlabel@i}} + +\def\enit@postlabel@i#1#2#3#4#5{% + \def\enit@lblpenalty{\penalty\z@\hskip\skip@}% + \ifenit@nextline + \ifdim\wd\@tempboxa>\labelwidth + \def\enit@lblpenalty{\newline\@nobreaktrue}% + \fi + \fi + \everypar{% + \@minipagefalse + \global\@newlistfalse + \if@inlabel + \global\@inlabelfalse + {\setbox\z@\lastbox + \ifvoid\z@ + \kern-\itemindent + \fi}% + \unhbox\@labels + \skip@\lastskip % Save last \labelsep + \unskip % Remove it + \enit@lblpenalty % Restore it, after penalty + \fi + \if@nobreak + \@nobreakfalse + \clubpenalty\@M + \else + \clubpenalty\@clubpenalty + \everypar{}% + \fi}% + \def\enit@a{#1#2#3#4}% + \def\enit@b{\global\setbox\@labels\hbox}% + \ifx\enit@a\enit@b\else + \enit@error{Non standard \string\item}% + {A class or a package has redefined \string\item\MessageBreak + and I do not know how to continue}% + \fi + \global\setbox\@labels\hbox{% + \unhbox\@labels + \hskip\itemindent + \hskip-\labelwidth + \hskip-\labelsep + \ifdim\wd\@tempboxa>\labelwidth + \enit@align{\unhbox\@tempboxa}\unskip % Removes (typically) \hfil + \else + \leavevmode\hbox to\labelwidth{\enit@align{\unhbox\@tempboxa}}% + \fi + \hskip\labelsep}} + +% +=============================+ +% | (RE)DEFINING LISTS | +% +=============================+ +% +% Set keys/values +% =============== +% Remember \romannumeral0 expands to nothing. +% #1 = list name, #2 = level, #3 = flag if star, #4 = keys/values + +\let\enit@keys@sizes\relax + +\def\enit@saveset#1#2#3#4{% + \setcounter{enit@cnt}{#2}% + \ifx\enit@forsize\@empty + \ifcase#3% + \expandafter + \def\csname enit@@#1\romannumeral\c@enit@cnt\endcsname{#4}% + \or + \expandafter\let\expandafter\enit@b + \csname enit@@#1\romannumeral\c@enit@cnt\endcsname + \ifx\enit@b\relax + \let\enit@b\@empty + \fi + \expandafter\def + \csname enit@@#1\romannumeral\c@enit@cnt\expandafter\endcsname + \expandafter{\enit@b,#4}% + \fi + \else + \ifcase#3% + \enit@ifunset{enit@@#1\romannumeral\c@enit@cnt}% + {\expandafter\let + \csname enit@@#1\romannumeral\c@enit@cnt\endcsname\@empty}% + {}% + \expandafter\let\expandafter\enit@b + \csname enit@@#1\romannumeral\c@enit@cnt @@sizes\endcsname + \ifx\enit@b\relax + \let\enit@b\@empty + \fi + \toks@\expandafter{\enit@b}% + \edef\enit@b{\the\toks@\enit@forsize\enit@keys@sizes}% + \expandafter\def + \csname enit@@#1\romannumeral\c@enit@cnt @@sizes\expandafter\endcsname + \expandafter{\enit@b{#4}}% + \else + \enit@error{* and \string<\string> are not compatible}% + {Use either * or angles, but not both.}% + \fi + \fi} + +% TODO: more robust tests (catch wrong key names, but not easy) + +% Internally, LaTeX uses a short name for enumerate (enum) +% and itemize (item). To be consistent with this convention, +% a couple of macros provide a "translation". I'm not very +% happy with the current implementation. + +\def\enit@shortenumerate{enum} +\def\enit@shortitemize{item} + +\newcommand\setlist{% + \@ifstar{\enit@setlist\@ne}{\enit@setlist\z@}} + +\def\enit@setlist#1{% + \@ifnextchar<% + {\enit@setlist@q#1}% + {\let\enit@forsize\@empty\enit@setlist@n#1}} + +% Default definitions. Modified below with option 'sizes': + +\def\enit@setlist@q#1<#2>{% + \enit@error + {Activate this feature with options 'sizes'}% + {Size dependent setting with \string<\string> must be\MessageBreak + explicitly activated with the package option 'sizes'}} + +\def\enit@setlist@n#1{% + \@ifnextchar[{\enit@setlist@x#1}{\enit@setlist@i#1\@empty}} + +% Let's accept \setlist[]*{}, too, because an error in <=3.5.1 + +\def\enit@setlist@x#1[#2]{% + \@ifstar{\enit@setlist@i\@ne{#2}}{\enit@setlist@i#1{#2}}} + +% #1 list names/levels, #2 keys/values + +% #1 star flag, #2 list names/levels, #3 keys/values + +\def\enit@setlist@i#1#2#3{% + \let\enit@eltnames\relax + \let\enit@b\@empty + \let\enit@eltlevels\relax + \let\enit@c\@empty + \protected@edef\enit@a{#2}% + \@for\enit@a:=\enit@a\do{% the 2nd enit@a is first expanded + \enit@ifunset{enitdp@\enit@meaning\enit@a}% + {\edef\enit@c{\enit@c\enit@eltlevels{\enit@a}}}% + {\enit@ifunset{enit@short\enit@meaning\enit@a}% + \@empty + {\edef\enit@a{\@nameuse{enit@short\enit@a}}}% + \edef\enit@b{\enit@b\enit@eltnames{\enit@a}}}}% + \ifx\enit@b\@empty + \def\enit@b{\enit@eltnames{list}}% + \fi + \ifx\enit@c\@empty + \def\enit@c{\enit@eltlevels{0}}% + \fi + \def\enit@eltnames##1{% + \def\enit@a{##1}% + \enit@c}% + \def\enit@eltlevels##1{% + \enit@saveset\enit@a{##1}#1{#3}}% + \enit@b}% + +% Deprecated: + +\newcommand\setdisplayed[1][0]{\setlist[trivlist,#1]} +\let\enitdp@trivlist\@empty % dummy, let know it exists +\newcommand\setenumerate[1][0]{\setlist[enumerate,#1]} +\newcommand\setitemize[1][0]{\setlist[itemize,#1]} +\newcommand\setdescription[1][0]{\setlist[description,#1]} + +% New lists +% ========= + +% When defining a list, \label... and counters must be defined +% for each level, too: + +\def\enit@xset@itemize{% + \@namedef{label\enit@c\romannumeral\count@}{% + \enit@error{Undefined label}% + {You have defined a list, but labels have + not been setup.\MessageBreak + You can set the label field with \string\setlist.}}} +\@namedef{enit@xset@itemize*}{\enit@xset@itemize} + +\def\enit@xset@enumerate{% + \enit@xset@itemize + \enit@ifunset{c@\enit@c\romannumeral\count@}% + {\@definecounter{\enit@c\romannumeral\count@}}{}} +\@namedef{enit@xset@enumerate*}{\enit@xset@enumerate} + +\let\enit@xset@description\@empty +\@namedef{enit@xset@description*}{\enit@xset@description} + +\newcommand\newlist{\enit@newlist\newenvironment} +\newcommand\renewlist{\enit@newlist\renewenvironment} + +% <new/renew>, <name>, <type>, <max-depth> + +\def\enit@newlist#1#2#3#4{% + \enit@ifunset{enit@xset@#3}% + {\enit@error{Unknown list type '#3')}% + {Valid types are: + enumerate, itemize, description,\MessageBreak + enumerate*, itemize*, description*}}% + {}% + \setcounter{enit@cnt}{#4}% + \count@\@ne + \enit@ifunset{enit@short#2}% + {\def\enit@c{#2}}% + {\edef\enit@c{\csname enit@short#2\endcsname}}% + \loop + \@nameuse{enit@xset@#3}% Uses \enit@c + \ifnum\count@<\c@enit@cnt + \advance\count@\@ne + \repeat + \enit@ifunset{enitdp@#2}% + {\expandafter\newcount\csname enitdp@#2\endcsname}{}% + \csname enitdp@#2\endcsname\z@ + \advance\c@enit@cnt\m@ne + \edef\enit@a{% + \noexpand#1{#2}[1][]% + {\enit@noexcs{enit@#3}% + \enit@noexcs{enitdp@#2}% + {\enit@c}% + {\the\c@enit@cnt}% + {####1}}% + {\enit@noexcs{enit@end#3}}}% + \enit@a} + +% Changing the default nesting limit +% ---------------------------------- + +\newcommand\setlistdepth{\def\enit@listdepth} +\setlistdepth{5} + +% +=============================+ +% | PACKAGE OPTIONS | +% +=============================+ + +\newif\ifenit@loadonly + +\DeclareOption{ignoredisplayed}{\let\enit@trivlist\trivlist} +\DeclareOption{includedisplayed}{% + \def\enit@setglobalkeys{% + \enit@setkeys{list}% + \enit@setkeys{list\romannumeral\@listdepth}}} +\let\enit@setglobalkeys\relax + +\DeclareOption{loadonly}{\enit@loadonlytrue} + +\DeclareOption{shortlabels} + {\def\enit@shl#1{% + \ifnum\enit@type=\tw@ + \enit@toks{#1}% + \else + \def\enit@c{#1}% + \enit@first#1,\@nil\@@nil % Returns enit@toks + \fi}} + +\DeclareOption{inline} + {\newenvironment{enumerate*}[1][]% + {\@nameuse{enit@enumerate*}\enitdp@enumerate{enum}\thr@@{#1}} + {\@nameuse{enit@endenumerate*}} + \newenvironment{itemize*}[1][]% + {\@nameuse{enit@itemize*}\enitdp@itemize{item}\thr@@{#1}} + {\@nameuse{enit@enditemize*}} + \newenvironment{description*}[1][]% + {\@nameuse{enit@description*}\enitdp@description{description}\@M{#1}} + {\@nameuse{enit@enddescription*}}} + +\def\enit@setlength{\setlength} +\DeclareOption{sizes} + {\def\enit@setlength#1#2{% + \enit@try@size@range{#2}% Returns \enit@c + \setlength#1{\enit@c}}% + \def\enit@setkeys#1{% + \enit@ifunset{enit@@#1}{}% + {\let\enit@c\@empty + \enit@ifunset{enit@@#1@@sizes}{}% + {\expandafter\let\expandafter\enit@a\csname enit@@#1@@sizes\endcsname + \expandafter\enit@try@size@range\expandafter{\enit@a}% + \def\enit@keys@sizes{\def\enit@c}% + \enit@c + \let\enit@keys@sizes\relax}% + \expandafter\expandafter\expandafter + \enit@setkeys@i + \csname enit@@#1\expandafter\endcsname + \expandafter,\enit@c\@@}}% + \def\enit@setlist@q#1<#2>{% + \def\enit@forsize{<#2>}% + \enit@setlist@n#1}} + +\chardef\enit@seriesopt\z@ +\DeclareOption{series=override}{\chardef\enit@seriesopt\tw@} + +\let\enit@shl\enit@toks + +\ProcessOptions + +\let\trivlist\enit@trivlist + +% If there is no loadonly, redefine the basic lists: + +\ifenit@loadonly\else + +\let\enitdp@enumerate\@enumdepth +\renewenvironment{enumerate}[1][] + {\enit@enumerate\enitdp@enumerate{enum}\thr@@{#1}} + {\enit@endenumerate} + +\let\enitdp@itemize\@itemdepth +\renewenvironment{itemize}[1][] + {\enit@itemize\enitdp@itemize{item}\thr@@{#1}} + {\enit@enditemize} + +\newcount\enitdp@description +\renewenvironment{description}[1][] + {\enit@description\enitdp@description{description}\@M{#1}} + {\enit@enddescription} + +\fi + +% +=============================+ +% | TOOLS | +% +=============================+ + +\def\enit@drawrule#1#2#3#4{% + \rlap{% + \ifdim#1>0pt\relax + \vrule width #1 height #2 depth -#3\relax + \else\ifdim#1=0pt\relax + % + \else + \hskip#1% + \vrule width -#1 height #2 depth -#4\relax + \fi\fi}} + +\def\DrawEnumitemLabel{% + \begingroup + \item[]% + \hskip-\labelsep + \enit@drawrule\labelsep{4pt}{3pt}{2.3pt}% + \hskip-\labelwidth + \enit@drawrule\labelwidth{6pt}{5pt}{4.3pt}% + \hskip\labelwidth + \hskip\labelsep + % + \hskip-\itemindent + \enit@drawrule\itemindent{2pt}{1pt}{.3pt}% + \rlap{\vrule height 9pt depth .5pt}% + \hskip-\leftmargin + \rlap{\vrule height 9pt depth .5pt}% + \enit@drawrule\labelindent{8pt}{7pt}{6.5pt}% + % \message{\the\labelindent/\the\labelwidth/\the\labelsep/\the\itemindent}% + \endgroup} + +% TODO - option 'verbose' + +% +=============================+ +% | TWO-PASS TOOLS | +% +=============================+ + +% TODO - Not for the moment, because both tools would require to take +% into account series and resume, which is not simple. Also, are they +% applied to all lists, by type, by level, by name, etc.? Document how +% to do it in at least the simplest cases. +% +% - reverse counting +% - automatic widest, based on existing labels. + +\endinput + +MIT License +----------- + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/titlesec.sty b/titlesec.sty @@ -0,0 +1,1719 @@ +% +% Copyright (C) 1998-2019 Javier Bezos http://www.texnia.com +% +% This file may be distributed and/or modified under the conditions of +% the MIT License. A version can be found at the end of this file. +% +% Repository: https://github.com/jbezos/titlesec +% +% Notes +% ~~~~~ +% +% The following tags are used: +% ttl@ : the generic tag used through the style +% ttlh@ : a shape definition +% ttlf@ : a macro containing the title format +% ttls@ : id. the title space +% ttlp@ : page key related macros +% ttll@ : level number +% +% The ttlf@ and ttls@ contains data in the form {..}{..}. +% Perhaps in future releases they should be converted +% to a prop-like list, similar to that proposed by the +% latex team. +% +% Admittedly, the current implementation seems too +% complicated, but that's necessary in order to provide +% certain compatibility with the sections as defined by the +% used class. Other packages opt for providing the sections +% as defined by standard classes ignoring the class; for +% instance sectsty which does a simple task in a simple and +% nice way. However, that was not my goal. +% +% Release +% ~~~~~~~ + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{titlesec}[2019/10/16 v2.13 Sectioning titles] + +% Initialization +% ~~~~~~~~~~~~~~ + +\newif\ifttl@ps +\ttl@psfalse + +% The \ttl@label switch is used when printing the label in titles. +% A numberless variant makes it to true. +% There is a \ttl@toclabel as well, which is true iff the +% title is numbered; used in toc entries (except default part +% and chapter) and marks (only in titlesec pagestyles). + +\newif\ifttl@label +\newif\ifttl@toclabel + +\newbox\ttl@box + +% A provision for the report style: + +\@ifundefined{if@mainmatter} + {\let\if@mainmatter\iftrue}{} + +\@ifundefined{if@openright} + {\let\if@openright\iftrue}{} + +% and the ams styles as well + +\@ifundefined{@chapapp} + {\let\@chapapp\chaptername}{} + +\def\ttl@trylist{\ttl@try{}} + +\def\ttl@getkeys#1#2{% + \if\expandafter @\@gobble#1@\@empty + \edef\ttl@b{\expandafter\@gobble\string#1}% + \let\ttl@a\ttl@b + \else + \ttl@keys + \ttl@getkeys{#1}{#2}% + \fi} + +% A more meaningful error for \@notdefinable + +\expandafter\AtEndOfPackage\expandafter{\expandafter + \gdef\expandafter\@notdefinable\expandafter{\@notdefinable}} + +\def\@notdefinable{% + \PackageError{titlesec}% + {Incompatible package}% + {Titlesec cannot continue defining its own macros + because\MessageBreak + \@backslashchar\reserved@a\space is already used by other package, + the class\MessageBreak + or the document.}} + +% +-----------------+ +% | C L A S S E S | +% +-----------------+ + +\def\ttl@useclass#1#2{% + \@ifstar + {\ttl@labelfalse#1{#2}[]}% + {\ttl@labeltrue\@dblarg{#1{#2}}}} + +\def\ttl@straightclass{\ttl@useclass\ttl@straight@i} +\def\ttl@partclass{\ttl@useclass\ttl@part@i} +\def\ttl@topclass{\ttl@useclass\ttl@top@i} +\def\ttl@pageclass{\ttl@useclass\ttl@page@i} + +% Here \scantokens is used to make sure the unescaped name +% has `letters' and no `others'. Mainly for hyperref, so there +% should be no problems. + +\newcommand\titleclass[1]{% + \edef\ttl@a{\expandafter\@gobble\string#1}% + \ifx\scantokens\@undefined\else + \scantokens\expandafter{\expandafter + \def\expandafter\ttl@a\expandafter{\ttl@a}}% + \fi + \@ifnextchar[{\@tempswatrue\ttl@class@i{#1}}% + {\@tempswafalse\ttl@class@ii{#1}}} + +\def\ttl@class@i#1[#2]{% + \@namedef{ttll@\ttl@a}{#2}% + \expandafter\providecommand\csname\ttl@a title\endcsname{}%%%% + \@ifundefined{ttl@toplevel}{}% + {\expandafter\let\csname ttlss@\ttl@a\expandafter\endcsname + \csname ttlss@\ttl@toplevel\endcsname}% + \edef\ttl@toplevel{\ttl@a}% + \ttl@class@ii{#1}} + +\def\ttl@class@ii#1#2{% + \@ifundefined{ttl@#2class}% + {\PackageError{titlesec}{Unknown sectioning class}% + {Valid names are top, page and straight}}% + {\expandafter\let\csname ttl@compat\ttl@a\endcsname\relax + \@ifundefined{\ttl@a mark}% + {\@namedef{\ttl@a mark}{\@gobble}}% + {}% + \edef#1{% + \expandafter\noexpand\csname ttl@#2class\endcsname{\ttl@a}}}% + \if@tempswa + \expandafter\@gobble + \else + \expandafter\@firstofone + \fi + {\@ifnextchar[% + {\ttl@class@iii}% + {\@ifundefined{ttll@\ttl@a}% + {\PackageError{titlesec}{Unknown sectioning level}% + {\string\titleclass\space with no optional arguments\MessageBreak + only changes the class of an *existing* level}}}}} + +\def\ttl@class@iii[#1]{% + \edef\ttl@b{\expandafter\@gobble\string#1}% + \expandafter\let\csname ttlss@\ttl@a\expandafter\endcsname + \csname ttlss@\ttl@b\endcsname + \expandafter\edef\csname ttlss@\ttl@b\endcsname{\ttl@a}% + \let\ttl@a\ttl@toplevel + \count@\csname ttll@\ttl@toplevel\endcsname + \ttl@class@iv} + +\def\ttl@class@iv{% + \@ifundefined{ttlss@\ttl@a}{}% + {\advance\count@\@ne + \edef\ttl@a{\csname ttlss@\ttl@a\endcsname}% + \expandafter\edef\csname ttll@\ttl@a\endcsname{\the\count@}% + \ttl@class@iv}} + +% Typesetting Classes: General tools +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +% The following command handles the *n spacing +% Some tricks are necessary to multiply a +% skip by a non integer number + +\newskip\beforetitleunit +\beforetitleunit=1ex\@plus.3ex\@minus.06ex +\newskip\aftertitleunit +\aftertitleunit=1ex\@plus.1ex + +\newdimen\ttl@plus +\newdimen\ttl@minus + +\def\ttl@assign#1{% + \@ifstar + {\ttl@assign@i{#1}}% + {\ttl@assign@d{#1}}} + +\def\ttl@assign@i#1#2\relax#3{% + \ttl@plus\z@ + \ttl@minus\z@ + \afterassignment\ttl@assign@ii + \dimen@\the#3, % <- space + #1 = #2\dimen@ + plus #2\ttl@plus + minus #2\ttl@minus} + +\def\ttl@assign@ii#1 {% <- space + \if#1,\else\afterassignment\ttl@assign@ii\fi + \csname ttl@\string#1\endcsname} + +\def\ttl@assign@d#1#2\relax#3{\setlength#1{#2}} + +% To be used with \v/vspace to make them calc-savvy + +\def\ttl@calc#1#2{% + {\setlength\@tempskipa{#2}% + #1\@tempskipa}} + +\def\ttl@calcneg#1#2{% + {\setlength\@tempskipa{#2}% + #1{-\@tempskipa}}} + +% Gets from ttls@ and passes the spacing parameters: + +\def\ttl@startargs#1#2{% Get the first arguments, with the spacing + \@ifundefined{ttlp@#2}% + {\let\ttl@key@page\@empty}% + {\ttlp@fetch{#2}}% + \begingroup + \def\ttl@b{ttls@#2}% + \edef\ttl@key@numberless{\ifttl@label//\else/*\fi}% + \def\ttl@a##1{\csname ttl@key@##1\endcsname}% Used as elt in try + \ttl@trylist + \xdef\ttl@b{\ttl@c}% + \endgroup + \ifx\ttl@b\@empty + \PackageError{titlesec}{Format/spacing not found}% + {I was unable to find the format corresponding to #2.\MessageBreak + Maybe you haven't set it with \string\titleformat\space and + \string\titlespacing} + \fi + \expandafter#1\ttl@b{#2}} + +% Used in ttl@select + +\def\ttl@savefn#1[#2]#3{% + \ifcase#1% + \footnotemark[#2]% + \gdef\ttl@fn{\footnotetext[#2]{#3}}% + \else + \footnotemark + \gdef\ttl@fn{\footnotetext{#3}}% + \fi} + +\def\ttl@nest@error{% + \PackageError{titlesec}{Nested titles}{Titles must not be nested}} + +\def\ttl@hmode@error{% + \PackageError{titlesec}{Entered in horizontal mode} + {The <format> argument cannot contain horizontal material\MessageBreak + such as text, \string\noindent, \string\makebox, etc.}} + +% \ttl@select not only selects the right version to be +% used. It also take steps to ensure that a mark +% is not lost inside a box by saving it into \ttl@mk, +% which in turn is used by the sect and chap commands. + +% As of 2019 and due the LaTex +% kernel modifies \markboth, we consider two possibilities (2.13). + +\newif\ifttl@explicit + +\def\ttl@gmk#1{\gdef\ttl@mk{#1}} + +\def\ttl@select#1#2#3#4{% + \ttl@Hy@saveanchor + \global\let\ttl@mk\@empty % global because of rigidchapters + \global\let\ttl@fn\@empty + \begingroup + \if@inlabel\else % Keep item's \everypar + \everypar{\setbox\z@\lastbox\ttl@strut}% + \fi + \let\ttl@straight@i\ttl@nest@error + \let\ttl@top@i \ttl@nest@error + \let\ttl@part@i \ttl@nest@error + \let\ttl@page@i \ttl@nest@error + \let\ttl@newpage\newpage + \def\newpage{\ttl@savewrite\ttl@newpage}% + \expandafter\ifx\csname markboth \endcsname\relax + \def\markboth##1##2{\protect\ttl@gmk{\protect\markboth{##1}{##2}}}% + \def\markright##1{\protect\ttl@gmk{\protect\markright{##1}}}% + \else + \@namedef{markboth }##1##2{\protect\ttl@gmk{\markboth{##1}{##2}}}% + \@namedef{markright }##1{\protect\ttl@gmk{\markright{##1}}}% + \fi + \def\@mkboth##1##2{\protect\ttl@gmk{\protect\@mkboth{##1}{##2}}}% + \def\footnote{\@ifnextchar[% + {\ttl@savefn\z@}{\ttl@savefn\@ne[]}}% + \edef\ttl@key@numberless{\ifttl@label//\else/*\fi}% + \def\ttl@b{ttlf@#1}% + \def\ttl@a##1{\csname ttl@key@##1\endcsname}% Used as elt in try + \ttl@trylist + \ifttl@explicit + \def\ttl@passexplicit{\ttl@case{#4}}% + \ttl@c{#4}{#2}{#3}{}% ttl@c is returned by ttl@try with ttlf@... + \else + \let\ttl@passexplicit\ttl@case + \ttl@c{#2}{#3}{#4}% ttl@c is returned by ttl@try with ttlf@... + \fi + \endgroup} + +\let\ttl@savewrite\@empty + +\def\ttl@finmarks{% + \ttl@savewrite + \ttl@mk % Contains a possible mark, returned by \ttl@select + \ttl@fn} % And a footnote + +\def\ttl@try#1{% + \edef\ttl@c{#1}% #1 is a list in the form \ttl@a{key}\ttl@a{key} + \@ifundefined{\ttl@b\ttl@c}{}{% + \edef\ttl@c{\expandafter\noexpand\csname\ttl@b\ttl@c\endcsname}% + \def\ttl@a##1{\csname ttl@extra@##1\endcsname}% + #1% + \let\ttl@try\@gobble}} % locally modified to `break' testings + +% \ttl@write writes marks and toc. tocdepth is taken care of when +% the toc is typesetted and not here. Used always through +% ttl@savewrite, which is reset to \@empty to avoid duplicated +% calls. + +\def\ttl@write#1#2{% + \ttl@blinemarks + \csname#1mark\endcsname{#2}% + \def\ttl@a{\protect\numberline{\@nameuse{the#1}}}% + \@nameuse{ttl@toc#1}% eg, \ttl@tocpart modifies \ttl@a + \ttl@addcontentsline{#1}{#2}% Depends on toctitles, uses \ttl@a + \ttl@elinemarks + \global\ttl@toclabelfalse + \global\let\ttl@savewrite\@empty} + +\newif\ifttl@premark % to be used in ttlps.def +\ttl@premarkfalse + +% 2019-06-20. Added the \lastskip stuff, because a mark 'forgets' the +% last skip. + +\def\ttl@premark#1#2{% + \let\ttl@lastskip\relax + \ifvmode + \ifdim\lastskip=\z@\else + \edef\ttl@lastskip{\the\lastskip}% + \vskip-\ttl@lastskip\relax + \fi + \fi + \protected@xdef\ttl@prevmarks{\ttl@marks}% + \ttl@blinemarks + \csname#1mark\endcsname{#2}% + \ttl@elinemarks + \ifx\ttl@lastskip\relax\else + \vskip\ttl@lastskip\relax + \fi + \gdef\ttl@prevmarks{\ttl@marks}} + +% Must be preceded by a default \ttl@savewrite, which is used +% in starred variants--\@empty in top and straight classes. +% In straight class, it is preceded by the setting of +% prev marks to provide a "fixed" top mark. Otherwise, +% the default prev mark (= curr mark) is used (restored +% after ttl@labelling in straight). This is the command +% to be hacked if you want to change the behaviour of +% starred variants. + +\def\ttl@labelling#1#2{% + \let\ttl@Hy@saveanchor\@empty + \ifttl@label % 1st - if star + \def\ttl@savewrite{\ttl@write{#1}{#2}}% + \@nameuse{ttl@#1label}% eg, sets if mainmatter in chapter. + \ifttl@label % 2nd - eg, if not main matter + \ifnum\@nameuse{ttll@#1}>\c@secnumdepth\relax + \ttl@labelfalse % 3rd - if too deep + \else + \ttl@Hy@refstepcounter{#1}% + \@nameuse{ttl@#1out}% + \fi + \fi + \fi + \let\ifttl@toclabel\ifttl@label + \ifx\ttl@savewrite\@empty\else % If marks + \ifttl@ps + \ifttl@premark + \global\ttl@premarkfalse + \else % if no \pretitlemark + \ttl@premark{#1}{#2}% + \fi + \fi + \ifttl@label\else\ttl@Hy@steplink{#1}\fi + \fi} + +% Executed by ttl@labelling if the name of section is chapter: + +\def\ttl@chapterlabel{\if@mainmatter\else\ttl@labelfalse\fi} + +% Executed by ttl@labelling if chapter has a number. Note +% you can define messages for other sectioning levels (eg, +% \ttl@sectionout). + +\def\ttl@chapterout{\typeout{\chaptertitlename\space\thechapter.}} + +% Straight class +% ~~~~~~~~~~~~~ +% Default for nobottomtitles. Changed by nobottomtitles* + +\def\ttl@addstretch{\advance\@tempskipa-\pagestretch} + +% 1:name 2:level 3:indent 4:before 5:after 6:afind [7]:cap 8:title +% The second argument of ttl@sect is the level, which +% is empty if the star version is used. In this case +% neither the toc nor the marks are written. + +\def\ttl@straight@i#1[#2]#3{% + \def\@currentlabelname{#2}% for nameref + \gdef\ttl@savemark{\csname#1mark\endcsname{#3}}% + \let\ttl@savewrite\@empty + \def\ttl@savetitle{#3}% + \gdef\thetitle{\csname the#1\endcsname}% + \if@noskipsec \leavevmode \fi + \par + \ttl@labelling{#1}{#2}% + \ttl@startargs\ttl@straight@ii{#1}{#3}} + +% 1:left 2:right 3:before 4:after 5:afterindent 6:name 7:title + +\def\ttl@straight@ii#1#2#3#4#5#6#7{% + \ttl@assign\@tempskipa#3\relax\beforetitleunit + \@ifundefined{ttl@ps@#6}{}% + {\PackageWarning{titlesec}{Page style in straight class ignored}}% + \if@nobreak + \ttl@titlespace{\@tempskipa}% + \else + \@ifundefined{#6break}% + {\addpenalty{\@secpenalty}}% + {\csname#6break\endcsname}% + \addvspace{\@tempskipa}% + \ifdim\bottomtitlespace<\z@ + \else + \begingroup + \@tempskipb\pagegoal + \@tempskipa\pagegoal + \ttl@addstretch % \relax if nobottomtitle* + \advance\@tempskipa-\bottomtitlespace\relax % not a register + \pagegoal\@tempskipa + \def\@textbottom{\vskip\z@\@plus.0001fil}% + \penalty9999 + \pagegoal\@tempskipb + \endgroup + \fi + \fi + \@afterindenttrue + \ifcase#5 \@afterindentfalse\fi + \ttl@assign\@tempskipb#4\relax\aftertitleunit + \ttl@select{#6}{#1}{#2}{#7}% + \ttl@finmarks + \@ifundefined{ttlp@#6}{}{\ttlp@write{#6}}% + \if@noskipsec + \global\@nobreakfalse + \everypar{% + \if@noskipsec + \global\@noskipsecfalse + \clubpenalty\@M + \hskip-\parindent + \begingroup + \@svsechd\unskip{\hspace{\@tempskipb}}% + \endgroup + \else + \clubpenalty\@clubpenalty\everypar{}% + \fi}% + \else + \par\nobreak + \vspace{\@tempskipb}% + \@afterheading + \fi + \ignorespaces} + +% Part class +% ~~~~~~~~~~ + +\providecommand\partmark[1]{\markboth{}{}} + +\def\ttl@part@i#1[#2]#3{% + \gdef\ttl@savemark{\csname#1mark\endcsname{#3}}% + \ifx\ttl@notocparts\@undefined + \def\ttl@savewrite{\ttl@write{#1}{#3}}% Not #2! + \else + \let\ttl@savewrite\@empty + \fi + \def\ttl@savetitle{#3}% + \ttl@labelling{#1}{#2}% + \ttl@startargs\ttl@part@ii{#1}{#3}} + +\def\ttl@part@ii#1#2#3#4#5#6#7{% + \ttl@assign\@tempskipa#3\relax\beforetitleunit + \vspace*{\@tempskipa}% + \@ifundefined{ttl@ps@#6}{}% + {\PackageWarning{titlesec}{Page style in part class ignored}}% + \global\@afterindenttrue + \ifcase#5 \global\@afterindentfalse \fi + \ttl@assign\@tempskipb#4\relax\aftertitleunit + \ttl@select{#6}{#1}{#2}{#7}% + \ttl@finmarks + \@ifundefined{ttlp@#6}{}{\ttlp@write{#6}}% + \par\nobreak + \vspace{\@tempskipb}% + \@afterheading} + +% Page class +% ~~~~~~~~~~ + +\def\ttl@page@i#1[#2]#3{% + \gdef\ttl@savemark{\csname#1mark\endcsname{#3}}% + \ifx\ttl@notocparts\@undefined + \def\ttl@savewrite{\ttl@write{#1}{#3}}% Not #2! + \else + \let\ttl@savewrite\@empty + \fi + \def\ttl@savetitle{#3}% + \ttl@labelling{#1}{#2}% + \ttl@startargs\ttl@page@ii{#1}{#3}} + +\def\ttl@page@ii#1#2#3#4#5#6#7{% + \ttl@assign\@tempskipa#3\relax\beforetitleunit + \if@openright + \cleardoublepage + \else + \clearpage + \fi + \@ifundefined{ttl@ps@#6}% + {\thispagestyle{plain}}% + {\thispagestyle{\@nameuse{ttl@ps@#6}}}% + \if@twocolumn + \onecolumn + \@tempswatrue + \else + \@tempswafalse + \fi + \vspace*{\@tempskipa}% + \@afterindenttrue + \ifcase#5 \@afterindentfalse\fi + \ttl@assign\@tempskipb#4\relax\aftertitleunit + \ttl@select{#6}{#1}{#2}{#7}% + \ttl@finmarks + \@ifundefined{ttlp@#6}{}{\ttlp@write{#6}}% + \vspace{\@tempskipb}% + \newpage + \if@twoside + \if@openright + \null + \@ifundefined{ttl@ps@#6}% + {\thispagestyle{empty}}% + {\thispagestyle{\@nameuse{ttl@ps@#6}}}% + \newpage + \fi + \fi + \if@tempswa + \twocolumn + \fi + \ignorespaces} + +% Top class and some makechapterhead stuff +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +% +% \ttl@mkchap is the new make(s)chapterhead. + +\def\ttl@mkchap#1#2#3#4#5#6#7{% + \gdef\ttl@savemark{\csname#6mark\endcsname{#7}}% + \let\ttl@savewrite\@empty + \let\ttl@Hy@saveanchor\@empty + \@ifundefined{ttl@ps@#6}{}% + {\thispagestyle{\@nameuse{ttl@ps@#6}}}% + \let\ifttl@toclabel\ifttl@label + \ttl@mkchap@i{#1}{#2}{#3}{#4}{#5}{#6}{#7}} + +% But \ttl@mkchap@i is used by both makechapterhead and +% the top class. + +\def\ttl@mkchap@i#1#2#3#4#5#6#7{% + \ttl@assign\@tempskipa#3\relax\beforetitleunit + \vspace*{\@tempskipa}% + \global\@afterindenttrue + \ifcase#5 \global\@afterindentfalse\fi + \ttl@assign\@tempskipb#4\relax\aftertitleunit + \ttl@topmode{\@tempskipb}{% + \ttl@select{#6}{#1}{#2}{#7}}% + \ttl@finmarks % Outside the box! + \@ifundefined{ttlp@#6}{}{\ttlp@write{#6}}} + +\def\ttl@top@i#1[#2]#3{% + \gdef\ttl@savemark{\csname#1mark\endcsname{#3}}% + \let\ttl@savewrite\@empty + \def\ttl@savetitle{#3}% + \ttl@labelling{#1}{#2}% + \ttl@startargs\ttl@top@ii{#1}{#3}} + +\def\ttl@top@ii#1#2#3#4#5#6#7{% + \@ifundefined{#6break}% + {\if@openright + \cleardoublepage + \else + \clearpage + \fi}% + {\csname#6break\endcsname}% + \@ifundefined{ttl@ps@#6}% + {\thispagestyle{plain}}% + {\thispagestyle{\@nameuse{ttl@ps@#6}}}% + \global\@topnum\z@ + \@ifundefined{#6tolists}% + {\addtocontents{lof}{\protect\ttl@tocsep}% + \addtocontents{lot}{\protect\ttl@tocsep}} + {\@nameuse{#6tolists}}% + \if@twocolumn + \@topnewpage[\ttl@mkchap@i{#1}{#2}{#3}{#4}{#5}{#6}{#7}]% + \else + \ttl@mkchap@i{#1}{#2}{#3}{#4}{#5}{#6}{#7}% + \@afterheading + \fi + \ignorespaces} + +% \def\ttl@noskipsectrue{% +% \if@noskipsec +% \PackageError{titlesec}{Invalid shape for top class}% +% {The selected shape only makes sense when merged into\MessageBreak +% a paragraph. That is impossible in the top class}% +% \else + +\newcommand\chaptertitlename{\@chapapp} +\def\ttl@tocsep{\addvspace{10\p@}} + +% +-----------------+ +% | S H A P E S | +% +-----------------+ +% +% Reformatting Titles: Interface +% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +% The surrounding space is stored in a macro +% named \ttls@<section> whose content is +% {left}{right}{before}{after}{afterindent}. +% But if there is the page key, the name is +% \ttls@<section>/<page> + +\newcommand\titlespacing{% + \@ifstar{\ttl@spacing@i{\z@}}{\ttl@spacing@i{\@ne}}} + +\def\ttl@spacing@i#1#2#3#4#5{% + \ttl@getkeys{#2}{titlesec}% + \@ifnextchar[{% + \ttl@spacing@ii{#1}{#3}{#4}{#5}% + }{% + \ttl@spacing@ii{#1}{#3}{#4}{#5}[\z@]}} + +\def\ttl@spacing@ii#1#2#3#4[#5]{% + \expandafter\def\csname ttls@\ttl@a\endcsname + {{#2}{#5}{#3}{#4}{#1}}} + +% The section name is built in \ttl@a. +% The format is stored in a macro named \ttlf@<section>, +% or \ttlf@<section>/<page> if there is the page spec, +% or \ttlf@.../* if numberless is true +% whose content is +% \ttl@<shape>{format}{label}{sep}{before}{after} + +\newtoks\ttl@toksa + +\newcommand\titleformat{% + \@ifstar{\ttl@format@s}% + {\ttl@format@i}} + +\def\ttl@format@s#1#2{% + \edef\ttl@a{\expandafter\@gobble\string#1}% + \@ifundefined{ttlf@\ttl@a}% + {\PackageError{titlesec}{Not allowed in `easy' settings} + {The sectiong command you are trying to redefine\MessageBreak + is not handled by the starred variant (eg, \string\part)}}{} + \expandafter\expandafter\expandafter + \ttl@format@si\csname ttlf@\ttl@a \endcsname + {#2}} + +\def\ttl@format@si#1#2#3#4#5#6#7{% + \@namedef{ttlf@\ttl@a}{#1{#7}{#3}{#4}{#5}{#6}}} + +\def\ttl@format@i#1{% + \@ifnextchar[{\ttl@format@ii{#1}}{\ttl@format@ii{#1}[hang]}} + +\def\ttl@format@ii#1[#2]#3#4#5#6{% + \ttl@getkeys{#1}{titlesec}% + \ttl@toksa{{#3}{#4}{#5}{#6}}% Save arguments + \@ifnextchar[{% + \ttl@format@iii{#2}% + }{% + \ttl@format@iii{#2}[]}} + +% First, we get the shape -- if not defined it loads +% the corresponding file. + +\def\ttl@format@iii#1[#2]{% + \@ifundefined{ttlh@#1}{% + \begingroup + \makeatletter + \InputIfFileExists{#1.tss}{}{% + \@ifundefined{ttlhx@#1}% + {\PackageError{titlesec}{Unknown shape}% + {Shapes are defined in files with extension tss\MessageBreak + Either you have misspelled the shape\MessageBreak + or there is no a #1.tss file}}% + {\global\expandafter + \let\csname ttlh@#1\expandafter\endcsname + \csname ttlhx@#1\endcsname}}% + \endgroup}{}% + \@temptokena{#2}% + \ifttl@explicit + \edef\ttl@b{% + \def\expandafter\noexpand\csname ttlf@\ttl@a\endcsname####1% + {\expandafter\noexpand\csname ttlh@#1\endcsname + \the\ttl@toksa{\the\@temptokena}}}% + \else + \edef\ttl@b{% + \def\expandafter\noexpand\csname ttlf@\ttl@a\endcsname + {\expandafter\noexpand\csname ttlh@#1\endcsname + \the\ttl@toksa{\the\@temptokena}}}% + \fi + \ttl@b + \csname ttl@compat\ttl@a\endcsname} + +% Styles +% ~~~~~~ + +% 1:global 2:label 3:sep 4:style 5:after 6:left 7:right 8:title +% \ttl@<shape> and \ttlh@<shape> take the following eight +% arguments: +% {format}{label}{sep}{before}{after}{left}{right}{title} +% where before and after refer to the format. +% With the option explicit, #4 contains the title and #8 is +% empty. + +\def\ttl@strut{\strut} + +\def\ttlh@display#1#2#3#4#5#6#7#8{% + \gdef\ttl@makeline##1{\ttl@calc\hspace{#6}##1\ttl@calc\hspace{#7}}% + \setlength\leftskip{#6}% + \setlength\rightskip{#7}% + \interlinepenalty\@M + \ttl@changecentercr + \ttl@defnostruts + \ttl@beginlongest + #1\ifhmode\ttl@hmode@error\fi + \ttl@glcmds + \parindent\z@ + \ifttl@label + {#2\ttl@strut\@@par}\nobreak\ttl@calc\vspace{#3}% + \fi + #4{#8}% + \kern\z@\ttl@strut\@@par + \nobreak\ttl@midlongest#5\@@par + \ttl@endlongest} + +\def\ttlh@hang#1#2#3#4#5#6#7#8{% + \gdef\ttl@makeline##1{\ttl@calc\hspace{#6}##1\ttl@calc\hspace{#7}}% + \setlength\leftskip{#6}% + \setlength\rightskip{#7}% + \interlinepenalty\@M + \ttl@changecentercr + \ttl@defnostruts + \ttl@beginlongest + #1{\ifhmode\ttl@hmode@error\fi + \ttl@glcmds + \parindent\z@ + \begingroup + \ifttl@label + \noindent + \sbox\z@{#2\ttl@strut\ttl@calc\hspace{#3}}% + \hangindent\wd\z@ + \box\z@ + \fi + #4{#8}% + \kern\z@\ttl@strut\@@par + \endgroup + \nobreak\ttl@midlongest#5\@@par}% + \ttl@endlongest} + +\def\ttlh@runin#1#2#3#4#5#6#7#8{% + \global\@noskipsectrue + \gdef\ttl@makeline##1{##1}% + \ttl@changecentercr + \ttl@defnostruts + #1{\ifhmode\ttl@hmode@error\fi + \global\sbox\ttl@box{% + \ttl@calc\hspace{#6}% + \ifttl@label{\ttl@strut#2}\ttl@calc\hspace{#3}\fi + #4{#8}#5\unskip}}% + \gdef\@svsechd{\unhbox\ttl@box}} + +% ---------- + +\gdef\ttlhx@block#1#2#3#4#5#6#7#8{% + \gdef\ttl@makeline##1{\ttl@calc\hspace{#6}##1\ttl@calc\hspace{#7}}% + \setlength\leftskip{#6}% + \setlength\rightskip{#7}% + \interlinepenalty\@M + \ttl@changecentercr + \ttl@defnostruts + \ttl@beginlongest + #1% \ifhmode\ttl@hmode@error\fi + \ttl@glcmds + \parindent\z@ + \leavevmode + \ifttl@label + {#2}% + \setlength\@tempskipa{#3}% + \ifdim\@tempskipa=\z@\else\ttl@calc\hspace{#3}\fi + \fi + #4{#8}% + \kern\z@\ttl@strut\@@par + \nobreak\ttl@midlongest#5\@@par + \ttl@endlongest} + + +\gdef\ttlhx@frame#1#2#3#4#5#6#7#8{% + \def\ttl@filleft##1{\hfill}% + \def\ttl@filright##1{\hfill}% + \gdef\ttl@makeline##1{% + \ttl@calc\hspace{#6}##1\ttl@calc\hspace{#7}}% + \interlinepenalty\@M + \ttl@changecentercr + \ttl@defnostruts + #1\ifhmode\ttl@hmode@error\fi + \parindent\z@ + \leavevmode + \@tempdima\fboxrule + \addtolength\@tempdima{#3}% + \setlength\leftskip{#6}% + \setlength\rightskip{#7}% + \lower\@tempdima\hbox{% + \everypar{}% + \setbox\z@\hbox{#2}% + \addtolength\hsize{-#6}% + \addtolength\hsize{-#7}% + \@tempdima\dp\z@ % 2002/3/22 + \advance\@tempdima.5\ht\z@ + \vbox{% + \hbox to \hsize{% + \leaders\hrule\@height\fboxrule\ttl@filleft{#3}% + \ifttl@label\lower.5\ht\z@\box\z@\fi + \leaders\hrule\@height\fboxrule\ttl@filright{#3}}% + \vskip-\lineskip + \ifttl@label\vskip-\@tempdima\fi + \hbox{% + \vrule\@width\fboxrule + \kern-\fboxrule + \vbox{% + \ttl@calc\vspace{#3}% + \leavevmode + \addtolength\leftskip {#3}\addtolength\leftskip{-#6}% + \addtolength\rightskip{#3}\addtolength\rightskip{-#7}% + \ttl@strut#4{#8}\kern\z@\ttl@strut\@@par + \ttl@calc\vspace{#3}}% + \kern-\fboxrule + \vrule\@width\fboxrule}% + \hrule\@height\fboxrule}}% + \@@par\nobreak#5\@@par} + +\gdef\ttlhx@leftmargin#1#2#3#4#5#6#7#8{% + \global\@noskipsectrue + \addtolength\@tempskipb{#6}% + \xdef\ttl@makeline##1{\hskip-\the\@tempskipb\relax##1}% + \leftskip\z@skip + \rightskip\z@skip + \ttl@changecentercr + \ttl@defnostruts + #1\ifhmode\ttl@hmode@error\fi + \parindent\z@ + \global\setbox\ttl@box\vtop{% + \setlength\hsize{#6}% + \linewidth\hsize + \everypar{}% + \color@begingroup + \ifttl@label{\ttl@strut#2\ttl@strut}\ttl@calc\hspace{#3}\fi + \ttl@strut#4{#8}\kern\z@\ttl@strut\@@par + \color@endgroup}% + \advance\@tempskipa\ht\ttl@box + \advance\@tempskipa\dp\ttl@box + \advance\@tempskipa-\pagegoal + \advance\@tempskipa\pagestretch + \@tempskipb\pagegoal + \pagegoal-\@tempskipa + \ifdim\bottomtitlespace<\z@\else + \def\@textbottom{\vskip\z@\@plus.0001fil}% + \fi + \penalty9999 + \pagegoal\@tempskipb + \dp\ttl@box=\z@ + \gdef\@svsechd##1##2{% + \llap{\box\ttl@box##2}% + \if@afterindent\hskip\parindent\fi + #5}} + +\let\ttlhx@margin\ttlhx@leftmargin + +\gdef\ttlhx@rightmargin#1#2#3#4#5#6#7#8{% + \global\@noskipsectrue + \addtolength\@tempskipb{#6}% + \xdef\ttl@makeline##1{##1\hskip-\the\@tempskipb}% + \leftskip\z@skip + \rightskip\z@skip + \ttl@changecentercr + \ttl@defnostruts + #1\ifhmode\ttl@hmode@error\fi + \parindent\z@ + \global\setbox\ttl@box\vtop{% + \setlength\hsize{#6}% + \linewidth\hsize + \everypar{}% + \color@begingroup + \ifttl@label{\ttl@strut#2\ttl@strut}\ttl@calc\hspace{#3}\fi + \ttl@strut#4{#8}\kern\z@\ttl@strut\@@par + \color@endgroup}% + \advance\@tempskipa\ht\ttl@box + \advance\@tempskipa\dp\ttl@box + \advance\@tempskipa-\pagegoal + \advance\@tempskipa\pagestretch + \@tempskipb\pagegoal + \pagegoal-\@tempskipa + \ifdim\bottomtitlespace<\z@\else + \def\@textbottom{\vskip\z@\@plus.0001fil}% + \fi + \penalty9999 + \pagegoal\@tempskipb + \dp\ttl@box=\z@ + \gdef\@svsechd##1##2{% + \rlap{\hskip\textwidth##2\box\ttl@box}% + \if@afterindent\hskip\parindent\fi}} + +\gdef\ttlhx@wrap#1#2#3#4#5#6#7#8{% + \global\@noskipsectrue + \gdef\ttl@makeline##1{##1}% + \ttl@changecentercr + \ttl@defnostruts + \begingroup + #1\ifhmode\ttl@hmode@error\fi + \titlewidth\z@ + \def\\{\@ifstar{\@ifnextchar[{\ttl@bs}{\newline}}% + {\@ifnextchar[{\ttl@bs}{\newline}}}% + \def\ttl@bs[##1]{\newline}% + \let\@centercr\\% + \advance\rightskip 1\leftskip plus 1fil + \leftskip=\z@ + \parindent\z@ + \let\iftitlemeasuring\@firstoftwo + \global\setbox\ttl@box\vtop{\setlength\hsize{#6}% + \color@begingroup + \ifttl@label{#2}\ttl@calc\hspace{#3}\fi + #4{#8}\kern\z@\ttl@strut + \@@par + \color@endgroup}% + \let\iftitlemeasuring\@secondoftwo + \ttl@boxprocess + \global\titlewidth\titlewidth + \global\titlewidthfirst\titlewidthfirst + \global\titlewidthlast\titlewidthlast + \endgroup + \edef\ttl@maxdimen{\the\titlewidth}% + #1\ifhmode\ttl@hmode@error\fi + \global\setbox\ttl@box\vtop{\setlength\hsize{\ttl@maxdimen}% + \color@begingroup + \ifttl@label{#2}\ttl@calc\hspace{#3}\fi#4{#8}\kern\z@\ttl@strut + \@@par + \color@endgroup}% + \advance\@tempskipa1.5\baselineskip + \advance\@tempskipa\ht\ttl@box + \advance\@tempskipa\dp\ttl@box + \advance\@tempskipa-\pagegoal + \advance\@tempskipa\pagestretch + \@tempskipb\pagegoal + \pagegoal-\@tempskipa + \ifdim\bottomtitlespace<\z@\else + \def\@textbottom{\vskip\z@\@plus.0001fil}% + \fi + \penalty9999 + \pagegoal\@tempskipb + \@tempdima\ht\ttl@box \advance\@tempdima\dp\ttl@box + \@tempdimb\@tempdima + \divide\@tempdima\baselineskip \count@\@tempdima + \advance\count@ + \ifdim\@tempdimb<\the\count@.5\baselineskip\@ne\else\tw@\fi + \dp\ttl@box=\z@ + \xdef\@svsechd##1##2{% + \noexpand\llap{\box\ttl@box##2}% + \setbox\z@\hbox{\hskip\ttl@maxdimen\relax##2}% + \global\hangindent\wd\z@ + \global\hangafter-\the\count@\relax}} + +\gdef\ttlhx@drop#1#2#3#4#5#6#7#8{% + \global\@noskipsectrue + \gdef\ttl@makeline##1{##1}% + \ttl@changecentercr + \ttl@defnostruts + #1\ifhmode\ttl@hmode@error\fi + \parindent\z@ + \global\setbox\ttl@box\vtop{\setlength\hsize{#6}% + \color@begingroup + \ifttl@label{#2}\ttl@calc\hspace{#3}\fi + #4{#8}\kern\z@\ttl@strut + \@@par + \color@endgroup}% + \advance\@tempskipa1.5\baselineskip + \advance\@tempskipa\ht\ttl@box + \advance\@tempskipa\dp\ttl@box + \advance\@tempskipa-\pagegoal + \advance\@tempskipa\pagestretch + \@tempskipb\pagegoal + \pagegoal-\@tempskipa + \ifdim\bottomtitlespace<\z@\else + \def\@textbottom{\vskip\z@\@plus.0001fil}% + \fi + \penalty9999 + \pagegoal\@tempskipb + \@tempdima\ht\ttl@box \advance\@tempdima\dp\ttl@box + \@tempdimb\@tempdima + \divide\@tempdima\baselineskip \count@\@tempdima + \advance\count@ + \ifdim\@tempdimb<\the\count@.5\baselineskip\@ne\else\tw@\fi + \dp\ttl@box=\z@ + \xdef\@svsechd##1##2{% + \noexpand\llap{\box\ttl@box##2}% + \setbox\z@\hbox{\noexpand\ttl@calc\noexpand\hspace{#6}\relax##2}% + \global\hangindent\wd\z@ + \global\hangafter-\the\count@\relax}} + +% +-----------------+ +% | T O O L S | +% +-----------------+ +% +% calcwidth +% ~~~~~~~~~ +% Implemented after code from soul (but much modified...) + +\newdimen\titlewidth +\newdimen\titlewidthlast +\newdimen\titlewidthfirst + +\let\ttl@glcmds\relax +\let\ttl@beginlongest\@empty +\let\ttl@midlongest\@empty +\let\ttl@endlongest\@empty +\let\iftitlemeasuring\@secondoftwo + +\def\ttl@xbeginlongest#1\ttl@endlongest{% + \titlewidth\z@ + \titlewidthlast\z@ + \let\iftitlemeasuring\@firstoftwo + \setbox\ttl@box\vbox{% + \def\ttl@glcmds{% + \def\\{\@ifstar{\@ifnextchar[{\ttl@bs}{\newline}}% + {\@ifnextchar[{\ttl@bs}{\newline}}}% + \def\ttl@bs[####1]{\newline}% + \let\@centercr\\% + \def\ttl@midlongest####1\@@par{}% Very dirty... + \advance\rightskip 1\leftskip plus 1fil + \leftskip=\z@}% + #1}% + \let\iftitlemeasuring\@secondoftwo + \ttl@boxprocess + #1} + +\def\ttl@boxprocess{% + \setbox\ttl@box=\vbox{% + \unvcopy\ttl@box + \unskip\unpenalty + \global\setbox\@ne=\lastbox}% + \ifvoid\@ne + \else + \setbox\tw@=\hbox{\hskip-\leftskip\unhbox\@ne\hskip-\rightskip}% + \titlewidthfirst\wd\tw@ + \ifdim\titlewidth<\titlewidthfirst + \titlewidth\titlewidthfirst + \fi + \ifdim\titlewidthlast=\z@ + \titlewidthlast\titlewidthfirst + \fi + \expandafter\ttl@boxprocess + \fi} + +% Rules +% ~~~~~ + +\providecommand\titleline{% + \@ifstar{\ttl@line@i{\hb@xt@\titlewidth}}% + {\ttl@line@i{}}} + +\def\ttl@line@i#1{% + \@ifnextchar[{\ttl@line{#1}}{\ttl@line{#1}[s]}} + +\def\ttl@line#1[#2]#3{% + \vskip\topskip + \hrule \@height \z@ + \nobreak + \vskip-\topskip + \begingroup + \parindent\z@ + \everypar{}% + \leftskip\z@ + \rightskip\z@ % #1 is either \hb@xt@\titlewidth or empty: + \@makebox[\hsize][#2]{\ttl@makeline{#1{#3}}}% + \par + \endgroup + \hrule height \z@ + \nobreak} + +\providecommand\titlerule{\@ifstar{\ttl@row}{\ttl@rule}} + +\let\ttl@leaders\xleaders % For titletoc compatibility + +\def\ttl@row{\@ifnextchar[{\ttl@row@i}{\ttl@row@i[\wd\z@]}} +\def\ttl@row@i[#1]#2{% + \ifvmode\expandafter\titleline\fi + {\sbox\z@{#2}% + \ttl@calcneg\hspace{#1}% + \hskip\wd\z@ + \ttl@leaders\hb@xt@#1{\hss\box\z@}% + \hfill\kern\z@}} + +\def\ttl@rule{\@ifnextchar[{\ttl@rule@i}{\ttl@rule@i[.4\p@]}} +\def\ttl@rule@i[#1]{% + \ifvmode\expandafter\titleline\fi + {\leaders\hrule height #1\hfill\kern\z@}} + +% Par shapes and space +% ~~~~~~~~~~~~~~~~~~~~ + +\providecommand\filright{% + \gdef\ttl@filleft##1{\hskip##1}% + \gdef\ttl@filright##1{\hfill}% + \let\\\@centercr + \advance\rightskip\z@ \@plus 1fil\relax} +\providecommand\filleft{% + \gdef\ttl@filleft##1{\hfill}% + \gdef\ttl@filright##1{\hskip##1}% + \let\\\@centercr + \advance\leftskip\z@ \@plus 1fil + \parfillskip\z@} +\providecommand\filcenter{\filleft\filright + \gdef\ttl@filleft##1{\hfill}} +\providecommand\fillast{% + \gdef\ttl@filleft##1{\hfill}% + \gdef\ttl@filright##1{\hfill}% + \let\\\@centercr + \filleft\advance\rightskip\z@ \@plus -1fil + \parfillskip\z@ \@plus 2fil\relax} +\newcommand\filinner{% + \if@twoside + \ifodd\count\z@\filleft\else\filright\fi + \else + \filleft + \fi} +\newcommand\filouter{% + \if@twoside + \ifodd\count\z@\filright\else\filleft\fi + \else + \filright + \fi} + +\newcommand\wordsep{\fontdimen\tw@\font \@plus + \fontdimen\thr@@\font \@minus \fontdimen4\font} + +% Struts. +% ~~~~~~ +% A way to remove the struts added by styles. May be redefined below +% with option nostruts. + +\def\ttl@defnostruts{\def\nostruts{\let\ttl@strut\@empty}} + +% +-----------------+ +% | O P T I O N S | +% +-----------------+ + +\DeclareOption{pagestyles}{\let\sectiontitle\@empty} +\DeclareOption{extramarks}{\let\ttl@fetchmark\@empty} +\DeclareOption{floatps}{% + \ifx\sectiontitle\@empty + \let\ttl@replace\space + \else + \PackageWarning{titlesec}{Ignoring `floatps' without + `pagestyles'. This option is now deprecated.}% + \fi} +\DeclareOption{psfloats}{% + \ifx\sectiontitle\@empty + \let\ttl@replace\@empty + \else + \PackageWarning{titlesec}{Ignoring `psfloats' without + `pagestyles'}% + \fi} + +\DeclareOption{loadonly}{\let\ttl@extract\@empty} + +\DeclareOption{outermarks}{% + \def\ttl@titlemarks{\outertitlemarks}} +\DeclareOption{topmarks}{ + \def\ttl@titlemarks{\toptitlemarks}} +\DeclareOption{botmarks}{% + \def\ttl@titlemarks{\bottitlemarks}} +\DeclareOption{innermarks}{% + \def\ttl@titlemarks{\innertitlemarks}} + +\DeclareOption{footmarks}{} % Backward compat + +\DeclareOption{explicit}{\ttl@explicittrue} + +\DeclareOption{clearempty}{% + \def\cleardoublepage{% + \clearpage{\ps@empty\if@twoside\ifodd\c@page\else + \hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi}}} + +\DeclareOption{rigidchapters}{% + \def\ttl@topmode#1#2{\vbox to #1{#2\vfil}}% + \def\ttl@chapafter{.26\textheight}} +\DeclareOption{rubberchapters}{% + \def\ttl@topmode#1#2{{#2}\ttl@calc\vspace{#1}}% + \def\ttl@chapafter{40\p@}} + +\DeclareOption{bottomtitles}{% + \def\bottomtitlespace{-1\p@}} +\DeclareOption{nobottomtitles}{% + \def\bottomtitlespace{.2\textheight}} +\DeclareOption{nobottomtitles*}{% + \let\ttl@addstretch\relax + \def\bottomtitlespace{.2\textheight}} + +\DeclareOption{calcwidth}{% + \let\ttl@beginlongest\ttl@xbeginlongest} + +\DeclareOption{aftersep}{% + \let\ttl@titlespace\@gobble} +\DeclareOption{largestsep}{% + \let\ttl@titlespace\addvspace} + +\DeclareOption{oldparttoc}{% + \def\ttl@tocpart{\def\ttl@a{\thepart\hspace{1em}}}} +\DeclareOption{newparttoc}{% + \let\ttl@tocpart\relax} +\DeclareOption{notocpart*}{% + \let\ttl@notocparts\@empty} + +\DeclareOption{rm}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\rmfamily}} +\DeclareOption{sf}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\sffamily}} +\DeclareOption{tt}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\ttfamily}} +\DeclareOption{md}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\mdseries}} +\DeclareOption{bf}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\bfseries}} +\DeclareOption{up}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\upshape}} +\DeclareOption{it}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\itshape}} +\DeclareOption{sl}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\slshape}} +\DeclareOption{sc}{% + \protected@xdef\ttl@fonts{\ttl@fonts\protect\scshape}} + +\DeclareOption{big}{% + \gdef\ttl@sizes#1{\ifcase#1\relax\Huge\or\Large\or\large + \or\normalsize\or\or\or\huge\fi}} +\DeclareOption{medium}{% + \gdef\ttl@sizes#1{\ifcase#1\relax\huge\or\Large\or\large + \or\normalsize\or\or\or\LARGE\fi}} +\DeclareOption{small}{% + \gdef\ttl@sizes#1{\ifcase#1\relax\LARGE\or\large + \or\normalsize\or\normalsize\or\or\or\Large\fi}} +\DeclareOption{tiny}{% + \gdef\ttl@sizes#1{\ifcase#1\relax\large\or\normalsize\or + \normalsize\or\normalsize\or\or\or\normalsize\fi}} + +\DeclareOption{raggedleft}{% + \gdef\ttl@fil{\filleft}} +\DeclareOption{center}{% + \gdef\ttl@fil{\filcenter}} +\DeclareOption{raggedright}{% + \gdef\ttl@fil{\filright}} + +\DeclareOption{uppercase}{% + \gdef\ttl@case{\MakeUppercase}} + +\DeclareOption{compact}{% + \gdef\ttl@space{1}% + \gdef\ttl@chapafter{30\p@}} + +% Deprecated. To be remmoved in a major upgrade (3.0) +\DeclareOption{indentfirst}{% + \gdef\@afterindentfalse{\let\if@afterindent\iftrue}% + \@afterindenttrue + \def\titlespacing{% + \@ifstar{\ttl@spacing@i{\@ne}}{\ttl@spacing@i{\@ne}}}} +\DeclareOption{nonindentfirst}{% + \def\titlespacing{% + \@ifstar{\ttl@spacing@i{\z@}}{\ttl@spacing@i{\z@}}}} + +% New names +\DeclareOption{indentafter}{% + \gdef\@afterindentfalse{\let\if@afterindent\iftrue}% + \@afterindenttrue + \def\titlespacing{% + \@ifstar{\ttl@spacing@i{\@ne}}{\ttl@spacing@i{\@ne}}}} +\DeclareOption{noindentafter}{% + \def\titlespacing{% + \@ifstar{\ttl@spacing@i{\z@}}{\ttl@spacing@i{\z@}}}} + +% newlinetospace +\let\ttl@blinemarks\relax +\let\ttl@elinemarks\relax + +\DeclareRobustCommand\ttl@linetosp{% + \@ifstar{\ttl@linetosp@i}{\ttl@linetosp@i}}% + +\def\ttl@linetosp@i{% + \ifdim\lastskip>\z@\else\space\fi + \ignorespaces} + +\DeclareOption{newlinetospace}{% + \def\ttl@blinemarks{% + \let\ttl@e\\% + \def\\{\ttl@linetosp}}% + \def\ttl@elinemarks{\let\\\ttl@e}}% + +% toctitles +\def\ttl@addcontentsline#1#2{% + \addcontentsline{toc}{#1}{\ifttl@toclabel\ttl@a\fi#2}% + \nobreak} + +\DeclareOption{toctitles}{% + \def\ttl@addcontentsline#1#2{% + \addcontentsline{toc}{#1}{\ifttl@toclabel\ttl@a\fi\ttl@savetitle}% + \nobreak}} + +% pageatnewline + +\def\ttl@changecentercr{% + \let\ttl@centercr\@centercr + \def\@centercr{\@ifstar{\ttl@centercr*}{\ttl@centercr*}}} + +\DeclareOption{pageatnewline}{\let\ttl@changecentercr\relax} + +\def\ttl@fonts{} + +% nostruts + +\DeclareOption{nostruts}{% + \let\ttl@strut\@empty + \def\ttl@defnostruts{% + \let\ttl@strut\@empty + \def\nostruts{\let\ttl@strut\@empty}}} + +\ExecuteOptions{rubberchapters,bottomtitles,aftersep,oldparttoc,% + innermarks} + +\ProcessOptions + +% +-----------------+ +% | H Y P E R R E F | +% +-----------------+ +% +% These two commands are provided by hyperref. But if they +% are not defined at \begin{document} hyperref has not been +% loaded or it is an old version. + +\AtBeginDocument{% + \ifx\ttl@Hy@steplink\@undefined + \let\ttl@Hy@steplink\@gobble + \let\ttl@Hy@refstepcounter\refstepcounter + \fi} + +% +-----------------+ +% | PAGE STYLES | +% +-----------------+ +% +% This is generic: + +\newcommand\assignpagestyle[2]{% + \@namedef{ttl@ps@\expandafter\@gobble\string#1}{#2}} + +% Old pagestyles +% ~~~~~~~~~~~~~~ + +\providecommand\newpagestyle{% + \let\ttl@compatps\@empty % marks the ``old interface'' + \let\ttl@coreps\@empty + \makeatletter + \edef\ttl@d{% + \noexpand\input{titleps.sty}% + \catcode`\noexpand\@=\the\catcode`\@}% + \ttl@d + \newpagestyle} + +\providecommand\renewpagestyle{% + \let\ttl@compatps\@empty % marks the ``old interface'' + \let\ttl@coreps\@empty + \makeatletter + \edef\ttl@d{% + \noexpand\input{titleps.sty}% + \catcode`\noexpand\@=\the\catcode`\@}% + \ttl@d + \renewpagestyle} + +\providecommand\widenhead{% + \let\ttl@compatps\@empty % marks the ``old interface'' + \let\ttl@coreps\@empty + \makeatletter + \edef\ttl@d{% + \noexpand\input{titleps.sty}% + \catcode`\noexpand\@=\the\catcode`\@}% + \ttl@d + \widenhead} + +% New pagestyles +% ~~~~~~~~~~~~~~ + +\@ifundefined{sectiontitle}{}{% + \let\ttl@coreps\@empty + \input{titleps.sty}} + +% +-----------------+ +% | K E Y S | +% +-----------------+ + +\def\ttl@keys{% + \let\ttl@keys\relax + \@ifundefined{define@key}{\RequirePackage{keyval}}{}% + \def\ttl@getkeys##1##2{% + \let\ttl@a\@empty + \if\expandafter @\@gobble##1@\@empty % if there is a single token + \edef\ttl@b{\expandafter\@gobble\string##1}% + \let\ttl@a\ttl@b + \else + \ttl@labelfalse % A temporary flag: true if there is page key + \setkeys{##2}{##1}% + \ifttl@label + \@ifundefined{ttlp@\ttl@b}{% + \expandafter\let\csname ttlp@\ttl@b\endcsname\@empty}{}% + \fi + \edef\ttl@a{\ttl@b\ttl@a}% + \fi}% + % + \define@key{titlesec}{name}{% + \edef\ttl@b{\expandafter\@gobble\string##1}}% + \define@key{titlesec}{numberless}[true]{% + \csname @tempswa##1\endcsname + \if@tempswa + \edef\ttl@a{\ttl@a/*}% + \fi}% + \define@key{titlesec}{page}{% + \ttl@labeltrue % Used as flag + \edef\ttl@a{/##1\ttl@a}}% + % + \def\ttl@extra@numberless{\ttl@labeltrue}% The actual meaning + \let\ttl@key@numberless\@empty + %\let\ttl@key@matter\@empty + \let\ttlp@append\@gobbletwo + \def\ttl@setkeys##1{% + \def\ttl@trylist{\ttl@try{}}% + \@for\ttl@b:=##1\do{% + \begingroup + \let\ttl@a\relax + \def\ttl@try####1{% + \noexpand\ttl@try{####1\ttl@a{\ttl@b}}% + \noexpand\ttl@try{####1}}% + \xdef\ttl@trylist{\ttl@trylist}% + \endgroup}}% + \ttl@setkeys{page,numberless}% matter + % + \if@twoside + \newcounter{ttlp@side}% + \newcount\ttlp@side + \def\ttlp@theside{\ifodd\c@page o\else e\fi}% + \def\ttlp@append##1##2{% + {\let\@elt\relax + \expandafter\xdef\csname ttlp@##1\endcsname{% + \csname ttlp@##1\endcsname\@elt ##2}}}% + \def\ttlp@write##1{% + {\let\ttlp@theside\relax + \protected@write\@auxout{}% + {\string\ttlp@append{##1}{\ttlp@theside}}}}% + \def\ttlp@fetch##1{% + \stepcounter{ttlp@side}% + \global\advance\ttlp@side\@ne + \@whilenum\ttlp@side<\c@ttlp@side\do{% + \expandafter\@next\expandafter\@tempa\csname ttlp@##1\endcsname{}{}% + \global\advance\ttlp@side\@ne}% + \expandafter\@next\expandafter\ttl@b\csname ttlp@##1\endcsname{% + \xdef\ttl@key@page{/\if\ttl@b oodd\else even\fi}% + }{% + \xdef\ttl@key@page{/\ifodd\c@page odd\else even\fi}% + \@@warning{Unsynchronized `##1' title on page \thepage}}}% + \else + \let\ttlp@write\@gobble + \def\ttlp@fetch##1{\gdef\ttl@key@page{/odd}}% + \fi} + +% +-----------------+ +% | C O M P A T | +% +-----------------+ +% Easy setup, i.e., that of package options, is +% taken care of, if necessary. + +\renewcommand\secdef[2]{% + \@ifstar + {\ttl@labelfalse + #2} + {\ttl@labeltrue + \ifx#1\@chapter + \if@mainmatter\else\ttl@labelfalse\fi + \ifnum\ttll@chapter>\c@secnumdepth\ttl@labelfalse\fi + \else\ifx#1\@part + \ifnum\ttll@part>\c@secnumdepth\ttl@labelfalse\fi + \fi\fi + \let\ifttl@toclabel\ifttl@label + \@dblarg{#1}}} + +\@ifundefined{ttl@extract}{}{\endinput} + +\newcommand\titlelabel[1]{% + \def\@seccntformat##1{#1}} + +\expandafter\ifx\csname chapter\endcsname\relax + + \def\ttl@compatpart{\titleclass{\part}{part}\relax} + +\else + + \def\ttl@compatchapter{% + \def\@makechapterhead{% + \ttl@labeltrue + \if@mainmatter\else\ttl@labelfalse\fi + \ifnum\ttll@chapter>\c@secnumdepth\ttl@labelfalse\fi + \ttl@startargs\ttl@mkchap{chapter}}% + \def\@makeschapterhead{% + \ttl@labelfalse + \if@mainmatter\else\ttl@labelfalse\fi + \ifnum\ttll@chapter>\c@secnumdepth\ttl@labelfalse\fi + \ttl@startargs\ttl@mkchap{chapter}}} + + \def\ttl@compatpart{\titleclass{\part}{page}\relax} + +\fi + +\def\ttl@@extract#1\@startsection#2#3#4#5#6#7#8{% + \@tempskipa=#5 + \@tempskipb=#6 + \ifdim\@tempskipa<\z@ + \toks@{\titlespacing*#8{#4}}% + \@tempskipa-\@tempskipa + \else + \toks@{\titlespacing#8{#4}}% + \fi + \@ifundefined{ttl@space}{}{% + \ttl@assign\@tempskipa*\ttl@space\relax\beforetitleunit}% + \ifdim\@tempskipb<\z@ + \if@tempswa + \titleformat#8[runin]% + {\ttl@fonts\ttl@sizes{#3}}{\@seccntformat{#2}}% + {\z@}\ttl@passexplicit + \else + \titleformat#8[runin]% + {#7}{\@seccntformat{#2}}% + {\z@}\ttl@passexplicit + \fi + \@tempskipb-\@tempskipb + \else + \if@tempswa + \titleformat#8% + {\ttl@fil\ttl@fonts\ttl@sizes{#3}}{\@seccntformat{#2}}% + {\z@}\ttl@passexplicit + \else + \titleformat#8% + {#7}{\@seccntformat{#2}}% + {\z@}\ttl@passexplicit + \fi + \@ifundefined{ttl@space}{}{% + \ttl@assign\@tempskipb*\ttl@space\relax\aftertitleunit}% + \fi + \edef\ttl@a{\the\toks@{\the\@tempskipa}{\the\@tempskipb}} + \ttl@a} + +\def\ttl@extract#1{% + \ifx#1\@undefined + \let#1\relax % Avoid error if undefined + \fi + \expandafter\in@\expandafter\@startsection\expandafter{#1}% + \ifin@ + \expandafter\ttl@@extract#1#1% + \else + \PackageWarningNoLine{titlesec}% + {Non standard sectioning command \string#1\MessageBreak + detected. Using default spacing and no format}% + \titlespacing*#1{\z@}{*3}{*2}% + \fi} + +\@tempswafalse + +\ifx\ttl@fonts\@empty + \def\ttl@fonts{\bfseries} +\else + \@tempswatrue +\fi + +\expandafter\ifx\csname ttl@sizes\endcsname\relax + \gdef\ttl@sizes#1{\ifcase#1\relax\Huge\or\Large\or\large + \or\normalsize\or\or\or\huge\fi} +\else + \@tempswatrue +\fi + +\expandafter\ifx\csname ttl@fil\endcsname\relax + \let\ttl@fil\@empty +\else + \@tempswatrue +\fi + +\expandafter\ifx\csname ttl@case\endcsname\relax + \let\ttl@case\@firstofone +\else + \@tempswatrue +\fi + +\if@tempswa + + \expandafter\ifx\csname chapter\endcsname\relax\else + \titleformat\chapter[display]% + {\@ifundefined{ttl@fil}{\raggedright}{\ttl@fil}\ttl@fonts\ttl@sizes6} + {\@chapapp\space\thechapter}{.8\baselineskip}{\ttl@sizes\z@\ttl@passexplicit} + \fi + +\fi + +\ttl@extract\section +\ttl@extract\subsection +\ttl@extract\subsubsection +\ttl@extract\paragraph +\ttl@extract\subparagraph + +\let\ttl@extract\@undefined +\let\ttl@@extract\@undefined + +\def\ttl@toplevel{part} + +\expandafter\ifx\csname chapter\endcsname\relax + + \@namedef{ttll@part}{0} + \titleclass{\section}{straight}[\part] + + \titlespacing*{\part} + {\z@} + {4ex} + {3ex} + +\else + + \let\ttl@save@mkchap\@makechapterhead + \let\ttl@save@mkschap\@makeschapterhead + + \def\@makechapterhead#1{% + \gdef\ttl@savemark{\chaptermark{#1}}% + \ttl@save@mkchap{#1}% + \@ifundefined{ttl@ps@chapter}{}% + {\thispagestyle{\@nameuse{ttl@ps@chapter}}}} + + \def\@makeschapterhead#1{% + \gdef\ttl@savemark{\chaptermark{#1}}% + \ttl@save@mkschap{#1}% + \@ifundefined{ttl@ps@chapter}{}% + {\thispagestyle{\@nameuse{ttl@ps@chapter}}}} + + \@namedef{ttll@part}{-1} + \@namedef{ttlss@part}{chapter} + \@namedef{ttll@chapter}{0} + \titleclass{\section}{straight}[\chapter] + +% The following is unoperant, unless when \chapter / \part +% format is redefined + + \titlespacing*{\part} + {\z@} + {\z@\@plus1fil} + {\z@\@plus1fil} + + \titlespacing*\chapter + {\z@}% + {50\p@}% + {\ttl@chapafter}% + +\fi + +\titleclass{\subsection} {straight}[\section] +\titleclass{\subsubsection}{straight}[\subsection] +\titleclass{\paragraph} {straight}[\subsubsection] +\titleclass{\subparagraph} {straight}[\paragraph] + +\endinput + +MIT License +----------- + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +