From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/titlesec/CHANGES.old | 341 +++++ macros/latex/contrib/titlesec/README.md | 62 + macros/latex/contrib/titlesec/titleps.pdf | Bin 0 -> 134004 bytes macros/latex/contrib/titlesec/titleps.sty | 837 +++++++++++ macros/latex/contrib/titlesec/titleps.tex | 835 +++++++++++ macros/latex/contrib/titlesec/titlesec.pdf | Bin 0 -> 183112 bytes macros/latex/contrib/titlesec/titlesec.sty | 1708 ++++++++++++++++++++++ macros/latex/contrib/titlesec/titlesec.tex | 2106 ++++++++++++++++++++++++++++ macros/latex/contrib/titlesec/titletoc.sty | 600 ++++++++ 9 files changed, 6489 insertions(+) create mode 100644 macros/latex/contrib/titlesec/CHANGES.old create mode 100644 macros/latex/contrib/titlesec/README.md create mode 100644 macros/latex/contrib/titlesec/titleps.pdf create mode 100644 macros/latex/contrib/titlesec/titleps.sty create mode 100644 macros/latex/contrib/titlesec/titleps.tex create mode 100644 macros/latex/contrib/titlesec/titlesec.pdf create mode 100644 macros/latex/contrib/titlesec/titlesec.sty create mode 100644 macros/latex/contrib/titlesec/titlesec.tex create mode 100644 macros/latex/contrib/titlesec/titletoc.sty (limited to 'macros/latex/contrib/titlesec') diff --git a/macros/latex/contrib/titlesec/CHANGES.old b/macros/latex/contrib/titlesec/CHANGES.old new file mode 100644 index 0000000000..fdbcb6b1db --- /dev/null +++ b/macros/latex/contrib/titlesec/CHANGES.old @@ -0,0 +1,341 @@ +## TITLESEC + +History of v1.0 +~~~~~~~~~~~~~~~ +1998/02/25 Added nops option +1998/02/28 Added \@mkboth stuff in \setmarks +1998/03/01 Changed test in \ttl@secnum +1998/03/03 Corrected some \fil... commands +1998/03/03 Replaced the faulty \@hangfrom by new commands +1998/03/03 Some \def replaced by \newcommand +1998/03/04 .dtx/.ins scheme finally rejected. Useless + for users, obtrusive for `readers' and proned + to errors +1998/03/04 Tidied up documentation +1998/03/06 \wordsep renamed and documented +1998/03/06 Added dummy asignation in \ttl@chap. +1998/03/06 Removed \ttl@xsect and merged into \tl@sect +1998/03/06 Added \ProvidesPackage + +History of v1.1 +~~~~~~~~~~~~~~~~ +1998/03/25 \chapter corrected, as well as the size options +1998/03/26 Added compact option +1998/03/26 Added flushleft, flushright and center options +1998/04/08 Changed all instances of \noindent by \parindent\z@ +1998/04/14 Added \filinner, \filouter +1998/04/14 Added drop shape +1998/05/01 Added rightmargin shape (and margin renamed to + leftmargin) +1998/05/03 Added \setheadindent + +History of v1.2 (unreleased) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +1998/06/01 Compatibility with AMS classes +1998/06/08 On-demand loading of shapes +1998/06/11 Frame shape. Some \fil... command + modified to work in the label of this + chapter shape. +1998/07/03 Bottomtitle option (at last...) +1998/07/14 ...margin styles bug fixed using a method + similar to bottomtitle. +1998/07/29 \titleline + +==================== + +History of v2.0 +~~~~~~~~~~~~~~~~ + +1998/08/05 to +1998/08/29 Fully reimplemented + +History of v2.1 +~~~~~~~~~~~~~~~~ +1999/01/05 We define in this file the three basic shapes. + Additional ones remain defined in external files. + Unified the shapes for sections and chapters. +1999/01/05 \ttl@shape merged into \ttl@format@iii. +1999/01/05 \titlerule +1999/01/07 \ttl@defkeys splitted from \ttl@keys +1999/01/10 Added the \part stuff, including a definition of \@openright +1999/01/11 Removed unnecessary \ttl@numsecfalse in \ttl@sect@i. +1999/01/14 Optimized \titlerule +1999/01/27 Changed \titleline to correct the spacing at the + top page and to fix a bug which changed the mode + to horizontal, thus introducing unwanted space + (\makebox -> \@makebox). +1999/02/02 \ttl@secnum renamed to \ttl@write and introduced the + \ttl@savewrite mechanism to sincronize the toc/marks + with the title in case there is a \newpage in . +1999/02/03 wrap shape +1999/02/03 Added a \kern\z@ for not to avoid hyphenation + of the last word. Not strictly necessary, but + it is more LaTeX-like. +1999/02/05 \partmark defined (and in \setmarks, too). +1999/02/08 \ttl@row@i simplified. +1999/02/08 \ttl@savefn mechanism. +1999/02/10 Removed extra \leavevmode in display +1999/02/13 Now \titleline doesn't add the width. It's set. +1999/02/17 The part mark is catched, even if unused. +1999/02/17 old/newparttoc added. +1999/02/18 Changed many TeX assignments to the LaTeX + counterpart. +1999/02/19 Introduced \ttl@startargs. + +History of v2.1.1 +~~~~~~~~~~~~~~~~~ +1999/08/04 Moved misplaced lines in \ttl@makeboth + +History of v2.2 (unreleased) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +1999/11/03 We load titleps if pagestyles are required, but + some old definitions are restored. +1999/11/06 Improved outermarks test in \ttl@sect@i. Formerly + the section number could be printed if a page ended + with an unnumebered section followed by a numbered one. +1999/11/06 \ttl@startargs now adds (and passes) automatically the + section name. Involved macros modified accordingly. +1999/11/06 Replaced explicit part names by the parameter in + \ttl@part@i. The same for chapter. +1999/11/21 \ttl@try's are not given explicitly, but built by + \ttl@setkeys. Intruduced the \ttl@key@... and + \ttl@extra@... commands. +1999/11/23 Minor problems with keys fixed. +1999/12/10 Added the nobottomtitles* option and \ttl@addstretch. +2000/01/07 First steps towards the calcwidth feature (basic code). +2000/01/08 (Continued.) \titleline* for rules of width \titlewidth. + Option calcwidth implemented. +2000/01/12 Finished with changes in wrap.tss (no longer + "experimental" :-) ) + +History of v2.3 +~~~~~~~~~~~~~~~ +2000/01/19 All keys are grouped in a single file tttkeys. Removed + page.tsk and deleted the corresponding code in the sty. +2000/01/19 Classes begun. +2000/01/19 The level numbers are stored in \ttll@ macros, and not + passed as arguments. +2000/01/21 Introduced the new mark scheme. It's mostly compatible + with the old one, but a compatibility mode seems + imposible (it was introduced in a preliminary test + but eventually removed). +2000/01/23 loadonly package option. +2000/02/01 Classes finished. Many things had to be rewritten. +2000/02/02 Made partially compatible with hyperref (dvips). +2000/02/08 \ttl@savewrite moved from shapes to classes. But + explicit page breaks expand it, too, to avoid wrong + toc entries. +2000/02/18 A new box named \ttl@box stores the title in runin + leftmargin etc shapes, to increase reliability. + +(2.3.1 -- 2.3.3 No changes on this file) + +History of v2.3.4 +~~~~~~~~~~~~~~~~~ +2000/05/12 nonindentfirst redefine \titlespacing instead of + \@afterindent... so that they don't interfere with + the first entry in tocs. +2000/05/17 The marks in \ttl@select are protected to prevent + endless loop if the title is expanded, say, by + \MakeUppercase. + +History of v2.3.5 +~~~~~~~~~~~~~~~~~ +2000/05/21 Restores missing test for secnumdepth in \ttl@mkchap, + and instead of setting \ttl@toclevel in ttlps now is + done in \secdef. Except inside the macros, \ttl@toclevel + is false, so that an explicit \...mark works. +2000/06/04 \partmark defined with \providecommand +2000/06/14 A patch mechanism added, for small bug fixes. + +History of v2.4 +~~~~~~~~~~~~~~~~ +2001/01/18 Minor changes in code. Essentialy an incremental + update. +2001/01/22 \titleformat has a new "easy" starred variant. + +History of v2.5 +~~~~~~~~~~~~~~~ +2002/01/02 New macros for \ttl@assign. Now * length allow + non integer values. +2002/03/22 Added \ttl@calc and \ttl@calcneg to make titlesec + calc-savvy. + - Merged bug fixes of .new into this file. + - Bugs in frame fixed -- gap in lines, misplaced + label, wrong margins (sometimes), + - \leftskip, \rightskip and \linewidth (re)set in + margin shapes. + - Removed obsolete flush... options. + - indentafter and noindentafter, new names for + indentfirst and nonindentfirst. + - A new level (\titleclass) without its "location" + now raises a meaningful error. + - Bug in top-level \titleclass fixed. +2002/03/23 Tests for undefined and unformatted sectioning levels, + and horizontal material in . + - Missing \if@openright inside \if@twoside in + page class added. + - Removed extra (but inoffensive) \expandafter + in \ttl@class@iii. +2002/03/27 Added \titlewidthfirst and ...last + - "Not definable" gives a more meaningful message in + the context of the package. + +History of v.2.6 +~~~~~~~~~~~~~~~~ +2004/08/30 Corrected typo in margin \hsiz -> \hsize. +2004/10/17 Added a couple of missing \noexpand's in drop. +2004/12/01 Removed the error about the mode in block because this + style is general purpose. +2005/01/16 Missing braces around #2 in the last else part of + \ttl@headinline added + - Replaced explicit \makeatother's by a saved value as + the macros can be used in a class/package file. +2005/01/18 newlinetospace mechanism + - // does not break pages; option pageatnewline to + restore the LaTeX behaviour. +2005/01/19 \...break in top shape. + - Renumbered several scratch registers to follow the + TeXbook (p. 346), with \ttl@box in a few cases. In + wrap \titlewidthfirst and \titlewidthlast made global. + - Float heads and foots have now a further argument for + additional stuff (eg, to remove rules). Option is now + psfloats while floatps enters in compatibility mode. + - \ttl@savetitle in all classes. Option toctitles. +2005/01/21 Changed pageatnewline to make it compatible with + titletoc, with \ttl@changecentercr. +2005/01/22 \...tolist in top class. + +History of v.2.7 +~~~~~~~~~~~~~~~~ +2007-03-27 Added the `explicit' option. + - Added \titlepagestyle. +2007-03-29 Fixed wrong number for chapter in log + - Patch file named .270 instead of .new +2007-05-09 Added to leftmargin, so that you can add stuff + at the beginning of the paragraph, eg, the sec number. +2007-07-07 Removed the patch mechanism. +2007-08-07 `explicit' improved. + +History of v.2.8 +~~~~~~~~~~~~~~~~ +2007-08-12 \titlepagestyle already used by KOMA-Script. Renamed + to \assignpagestyle. + +History of v.2.9 +~~~~~~~~~~~~~~~~ +2010-05-04 Add \nobreak in \ttl@addcontentsline, to prevent the title + going to footnotes (!) in runin style in some (rare) cases. +2010-05-06 Option uppercase (and \ttl@case). +2011-02-25 \iftitlemeasuring test +2011-07-14 Fixed \assignpagestyle +2011-07-15 Introduced the \scantokens mechanism to make sure section + names are 'letters' and not 'others' +2011-07-18 Removed \if@nobreak test in wrap/drop, which added a line + to the title after another section (why?) + +History of v.2.9.1 +~~~~~~~~~~~~~~~~~~ +2011-08-28 Removed a spurious > in wrap.tss + +History of v.2.9.2 +~~~~~~~~~~~~~~~~~~ +2011-11-11 Fixed a typo in ttlps.def (\MessageBreag) + +History of v.2.10.0 +~~~~~~~~~~~~~~~~~~~~ + +2011-12-15 Split titlesp + +History of v.2.10.1 +~~~~~~~~~~~~~~~~~~~~ + +2015-02-27 Fix: An explict \newpage in 'after' wrote the toc entry twice +2015-03-09 Fix (partial): A list containing just a sectioning command + raised an error + +History of v.2.10.2 +~~~~~~~~~~~~~~~~~~~~ + +2015-03-21 Fix: With 2.10.1 labels vanished in hang shape (due to a + misplaced \noindent) + +## TITLEPS + +History of v.1.1.1 +~~~~~~~~~~~~~~~~~~ +2016-03-15 New macro \setmarkboth for compatibility + +## TITLETOC + +History of v1.1 +~~~~~~~~~~~~~~~ +99/04/22: A bug fix. Some missing global assignments in \ttl@tocentry + were missing, and page numbers messed up with + \titlecontents* + +History of v1.2 +~~~~~~~~~~~~~~~~ +1999/10/20: Added \contentsafter. \ttl@tocentry modified to accept + the new command for grouping in a paragraph entries of + different levels. +1999/10/27: Instead of defining the level numbers explicitly, that's + done with \ttl@setlevels and \ttl@levels. +1999/10/27: Added the basic code for multiple indexes. +1999/10/29: Added the toctop test to the \ttl@savel@... commands. +1999/12/28: Simplified \ttl@savel@... with \ttl@lselect. +2000/01/12: \contentsafter rejected. An aditional optional parameter + is used instead. (Too) many thing had to be rewritten. +2000/01/27: Removed \ttl@setlevels. Any change of levels are + best done with titlesec. +2000/02/14: Moved misplaced \vskip in ttl@tocentry. +2000/02/16: A few changes in the "block" separators. +2000/02/16: Fixed bug in \ttl@margin. For the right margin the + correction was used instead of the margin. + +History of v1.2.1 +~~~~~~~~~~~~~~~~~ +2000/04/25: Dirty trick to make sure that \ttl@finish is the very + last thing in lists of floats (lof, lot, etc.). +2000/05/14: Missing \global before \ttl@labelfalse added. + +History of 1.2.2 +~~~~~~~~~~~~~~~~ +2000/06/05: The optional argument no longer mandatory, but + still reporting an error if the length is missing. + Minor internal changes, and a patch mechanism added. + +History of 1.3 +~~~~~~~~~~~~~~ +2001/01/12: Minor changes and some missing \globals added for + partial tocs to work inside a group. +2001/01/21: Added \dottedcontents. + +History of 1.4 +~~~~~~~~~~~~~~ +2002/03/27: titletoc.new merged into this file +2002/03/27: \ttl@finish written by the last \newpage. +2002/03/27: \ttl@lsection broke paragraphs always. Now + only if the sublevel is typeset. +2002/03/27: \ttl@finish -> \contentsfinish + +History of 1.5 +~~~~~~~~~~~~~~ +2003/06/14: \contentspush didn't work because of the change of +(.new) \leftskip was done inside a group before the + corresponding \par +2003/06/14: Added an useful error if a partial TOC is not +(.new) defined. +2005/01/17: New options rubber/rigidseps, to remove if desired + the small vertical "plus" between entries. +2005/01/20: Begin work on partial lists. +2005/01/21: \ttl@outblock and \ttl@outnoblock just to avoid a + huge definition and to ease patching. +2005/01/22: Work on partial lists finished (but to be resumed). + +History of 1.6 +~~~~~~~~~~~~~~ +2007/05/04: Added the patch 2005/05/03 which fixed a wrong + result with \included (F. Mittelbach) +2007/07/14: Removed the patch mechanism. diff --git a/macros/latex/contrib/titlesec/README.md b/macros/latex/contrib/titlesec/README.md new file mode 100644 index 0000000000..1b9250a712 --- /dev/null +++ b/macros/latex/contrib/titlesec/README.md @@ -0,0 +1,62 @@ +## Titlesec, Titletoc, Titleps + +This directory holds 3 packages for sectioning titles -- when used as +such (titlesec), in headers and footers (titleps) and in tables of +contents (titletoc). They can be used separately, but you will get +most of them when used together. + +### Titlesec + +Sectioning titles, including margin and `wrap` titles, different +format in odd and even pages, rules above and below the title, +adding new sectioning levels, measuring the width of the title, etc. + +### Titletoc + +TOC entries, with the possibility of changing the format in the middle +of a document, grouping the entries in a single paragraph, pretty +free-forms entries, partial tocs, etc. It's described in +`titlesec.pdf`. + +### Titleps + +Page styles with working top marks, access to top, first and bot marks +in a single header/footer, rules, headers/footers for specific floats +(kinda `\thispagestyle`), multiple sets of marks, etc. An one-stage +mechanims is used, without intermediate `\leftmark`s or `\rightmark`s. + +### Latest changes + +``` +2.11 2019-07-16 + - New license: MIT. + - Option nostruts, to remove struts inserted by titlesec. + - Reorganized code: only sty files, removed def and tss ones + (although the mechanism for tss still works). + - Fix - Wrong hyperlinks in table of contents with the starred + versions, because of a change of behavior of hyperref (it + patches the behaviour of an internal macro in hyperref). + - Fix - Wrong spacing with titleps and displayed text after a + section. + - Fix - Newly defined floats raised an error with titletoc. +``` + +### Installation + +No .ins/.dtx preinstalation is required. Move the files to a place +where LaTeX can find them and typeset titlesec.tex. All of files in +this directory are necessary for titlesec.sty to work, except the +manual titlesec.tex (and this 'readme' file). The manual requires +titlesec.sty and titletoc.sty. + +Further details are available on + + http://www.texnia.com/titlesec.html + +### Contact + +Please, for suggestions, bug reports, etc., go to +More + http://www.texnia.com/contact.html + + diff --git a/macros/latex/contrib/titlesec/titleps.pdf b/macros/latex/contrib/titlesec/titleps.pdf new file mode 100644 index 0000000000..cef3495fdf Binary files /dev/null and b/macros/latex/contrib/titlesec/titleps.pdf differ diff --git a/macros/latex/contrib/titlesec/titleps.sty b/macros/latex/contrib/titlesec/titleps.sty new file mode 100644 index 0000000000..2d2a03cbea --- /dev/null +++ b/macros/latex/contrib/titlesec/titleps.sty @@ -0,0 +1,837 @@ +% +% 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 +% +% +% Release +% ~~~~~~~ + +\ifx\ttl@coreps\@empty\else % START code for package + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{titleps}[2019/07/16 v2.11 Page styles] + +% This package is mainly a wrapper for the pagestyle macros provided +% by titlesec, so that they can be used without it. Functionality is +% almost similar. First, some definitions from titlesec. + +\expandafter\newif\csname ifttl@ps\endcsname +\expandafter\newif\csname ifttl@toclabel\endcsname +\ttl@toclabeltrue + +\def\ttl@calcneg#1#2{% + {\setlength\@tempskipa{#2}% + #1{-\@tempskipa}}} + +\expandafter\newif\csname ifttl@premark\endcsname +\ttl@premarkfalse + +% 2019-02-25. 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}% + \csname#1mark\endcsname{#2}% + \ifx\ttl@lastskip\relax\else + \vskip\ttl@lastskip\relax + \fi + \gdef\ttl@prevmarks{\ttl@marks}} + +\let\ttl@savemark\@empty + +% Patching sectioning commands + +\newcommand\TitlepsPatchSection{% + \@ifstar{\ttl@setsec\@gobbletwo}% + {\ttl@setsec\pretitlemark}} + +\def\ttl@setsec#1#2{% + \@ifundefined{#2}{}{% + \expandafter\let\csname ttl@s@#2\expandafter\endcsname + \csname#2\endcsname + \@namedef{#2}{% + \@ifstar{\ttl@presec@s{#2}}% + {\@dblarg{\ttl@presec@x#1{#2}}}}}}% + +% premark/gobble, sect-name, opt, title +\def\ttl@presec@x#1#2[#3]#4{% + #1{#2}{#3}% + \@nameuse{ttl@s@#2}[#3]{#4}} + +\def\ttl@presec@s#1#2{% + \gdef\ttl@savemark{\@nameuse{#1mark}{#2}}% + \@nameuse{ttl@s@#1}*{#2}} + +\def\ttl@atbegin{% + \TitlepsPatchSection*{chapter}% + \TitlepsPatchSection{section}% + \TitlepsPatchSection{subsection}% + \TitlepsPatchSection{subsubsection}% + \TitlepsPatchSection{paragraph}% + \TitlepsPatchSection{subparagraph}} + +\AtBeginDocument{\ttl@atbegin} + +% Package options + +\DeclareOption{psfloats}{\let\ttl@replace\@empty} % a flag + +\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{extramarks}{\let\ttl@fetchmark\@empty} +\DeclareOption{nopatches}{\let\ttl@atbegin\relax} + +\ExecuteOptions{innermarks} + +\ProcessOptions + +% Load the package body + +\let\newpagestyle\@empty +\let\renewpagestyle\@empty +\let\widenhead\@empty + +\fi % PAUSE code for package + +% START core code + +% As before, all marks has two parts but now they don't refer to left or +% right pages at all. There are some issues related to top marks which +% are explained by Knuth in \textit{The \TeX book}, pp. 259f, as well +% as an incompatibility between them and \LaTeX{} floats. To overcome +% both limitations, in the \textsf{titleps} page styles, the second +% part in |\cs{firstmark}| is a \emph{fixed} top mark and the first one +% the actual first mark; the right way to get the bot mark is from the +% second part. Marks are stored at each section and used before and +% after the title (straight class); the first part contains the values +% of current title, but the second one contains the previously stored +% values in the mark before the title, and the current values in the +% mark after. + +\ifx\ttl@compatps\@undefined\else + \PackageWarningNoLine{titlesec} + {You are using an old interface for page styles\MessageBreak + (or you forgot the package option 'pagestyles').\MessageBreak + You could proceed but don't complain if you run\MessageBreak + into errors} +\fi + +\ttl@pstrue + +\let\parttitle\@empty +\let\chaptertitle\@empty +\let\sectiontitle\@empty +\let\subsectiontitle\@empty +\let\subsubsectiontitle\@empty +\let\paragraphtitle\@empty +\let\subparagraphtitle\@empty + +\newcommand\iftitle[1]{% + \expandafter\ifx\csname #1title\endcsname\@empty + \expandafter\@secondoftwo + \else + \expandafter\@firstoftwo + \fi} + +% \newtitlemarks belongs to a nameless markset (ie, \@empty). +% For named extra marksets see below. + +\newcommand\newtitlemark{% + \@ifstar{\@tempswafalse\ttl@newmk@i\@empty}% + {\@tempswatrue\ttl@newmk@i\@empty}} + +\def\ttl@newmk@i#1#2{% markset, macro/var + \edef\ttl@a{\expandafter\@gobble\string#2}% + \expandafter\ifx\csname\ttl@a\endcsname#2\else + \edef\ttl@a{c@#2}% + \fi + \expandafter\ttl@newmk@ii\expandafter{\ttl@a}{#1}} + +\def\ttl@newmk@ii#1#2{% macro/var, markset + \expandafter\let\expandafter\ttl@a\csname ttl@mks@#2\endcsname + \if@tempswa + \expandafter\def\expandafter\ttl@a\expandafter{% + \ttl@a + \protect\@namedef{#1}{\@nameuse{#1}}}% + \else + \expandafter\def\expandafter\ttl@a\expandafter{% + \ttl@a + \protect\@nameuse{#1}=\the\@nameuse{#1}\relax}% + \fi + \expandafter\let\csname ttl@mks@#2\endcsname\ttl@a} + +\let\ttl@mks@\@empty +\def\ttl@moremarks{\ttl@mks@} % backward compat + +\def\ttl@prevmarks{\ttl@marks} +\let\ttl@marks\relax + +% The following command sets the ifthe... commands to +% be used in heads. When the call is from inside a sectioning +% command, toclabel is either true (in most of cases) or false +% (a chapter in the front matter, for example). Otherwise (an +% explicit \...mark) is false + +\def\ttl@setifthe#1{% + \expandafter\protected@edef\csname ifthe#1\endcsname{% + \ifttl@toclabel + \protect\@firstoftwo + \else + \protect\@secondoftwo + \fi}} + +% At this point \ttl@toclabel is always false + +\ttl@setifthe{part} +\ttl@setifthe{chapter} +\ttl@setifthe{section} +\ttl@setifthe{subsection} +\ttl@setifthe{subsubsection} +\ttl@setifthe{paragraph} +\ttl@setifthe{subparagraph} + +% Putting marks +% ------------- + +\newtitlemark{\ttl@running} +\let\ttl@enccode\relax +\def\ttl@running{\ttl@enccode} + +% \ttl@markboth redefines temporarily \mark to fetch changes made by +% babel or ams, saved in \ttl@running. When this is done, the actual +% \mark es emitted, which has \ttl@running as part of the markset (see +% the \newtitlemark above). + +\def\ttl@mb@mark{\markboth} +\def\ttl@mb@warn{% + \PackageWarningNoLine{titleps} + {Direct use of \string\markboth\space and \string\markleft\space + can lead\MessageBreak + to unpredictable results. Please, read the manual\MessageBreak + for an explanation of this warning.}} + +\def\ttl@markboth#1{% + \begingroup + \let\protect\@unexpandable@protect + \let\@mkboth\@gobbletwo + \let\ttl@enccode\relax + \let\label\relax + \let\index\relax + \let\glossary\relax + \let\ttl@c\mark + \def\mark##1{\xdef\ttl@running{\expandafter\@gobble##1}}% + \ttl@mb@mark{}{\ttl@enccode}% + \expandafter\let\csname#1mark\endcsname\@gobble + \xdef\ttl@marks{\ttl@marks}% + \gdef\@themark{{\ttl@marks}{\ttl@prevmarks}}% + \ttl@c{\@themark\let\noexpand\ttl@mb@warn\relax}% + \@nameuse{ttl@tem@#1}% + \if@nobreak\ifvmode\nobreak\fi\fi + \endgroup} + +\newcommand\settitlemarks{\@ifstar\ttl@svmarks@s\ttl@svmarks@x} + +\def\ttl@svmarks@x#1{\def\ttl@marksset{{#1}}} +\def\ttl@svmarks@s#1{\def\ttl@marksset{*{#1}}} + +\newcommand\setmarks[2]{\settitlemarks{#1,#2}} % back compat + +\def\ttl@settopmark#1\@@{% + \expandafter\def\csname#1mark\endcsname##1{% + \expandafter\gdef\csname#1title\endcsname{##1}% + \ttl@setifthe{#1}% + \expandafter\let\expandafter\ttl@marks\csname ttl@tm@#1\endcsname + \ttl@markboth{#1}}% + \global\@namedef{ttl@tm@#1}{% + \protect\@namedef{#1title}{\@nameuse{#1title}}% + \protect\@namedef{the#1}{\@nameuse{the#1}}% + \protect\@namedef{ifthe#1}{\@nameuse{ifthe#1}}}% + \def\ttl@elt##1{% + \expandafter\ttl@setsubmark\ttl@a\@@{##1}}% + \ttl@c}% + +\def\ttl@setsubmark#1\@@#2{% + \expandafter\g@addto@macro\csname ttl@tm@#2\endcsname{% + \protect\@namedef{#1title}{}% + \protect\@namedef{the#1}{}% + \protect\@namedef{ifthe#1}{\protect\@secondoftwo}} + \expandafter\g@addto@macro\csname ttl@tm@#1\endcsname{% + \protect\@namedef{#2title}{\@nameuse{#2title}}% + \protect\@namedef{the#2}{\@nameuse{the#2}}% + \protect\@namedef{ifthe#2}{\@nameuse{ifthe#2}}}}% + +\def\ttl@setmarks@x#1{% + \let\ttl@c\@empty % sub list + \@for\ttl@a:=#1\do{% + \expandafter\ttl@settopmark\ttl@a\@@ + \let\ttl@elt\relax + \xdef\ttl@c{\ttl@c\ttl@elt{\ttl@a}}}% + \@for\ttl@a:=#1\do{% + \expandafter\g@addto@macro\csname ttl@tm@\ttl@a\endcsname{% + \ttl@moremarks}}} + +\def\ttl@setmarks@s#1{% Solo con extramarks + \PackageError{titleps}% + {You need `extramarks' for \string\settitlemarks*}% + {\string\settitlemarks* requires the package option `extramarks'}} + +\newcommand\pretitlemark{% + \global\ttl@premarktrue + \@ifstar{\ttl@pretitlemark\z@}% + {\ttl@pretitlemark\@ne}} + +\def\ttl@pretitlemark#1#2#3{% + \addtocounter{#2}#1% + \ttl@premark{#2}{#3}% + \addtocounter{#2}{-#1}} + +% Rules +% ----- + +\newcommand\headrule{\setheadrule{.4\p@}} +\newcommand\footrule{\setfootrule{.4\p@}} + +\newcommand\setheadrule[1]{% + \ifdim#1=\z@ + \let\makeheadrule\@empty + \else + \def\makeheadrule{\rule[-.3\baselineskip]{\linewidth}{#1}}% + \fi} +\newcommand\setfootrule[1]{% + \ifdim#1=\z@ + \let\makefootrule\@empty + \else + \def\makefootrule{\rule[.7\baselineskip]{\linewidth}{#1}}% + \fi} + +\renewcommand\newpagestyle[1]{% + \begingroup + \catcode`\^^M=9 + \@ifnextchar[% + {\ttl@pagestyle\newcommand{#1}}% + {\ttl@pagestyle\newcommand{#1}[]}} + +\renewcommand\renewpagestyle[1]{% + \begingroup + \catcode`\^^M=9 + \@ifnextchar[% + {\ttl@pagestyle\renewcommand{#1}}% + {\ttl@pagestyle\renewcommand{#1}[]}} + +\def\ttl@pagestyle#1#2[#3]#4{% + \endgroup + \expandafter#1\csname ps@#2\endcsname{% + \ttl@defaultps + \def\ttl@headfmt{#3}% + #4% + \def\settitlemarks{\@ifstar\ttl@svmarks@s\ttl@svmarks@x}}} + +\def\ttl@userunning#1#2{\csname ttlr@#1#2\endcsname} + +\def\ttl@defaultps{% + \let\makeheadrule\@empty + \let\makefootrule\@empty + \def\@mkboth{\ttl@savemark\@gobbletwo}% + \def\@oddfoot{\ttl@userunning of}% + \def\@evenfoot{\ttl@userunning ef}% + \def\@oddhead{\ttl@userunning oh}% + \def\@evenhead{\ttl@userunning eh}% + \def\ttlr@of{\ttl@makefoot\@empty\@@\ttl@hiol\ttl@hior}% + \def\ttlr@ef{\ttl@makefoot\@empty\@@\ttl@hiel\ttl@hier}% + \def\ttlr@oh{\ttl@makehead\@empty\@@\ttl@hiol\ttl@hior}% + \def\ttlr@eh{\ttl@makehead\@empty\@@\ttl@hiel\ttl@hier}% + \let\ttlr@of@b\relax \let\ttlr@of@p\relax + \let\ttlr@ef@b\relax \let\ttlr@ef@p\relax + \let\ttlr@oh@t\relax \let\ttlr@oh@p\relax + \let\ttlr@eh@t\relax \let\ttlr@eh@p\relax + \def\settitlemarks{\@ifstar\ttl@setmarks@s\ttl@setmarks@x}% + \expandafter\settitlemarks\ttl@marksset} + +\@ifundefined{chapter}% + {\settitlemarks{section,subsection}}% + {\settitlemarks{chapter,section}} + +\newcommand\usepage{\protect\thepage} % back compat + +\newcommand\toptitlemarks{\expandafter\@secondoftwo\firstmark{}{}{}} +\def\firsttitlemarks{% + \toks@\expandafter\expandafter\expandafter{% + \expandafter\@secondoftwo \firstmark{}{}{}}% + \@temptokena\expandafter\expandafter\expandafter{% + \expandafter\@secondoftwo \botmark{}{}{}}% + \edef\ttl@a{\the\toks@}% + \edef\ttl@b{\the\@temptokena}% + \ifx\ttl@a\ttl@b + \expandafter\@secondoftwo\firstmark{}{}{}% + \else + \expandafter\@firstoftwo \firstmark{}{}{}% + \fi} +\newcommand\bottitlemarks{\expandafter\@secondoftwo\botmark{}{}{}} +\newcommand\nexttoptitlemarks{\expandafter\@firstoftwo\botmark{}{}{}} +\newcommand\outertitlemarks{% + \if@twoside + \ifodd\c@page\relax + \bottitlemarks + \else + \toptitlemarks + \fi + \else + \toptitlemarks + \fi} +\newcommand\innertitlemarks{% + \if@twoside + \ifodd\c@page\relax + \firsttitlemarks + \else + \bottitlemarks + \fi + \else + \bottitlemarks + \fi} + +\def\ttl@duplthreeargs#1#2#3#4{#1[#2][#3][#4]{#2}{#3}{#4}} +\def\ttl@dupltwoargs#1#2#3{#1[#2][#3]{#2}{#3}} +\def\ttl@duplthreeargsrev#1#2#3#4{#1[#4][#3][#2]{#2}{#3}{#4}} +\def\ttl@dupltwoargsrev#1#2#3{#1[#3][#2]{#2}{#3}} + +\def\ttl@setany#1{% + \@ifstar{\ttl@duplthreeargsrev#1}% + {\@ifnextchar[{#1}{\ttl@duplthreeargs#1}}} + +\newcommand\setfoot{\ttl@setany\ttl@setfoot} +\newcommand\sethead{\ttl@setany\ttl@sethead} + +\def\ttl@setfoot[#1][#2][#3]#4#5#6{% + \def\ttlr@ef{\ttl@makefoot{#1}{#2}{#3}\@@\ttl@hiel\ttl@hier}% + \def\ttlr@of{\ttl@makefoot{#4}{#5}{#6}\@@\ttl@hiol\ttl@hior}} + +\def\ttl@sethead[#1][#2][#3]#4#5#6{% + \def\ttlr@eh{\ttl@makehead{#1}{#2}{#3}\@@\ttl@hiel\ttl@hier}% + \def\ttlr@oh{\ttl@makehead{#4}{#5}{#6}\@@\ttl@hiol\ttl@hior}} + +\def\ttl@headinline#1#2#3{% + \ttl@headfmt + \def\ttl@a{#1#3}\def\ttl@b{#2}% + \ifx\ttl@a\@empty + \hfil{#2}\hfil + \else\ifx\ttl@b\@empty + {#1}\hfil{#3}% + \else + \sbox\z@ {#1}% + \sbox\tw@{#3}% + \copy\z@ + \ifdim\wd\z@<\wd\tw@ + \kern-\wd\z@\kern\wd\tw@ + \fi + \hfil{#2}\hfil + \ifdim\wd\z@>\wd\tw@ + \kern-\wd\tw@\kern\wd\z@ + \fi + \box\tw@ + \fi\fi} + +\def\ttl@makeboth#1#2#3#4{% + \ttl@calcneg\hspace{#3}% + \normalsize + \linewidth\textwidth + \addtolength\linewidth{#3}% + \addtolength\linewidth{#4}% + \ifx#2\@empty\else + \setbox\z@\hb@xt@\linewidth{% + \color@begingroup + #2% + \color@endgroup}% + \wd\z@\z@ + \ht\z@\z@ + \dp\z@\z@ + \box\z@ + \fi + \ttl@titlemarks % Must precede the format. Defines \ttl@running + \def\ttl@enccode{\ttl@headinline#1{}{}{}}% which contains ttl@enccode + \ttl@running + \ttl@calcneg\hspace{#4}}% + +\def\ttl@makehead#1\@@{\ttl@makeboth{#1}\makeheadrule} +\def\ttl@makefoot#1\@@{\ttl@makeboth{#1}\makefootrule} + +\renewcommand\widenhead{% + \@ifstar{\ttl@dupltwoargsrev\ttl@widenhd}% + {\@ifnextchar[{\ttl@widenhd}{\ttl@dupltwoargs\ttl@widenhd}}} + +\def\ttl@widenhd[#1][#2]#3#4{% + \def\ttl@hiel{#1}\def\ttl@hier{#2}% + \def\ttl@hiol{#3}\def\ttl@hior{#4}} + +\let\setheadindent\widenhead + +\def\ttl@hiel{\z@}\def\ttl@hier{\z@} +\def\ttl@hiol{\z@}\def\ttl@hior{\z@} + +% A tool: + +\def\ifsamemark#1#2{% + {#1\global\let\ttl@c#2}% + \ifx\ttl@c#2% + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi} + +% Another tool: + +\newcommand\setmarkboth{% + \ifx\markboth\ttl@mb@use\else + \let\ttl@mb@mark\markboth + \let\markboth\ttl@mb@use + \fi + \def\ttl@mb@new##1##2} + +% \ttl@mb@temp is a trick to allow resetting inside \setmarkboth. + +\def\ttl@mb@use#1#2{% + \let\markboth\ttl@mb@mark + \def\ttl@mb@temp{\let\markboth\ttl@mb@use}% + \ttl@mb@new{#1}{#2}% + \ttl@mb@temp + \let\ttl@mb@temp\@undefined} + +\newcommand\resetmarkboth{% + \ifx\ttl@mb@temp\@undefined + \let\markboth\ttl@mb@mark + \def\ttl@mb@mark{\markboth}% + \else + \def\ttl@mb@temp{% + \let\markboth\ttl@mb@mark + \def\ttl@mb@mark{\markboth}}% + \fi} + +% =========== +% EXTRA MARKS +% =========== + +\ifx\ttl@fetchmark\@empty + +\ifx\newmarks\@undefined + \PackageInfo{titleps}{% + You have requested `extramarks' but etex or similar\MessageBreak + has not been loaded. I'll do it for you.} + \RequirePackage{etex} +\fi + +\def\ttl@setmarks@s#1{% + \@for\ttl@a:=#1\do{% + \@ifundefined{ttl@mkc@\ttl@a}{% + \expandafter\newmarks\csname ttl@mkc@\ttl@a\endcsname}{}% + \expandafter\xdef\csname ttl@tem@\ttl@a\endcsname{% + \marks\expandafter\noexpand\csname ttl@mkc@\ttl@a\endcsname + {\noexpand\@themark}}}% + \ttl@setmarks@x{#1}}% + +\newcommand\newmarkset[1]{% + \expandafter\newmarks\csname ttl@mkc@#1\endcsname + \@namedef{ttl@mks@#1}{}% + \@namedef{ttl@premks@#1}{\@nameuse{ttl@mks@#1}}} + +\newcommand\newextramark{% + \@ifstar{\@tempswafalse\ttl@newmk@i}% + {\@tempswatrue\ttl@newmk@i}} + +\def\ttl@extramark#1{% + \begingroup + \let\protect\@unexpandable@protect + \let\@mkboth\@gobbletwo + \let\label\relax + \let\index\relax + \let\glossary\relax\endgroup} + +\newcommand\extramark[1]{% + \begingroup + \let\protect\@unexpandable@protect + \let\@mkboth\@gobbletwo + \let\label\relax + \let\index\relax + \let\glossary\relax + \marks\csname ttl@mkc@#1\endcsname{% + {\@nameuse{ttl@mks@#1}}% + {\@nameuse{ttl@mks@#1}}}% + \expandafter\xdef\csname ttl@premks@#1\endcsname + {\@nameuse{ttl@mks@#1}}% + \endgroup + \if@nobreak\ifvmode\nobreak\fi\fi}% + +\newcommand\preextramark[1]{% + \begingroup + \let\protect\@unexpandable@protect + \let\@mkboth\@gobbletwo + \let\label\relax + \let\index\relax + \let\glossary\relax + \marks\csname ttl@mkc@#1\endcsname{% + {\csname ttl@mks@#1\endcsname}% + {\csname ttl@premks@#1\endcsname}}% + \endgroup + \if@nobreak\ifvmode\nobreak\fi\fi} + +\newcommand\newshortmark[1]{% + \newmarkset{\string#1}% + \newextramark{\string#1}#1} + +\newcommand\shortmark[1]{\extramark{\string#1}} +\newcommand\preshortmark[1]{\preextramark{\string#1}} + +\newcommand\topshortmark[1]{{\topextramarks{\string#1}#1}} +\newcommand\firstshortmark[1]{{\firstextramarks{\string#1}#1}} +\newcommand\botshortmark[1]{{\botextramarks{\string#1}#1}} +\newcommand\nexttopshortmark[1]{{\nexttopextramarks{\string#1}#1}} + +\def\ttl@fetchmark#1#2#3{% + \expandafter#1#2\csname ttl@mkc@#3\endcsname{}{}{}} + +\newcommand\topextramarks[1]{\ttl@fetchmark\@secondoftwo\firstmarks{#1}} +\newcommand\firstextramarks[1]{% + \toks@\expandafter\expandafter\expandafter{% + \ttl@fetchmark\@secondoftwo\firstmarks{#1}}% + \@temptokena\expandafter\expandafter\expandafter{% + \ttl@fetchmark\@secondoftwo\botmarks{#1}}% + \edef\ttl@a{\the\toks@}% + \edef\ttl@b{\the\@temptokena}% + \ifx\ttl@a\ttl@b + \ttl@fetchmark\@secondoftwo\firstmarks{#1}% + \else + \ttl@fetchmark\@firstoftwo\firstmarks{#1}% + \fi} +\newcommand\botextramarks[1]{\ttl@fetchmark\@secondoftwo\botmarks{#1}} +\newcommand\nexttopextramarks[1]{\ttl@fetchmark\@firstoftwo\botmarks{#1}} + +\newcommand\outerextramarks[1]{% + \if@twoside + \ifodd\c@page\relax + \botextramarks{#1}% + \else + \topextramarks{#1}% + \fi + \else + \topextramarks{#1}% + \fi} +\newcommand\innerextramarks[1]{% + \if@twoside + \ifodd\c@page\relax + \firstextramarks{#1}% + \else + \botextramarks{#1}% + \fi + \else + \botextramarks{#1}% + \fi} + +\fi + +% ====== +% FLOATS +% ====== +% +% Pagestyles with floats. There macros are defined only with the +% psfloats package option. + +\ifx\ttl@replace\@undefined\else + +% User interface + + \newcommand\setfloatfoot{% + \let\ttl@c\@empty % <- current float, empty if general + \ttl@setany\ttl@setftfoot} + + \newcommand\setfloathead{% + \let\ttl@c\@empty % <- current float, empty if general + \ttl@setany\ttl@setfthead} + + \def\ttl@setftfoot[#1][#2][#3]#4#5#6#7{% + \@ifnextchar[{\ttl@setftfoot@i{#1}{#2}{#3}{#4}{#5}{#6}{#7}}% + {\ttl@setftfoot@i{#1}{#2}{#3}{#4}{#5}{#6}{#7}[bp]}} + + \def\ttl@setfthead[#1][#2][#3]#4#5#6#7{% + \@ifnextchar[{\ttl@setfthead@i{#1}{#2}{#3}{#4}{#5}{#6}{#7}}% + {\ttl@setfthead@i{#1}{#2}{#3}{#4}{#5}{#6}{#7}[tp]}} + + \def\ttl@setftfoot@i#1#2#3#4#5#6#7[#8]{% + \@tfor\ttl@b:=#8\do{% + \@namedef{ttlr@ef@\ttl@b\ttl@c}% + {#7\ttl@makefoot{#1}{#2}{#3}\@@\ttl@hiel\ttl@hier}% + \@namedef{ttlr@of@\ttl@b\ttl@c}% + {#7\ttl@makefoot{#4}{#5}{#6}\@@\ttl@hiol\ttl@hior}}} + + \def\ttl@setfthead@i#1#2#3#4#5#6#7[#8]{% + \@tfor\ttl@b:=#8\do{% + \@namedef{ttlr@eh@\ttl@b\ttl@c}% + {#7\ttl@makehead{#1}{#2}{#3}\@@\ttl@hiel\ttl@hier}% + \@namedef{ttlr@oh@\ttl@b\ttl@c}% + {#7\ttl@makehead{#4}{#5}{#6}\@@\ttl@hiol\ttl@hior}}} + + \newcommand\nextfloathead{% + \ttl@nextfree % returns ttl@c with the next float + \ttl@setany\ttl@setfthead} + + \newcommand\nextfloatfoot{% + \ttl@nextfree % returns ttl@c with the next float + \ttl@setany\ttl@setftfoot} + +% Compat mode with floatps + + \ifx\ttl@replace\space + + \let\ttl@setnewfoot\ttl@setftfoot + \let\ttl@setnewhead\ttl@setfthead + + \def\ttl@setftfoot[#1][#2][#3]#4#5#6{% + \ttl@setnewfoot[#1][#2][#3]{#4}{#5}{#6}{}} + \def\ttl@setfthead[#1][#2][#3]#4#5#6{% + \ttl@setnewhead[#1][#2][#3]{#4}{#5}{#6}{}} + + \fi + +% The simple default value of \ttl@userunning is +% replaced by one more elaborated + + \def\ttl@userunning#1#2{% + \if@fcolmade % From a post by D. Arseneau to comp.text.tex + \def\@elt##1{\edef\ttl@pageft{\string##1}}% + \@flsucceed + \let\@elt\relax + \if#2h% + \ttl@replace #1hp\ttl@pageft + \else + \ttl@replace #1fp\ttl@pageft + \ttl@killftps\ttl@pageft + \fi + \else\if#2h% + \ifx\ttl@topft\@empty\else + \ttl@replace #1ht\ttl@topft + \fi + \else + \ifx\ttl@botft\@empty\else + \ttl@replace #1fb\ttl@botft + \fi + \fi\fi + \csname ttlr@#1#2\endcsname} + +% [Don't move above as \ttl@replace is used as a flag.] + + \def\ttl@replace#1#2#3#4{% + \@ifundefined{ttlr@#1#2@#3#4}% + {\@ifundefined{ttlr@#1#2@#3}{}% + {\@namedef{ttlr@#1#2}{\@nameuse{ttlr@#1#2@#3}}}}% + {\csname ttlr@xx@x#4\endcsname\@gobble + {\expandafter\let\csname ttlr@#1#2\expandafter\endcsname + \csname ttlr@#1#2@#3#4\endcsname}}} + + \def\ttl@nextfree{% + \def\@elt##1{% + \edef\ttl@c{\string##1}% + \let\@elt\@gobble}% + \@freelist + \let\@elt\relax + \@ifundefined{ttlr@xx@x\ttl@c}% + {\expandafter\let\csname ttlr@xx@x\ttl@c\endcsname\@secondoftwo + \@tfor\ttl@a:={eh@t}{oh@t}{ef@b}{of@b}{eh@p}{oh@p}{ef@p}{of@p}\do{% + \expandafter\global\expandafter + \let\csname ttlr@\ttl@a\ttl@c\endcsname\relax}}{}} + + \def\ttl@killftps#1{% + \expandafter\global\expandafter + \let\csname ttlr@xx@x#1\endcsname\relax} + + \let\ttl@topft\@empty + \let\ttl@botft\@empty + \let\ttl@pageft\@empty + + \def\ttl@combinefloats{% + \ifx\@toplist\@empty\else + \def\@elt##1{% + \edef\ttl@topft{\string##1}% + \def\@elt####1{\ttl@killftps{\string####1}}}% + \@toplist + \fi + \ifx\@botlist\@empty\else + \def\@elt##1{% + \def\@elt####1{% + \def\@elt####1{\ttl@killftps\ttl@botft}% + \edef\ttl@botft{\string####1}}% + \edef\ttl@botft{\string##1}}% + \@botlist + \fi + \let\@elt\relax + \ttl@combinefloats@x} + + \AtBeginDocument{% + \let\ttl@combinefloats@x\@combinefloats + \let\@combinefloats\ttl@combinefloats} + +\fi + +% END core code + +\ifx\ttl@coreps\@empty\else % CONTINUE code for package + +% Raise error if the following are used without titlesec + +\DeclareRobustCommand\ttl@naerror[1]{% + \PackageError{titleps}% + {#1\space only available in titlesec.\MessageBreak + Consider using it instead of titleps}% + {titleps provides a subset of the macros\MessageBreak + for pagestyles defined in titlesec.}} + +\def\ttl@setifthe#1{% + \expandafter\protected@edef\csname ifthe#1\endcsname{% + \ttl@naerror{\string\ifthe#1}}} + +\ttl@setifthe{part} +\ttl@setifthe{chapter} +\ttl@setifthe{section} +\ttl@setifthe{subsection} +\ttl@setifthe{subsubsection} +\ttl@setifthe{paragraph} +\ttl@setifthe{subparagraph} + +\fi + +\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/macros/latex/contrib/titlesec/titleps.tex b/macros/latex/contrib/titlesec/titleps.tex new file mode 100644 index 0000000000..51149c9fa8 --- /dev/null +++ b/macros/latex/contrib/titlesec/titleps.tex @@ -0,0 +1,835 @@ +% +% 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 +% + +\def\fileversion{2.11} +\def\docdate{2019/07/16} + +\documentclass[a4paper]{ltxguide} +\usepackage[sf,bf,compact,topmarks,calcwidth,pagestyles]{titlesec} +\usepackage{titletoc} +\def\gobble#1{} +\DeclareRobustCommand\cs[1]{\expandafter\gobble\string\\#1} +\makeatletter +\newenvironment{desc} + {\if@nobreak + \vskip-\lastskip + \vspace*{-2.5ex}% + \fi + \decl} + {\enddecl} +\makeatother + +\usepackage{textcomp,pslatex} +\usepackage[linktocpage]{hyperref} + +\title{Headers and footers with \textsf{titleps}\footnote{The +\textsf{titleps} package is currently at version \fileversion. +\copyright{} 2016 Javier Bezos. All Rights Reserved.}} + +\author{Javier Bezos\footnote{For bug reports, comments and +suggestions go to \href{http://www.texnia.com/contact.html}% +{\texttt{http://www.texnia.com/contact.html}}. English +is not my strong point, so contact me when you find mistakes in the +manual. Other packages by the same author: \textsf{gloss} (with +Jos\'e Luis D\'{\i}az), \textsf{enumitem, accents, tensind, esindex, +dotlessi}.}} + +\date{\docdate} + +\widenhead{2.1pc}{0pc} +\titlelabel{\thetitle.\quad} + +\renewpagestyle{plain}[\small\sffamily\slshape]{ + \footrule + \setfoot{}{\thepage}{}} + +\newpagestyle{myps}[\small\sffamily\slshape]{ + \headrule + \sethead{titlesec -- titleps}{\sectiontitle}{\thepage}} + +\pagestyle{myps} + +\newcommand{\examplesep}{% + \begin{center}% + \rule{4pt}{4pt}% + \end{center}} + +\contentsmargin{0pt} + +\titlecontents*{section}[0pt]%[1.8pc] + {} + {\thecontentslabel. } + {} + {, \thecontentspage} + [. --- ][.] + +\addtolength{\topmargin}{-3pc} +\addtolength{\textwidth}{6pc} +\addtolength{\oddsidemargin}{-2pc} +\addtolength{\textheight}{7pc} + +\raggedright +\parindent1em +\parskip0pt + +\begin{document} + +\maketitle +\tableofcontents +\section{Introduction} + +The \textsf{titleps} package provides tools for one-stage setting of +page styles (headlines and footlines). A higher-level interface is +used, where the mark mechanism is hidden and there is no need to deal +with |\leftmark|s and |\rightmark|s -- just use a command or variable +registered as a ``mark'' as the expected value will be returned, i.e., +those when the mark was emitted, either by a sectioning command or +explicitly with |\chaptermark|, |\sectionmark|, etc. A simple +example, whose meaning should be obvious, is: +\begin{verbatim} +\newpagestyle{main}{ + \sethead[\thepage][\chaptertitle][(\thesection] % even + {\thesection)}{\sectiontitle}{\thepage}} % odd +\pagestyle{main} +\end{verbatim} + +Other features are: +\begin{itemize} +\item Working top marks, compatible with floats (unlike the standard +|\topmark|, which does not work correctly in \LaTeX{}). +\item Access to top, first and botttom marks in a single headline/footline +(e.g., the first and last section numbers). +\item Marks for more than 2 sectioning levels. +\item Auto-defining of suitable |\sectionmark| and the like. +\item Simple (and not so simple) headrules and footrules. +\item Headlines and footlines for pages with floats. +\item Headlines and footlines for specific floats (a sort of +|\thispagestyle| for floats). +\item Multiple sets of marks (named here \emph{markset}s and +\textit{extra marks}). +\end{itemize} + +It can be used without \textsf{titlesec}, but you will get most of +it when used together. To load it as a separate package, use the +customary \verb|\usepackage{titleps}|, but with \textsf{titlesec} you +have to load it with: +\begin{verbatim} +\usepackage[pagestyles]{titlesec} +\end{verbatim} + +Specific tools for sectioning command marks are provided, which are +considered the main \textit{markset} (unnamed) and carry out some +internal task. However, \textsf{titleps} can be used as well for +headers with the first an last entry of a page in a dictionary or index, +for example, thank to the \textit{extra marks} described below. + +It works with standard classes and many others; however, additional +\LaTeX{} layout adjustments could be necessary in some of them (for +instance the \textsc{AMS} classes) and several packages emitting marks +directly with \verb|\markboth| and \verb|\markleft|.\footnote{% +Two columns layout requires the \textsf{fix2col} package by David +Carlisle.} + +Once loaded the package, you can define your own page styles and then +activate them, but note page styles so defined cannot be used with +\verb|\thispagestyle| except if the surrounding page style has been +defined with \textsf{titleps}, too. + +%%%% empty ? plain ? + +\section{Defining Page Styles} + +\begin{desc} +|\newpagestyle{}[]{}|\\ +|\renewpagestyle{}[]{}| +\end{desc} + +Defines a new style or redefines an existing one, named ||. For +convenience, spaces and end of lines are ignored, and you need not +``hide'' them with |%|.\footnote{Even if marks should be reserved +to pass information +to headers, some classes, like the AMS ones, introduce additional +code. When redefining the |plain| style of AMS classes, you must add +the following line: |\cs{global}\cs{topskip}\cs{normaltopskip}|.} + +|| is any command to be applied to both footlines and +headlines. Fragile commands are allowed. + +In || you can use: + + +\begin{desc} +|\sethead[][][]|\\ +| {}{}{}|\\ +|\setfoot[][][]|\\ +| {}{}{}| +\end{desc} + +Set the corresponding part in headlines and footlines (note the +``visual'' layout of parameters). The optional arguments are the +three or none. If no optional arguments are given the odd-page +settings applies to both even and odd pages. A couple of starred +variant (|\setfoot*|, |\sethead*|) reverses the order of the settings +for even pages (obviously, with them the optional arguments are not +allowed). If |\sethead| is not given, then the headline it is left +empty, and same for |\setfoot| and the footline. + +In the arguments of |\sethead|/|\setfoot| and because of its one-stage +mechanism, we must distinguish between two groups of commands: +\begin{itemize} +\item The first one includes those saved when the marks are emitted, +with information related to sections, and includes: +\begin{itemize} +\item |\thechapter|, |\thesection|, |\thesubsection|\dots{} +\item |\chaptertitle|, |\sectiontitle|, |\subsectiontitle|\dots{} which print the +chapter, section\dots{} title. +\item (Only \textsf{titlesec}. Not in \textsf{titleps}.) +|\ifthechapter{}{}|, |\ifthesection{}{}|, +|\ifthesubsection{}{}|\dots{} which expands to || +except if the corresponding title lacks of label or there is no title +yet after the superior level (for example, between |\chapter| and a +subsequent |\section|). +\item Any other command or value ``registered'' as ``mark.'' (See below.) +\end{itemize} +They are ordinary commands, with no internal marks at all, and you can +test if, for example, they are empty. + +\item The second group are those expanded on every page, and includes: +\begin{itemize} +\item |\thepage|. +\item Any other command not included in the previous items. +\end{itemize} +\end{itemize} + +\begin{desc} +|\settitlemarks{,,...}|\\ +|\settitlemarks*{,,...}| +\end{desc} +Sets which |\...title| commands are to be defined, and when the marks +are emitted; any number of levels is allowed (1, 2, 3...). For example +|\settitlemarks{chapter,section}| +means that: +\begin{itemize} +\item |\chaptertitle| and |\sectiontitle| are the allowed titles in + headlines, +\item |\sectiontitle| is reset in |\chapter|, +\item (Only \textsf{titlesec}. Not in \textsf{titleps}.) +|\ifthechapter| and |\ifthesection| are valid tests. +\item Marks are updated in |\chapter| and |\section|. +\end{itemize} +Default is |\settitlemarks{chapter,section}|, but +|\settitlemarks{section,subsection}| in \textsf{article} class. +|\settitlemarks| may be used outside |\(re)newpagestyle| to set the +default to be used in newly defined and redefined page styles -- it is +used in |\pagestyle|.\footnote{The command \texttt{\string\setmarks} is +deprecated. Now +\texttt{\string\setmarks\string{\string}\string{\string}}is +\texttt{\string\settitlemarks\allowbreak\string{,\allowbreak\string}}.} + +The starred version |\settitlemarks*| creates parallel extra marks +as described below. + +\begin{desc} +|\headrule \footrule|\\ +|\setheadrule{} \setfootrule{}| +\end{desc} + +If you want a rule below the headline and above the footline. You may +also set their width directly with the commands |\setheadrule| and +|\setfootrule|. (For instance, |\setheadrule{.4pt}| which is, by the +way, the default value.) + +These commands are local to a page style, i.e., defining them directly +in the preamble will not work because the page style settings will +override them. + +\begin{desc} +|\makeheadrule \makefootrule| +\end{desc} + +These commands are used by \textsf{titleps} to typeset the rules. +If there is no rule, both commands are empty (this value is the +default). +|\setheadrule{|\emph{dim}|}| just stands for +\begin{verbatim} +\renewcommand{\makeheadrule}{\rule[-.3\baselineskip]{\linewidth}{}} +\end{verbatim} +unless if \emph{dim} is 0 pt, which empties +|\makeheadrule| (and similarly |\setfootrule|). + +You can access the total header/footer width with |\linewidth| +but the box enclosing the rule is in fact dimensionless. Hence, +you must be concerned with the rule placement only. Its +baseline is the same as that of the header/footer. That means the +material to be used as rule should be raised or lowered with +|\raisebox|, the lifting argument in |\rule| or by using sensible +coordinates in |picture|, for instance. That makes easy to +place material above \emph{and} below. For instance, +the following code creates a headline with a black bold line +above and a red rule below (the \textsf{color} package is required): +\begin{verbatim} +\renewcommand{\makeheadrule}{% + \makebox[0pt][l]{\rule[.7\baselineskip]{\linewidth}{0.8pt}}% + \color[named]{Red}% + \rule[-.3\baselineskip]{\linewidth}{0.4pt}} +\end{verbatim} + +Of course, the material to be used as rule is not restricted to actual +rules; pictures and leaders, for instance, are allowed, too. + +\section{On \texttt{\cs{markboth}} and \texttt{\cs{markleft}}} + +As \textit{The \LaTeX{} Companion explains} ``Leslie Lamport had a +specific marking scheme in mind when he designed those +commands''. They are clearly intended for the \verb|heading| and +\verb|myheading| pagestyles, with a \textit{main-mark} on the left +page and a \textit{sub-mark} on the right one. + +In order to provide the functionality offered by \textsf{titleps}, a +more general, less specific mechanism is devised, which means +|\markboth| here does not make sense, because it doesn't work like in +standard \LaTeX, and in fact, can lead to unpredictable results. + +Therefore, using directly the marking commands is discouraged (see +|titlesec.pdf|), but if you need them, you may write: +\begin{verbatim} +\chapter*{My Chapter} +\chaptermark{My Chapter} +\end{verbatim} + +But some issues remain, because there are a number of packages +assuming the pagestyle is \verb|heading| or \verb|myheading|. This is, +of course, a reasonable guess, but not always correct (even if +\textsf{titleps} is not used at all). Most of them do the right thing +-- \verb|\markboth| is encapsulated into a macro easily redefinable so +that the user can modify it if necessary. This is true, for example, +for \textsf{biblatex}, but unfortunately not for \textsf{endnotes}. +When this happens, you can resort to the following macro. + +\begin{desc} +|\setmarkboth{}| +\end{desc} + +From this point on, \verb|\markboth| behaves as defined. It doesn't +redefine directly the command, but rather provides a replacement code +(you can use |#1| and |#2| for the two arguments). With +|\resetmarkboth| (which can be used inside |\setmarkboth|) the +original definition will be again in force. For example, to cancel the +next |\markboth|: +\begin{verbatim} +\setmarkboth{\resetmarkboth\markboth{}{}} +\end{verbatim} + +\section{Headline/footline width} + +\begin{desc} +|\widenhead[][]{}{}|\\ +|\widenhead*{}{}| +\end{desc} + +Makes the headlines/footlines lines wider. The extra width is +asymmetrically added and hence the two [four] arguments. Like +|\sethead|, the starred version reverses the setting for even +pages---for example, |\widenhead*{0pt}{6pc}| is the same as +|\widenhead[6pc][0pt]{0pt}{6pc}|. + +To be used outside |\(re)newpagestyle|. + +\begin{desc} +|nopatches| \qquad (package option) +\end{desc} + +By default, sectioning commands are patched slightly for top marks +and |\@mkboth| to work, so that page styles behave like standard +|headings|. However, if you want to be explicit, like with standard +|myheadings|, and emit premarks and, if necessary, marks by yourself, +set this package option. Remenber you have to use |\sectionmark| and +the like, and not |\markboth| or |\markright|. + +You might also prefer to patch the sectioning commands by yourself, +either with low-level definitions or with the provided +|\TitlepsPatchSection| (with a starred version which adds no premark +and intended mainly for chapters). For example: +\begin{verbatim} +\TitlepsPatchSection*{chapter} % patches \chapter +\TitlepsPatchSection{section} % patches \section +\end{verbatim} +(In standard classes |\part| emits no mark, and therefore it is not +patched by default.) + +\section{Marks} + +Marks can be retrieved in 4 ways: +\begin{description} +\item[top marks] If a page begins with text, they are the marks +belonging to the sectioning unit of that text. If a page begin with a +sectioning title, they are the marks of that title. In other words, +top marks refer to the section immediately adjacent to the +headline. +\item[first marks] The marks of the very first sectioning title. +\item[botttom marks] The marks of the very last (bottom) sectioning +title (also known as \textit{bot marks}). +\item[next top marks] A botttom mark with the values of the top mark of +the next page (only |straight| class or equivalent); by picking some +value from it and comparing it with the corresponding value from the +botttom marks you may know if a section continues in the next page. +Of course, it will not be used very often. +\end{description} +Standard \LaTeX{} provides only first and bottom marks. As you see, with +\textsf{titleps} you have two additional marks, namely, top and next +top marks. + +It should be stressed top marks are not the same as the primitive +\verb|\topmark| (which, in fact, is not used internally at all). They +are true top marks, returning the expected result when the title is at +the top of the page. Further, they are compatible with floats, which +is not true with \verb|\topmark|s. However, they fail with explicit +page breaks, but you can use \verb|\pretitlemark| as described +below. + +\begin{desc} +|outermarks innermarks topmarks botmarks| \qquad (package options) +\end{desc} + +|innermarks| is the default in \LaTeX, with bottom marks in even pages +and first marks in odd pages. More convenient is |outermarks|, with +top marks in even pages and bottom marks in odd pages; it is the more +usual system in classic scientific literature and it is described in +\textit{The \TeX{}book}, p.~259.\footnote{|outermarks| may not work +well in conjunction with explicit |\string\
mark| commands} Both of them are intended for two side printing; +|topmarks|/|botmarks| are intended for one side printing with top/bot +marks in every page (they can be used in two side printing as well). + +\begin{desc} +|\bottitlemarks \toptitlemarks \firsttitlemarks \nexttoptitlemarks|\\ +|\outertitlemarks \innertitlemarks| +\end{desc} + +These commands set which mark the values of the subsequent +|\thesection|, |\sectiontitle|, etc., will be taken from. +These macros are switches, and therefore subsequent commands and +variables are taken from the selected mark. The following is valid: +\begin{verbatim} +\toptitlemarks\textbf{\thesection.} \sectiontitle -- +\bottitlemarks\textbf{\thesection.} \sectiontitle +\end{verbatim} + +You can use them freely in your headers;\,% +\footnote{Not exactly: top marks must not be used in the page where a +chapter begins, except by overriding the default definition and making +it of |top| class.} just for fun, the following header shows the +section label from three of these marks: +\begin{verbatim} +\newpagestyle{funny}{ + \sethead{\toptitlemarks Top is \thesection} + {\firsttitlemarks First is \thesection} + {\bottitlemarks Bot is \thesection}} +\end{verbatim} + +In multilingual documents, the language in force is that corresponding +to the package options -- command versions does not switch the +language, but you can do it easily with the help a new title mark and +then switching the language, as explained below. + +\begin{desc} +|\newtitlemark{}|\\ +|\newtitlemark*{}| +\end{desc} + +Add a command or a variable to the list of ``marks'' to be emitted at +a sectioning command. The macro must be parameterless, and the +variable is either a length, if it has the form \verb|\|, or a +counter, if it has the form \verb|| (i. e., a string). +For example, if you write (with \textsf{babel}): +\begin{verbatim} +\newtitlemark{\languagename} +\end{verbatim} +then a |\languagename| in the head/foot will contain the language when +the corresponding mark was emitted; unfortunately, \textsf{babel} +does not allow |\languagename| as the first argument of +|\foreignlanguage| (it enters in a infinite loop), but there is a +simple trick -- just use an intermediate command: +\begin{verbatim} +\newcommand\titlelanguage{\languagename} +\newtitlemark{\titlelanguage} +\end{verbatim} +(What is saved is the expansion of |\titlelanguage|, which is turn is +the expansion of |\languagename|. Alternatively, you can create the +intermediate command with |\let| in the header itself.) + +Marks to be emitted at other places (not sectioning commands) are +handled with extra marks and \textit{marksets} (see below). + +Commands must be robust, but not protected, or the value returned will +not be the right one. Remember there are two kinds of robust commands +-- those containing in turn robust commands and those protected with, +say, |\DeclareRobustCommand|.\footnote{Unfortunately, +\texttt{\string\DeclareRobustCommand} has a misleading name, because a +command created with \texttt{\string\newcommand} can be robust, too. +A better name would have been +\texttt{\string\DeclareProtectedCommand}.} An example of how to use +protected commands is a layout used sometimes if sections are long as +well as their titles, where the title is splitted across the left and +the right pages. Here is how this can be carried out: +\begin{verbatim} +\DeclareRobustCommand\splitheader[2]{#1 #2} +\def\contsplitheader{} + +\def\dosplitheader{% + \gdef\contsplitheader{}% + \DeclareRobustCommand\splitheader[2]{##1\gdef\contsplitheader{##2}}} + +\renewpagestyle{headings}{ + \sethead[\thepage] + [] + [\dosplitheader\sectiontitle] + {\contsplitheader} + {} + {\thepage} +} + +\pagestyle{headings} +\end{verbatim} +(Note the header also uses |\DeclareRobustCommand|.) + +\begin{desc} +|\pretitlemark{
}{}|\\ +|\pretitlemark*{
}{}| +\end{desc} + +Top marks require in fact two marks, one before the page break and +other after it. This is done by \textsf{titlesec}, while +\textsf{titleps} patches the sectioning commands as described above. + +However, if you need an explicit page break you can emit the mark +with |\pretitlemark|. For example: +\begin{verbatim} +\pretitlemark{section}{Performing Brahms} +\newpage +\section{Performing Brahms} +\end{verbatim} +Note the text in the premark is the title of the next section. The +counter is advanced temporarily, so that it has the right value, but +if for some reason you do not want that, just use +\verb|\pretitlemark*|. + +\begin{desc} +|\ifsamemark{}{}{}{}| +\end{desc} + +One of the disavantaged of the switching mechanism is that comparing +a command from, say, the top marks and the botttom marks is not +trivial. +This macro just makes it simpler. If you want to compare the +currect \verb|\thesection| with that in the top mark, write: +\begin{verbatim} +\ifsamemark\toptitlemarks\thesection{}{} +\end{verbatim} + +\section{Running heads with floats} + +\begin{desc} +|psfloats| \qquad (package option) +\end{desc} + +This package option activates the commands described in this section.% +\footnote{It redefines some internal \LaTeX{} commands and there could be +incompatibilities with other packages modifying the same commands. That's +the very reason these commands are loaded only optionally. As of +version 2.6 the syntax was extended with a new argument to allow +extra stuff in running heads/foots. This change is backward +compatible---just preserve the old name \verb|floatps|, which +is deprecated, if you want the pre-2.6 behaviour.} + +\begin{desc} +|\setfloathead*{.}{.}{.}{}[]|\\ +|\setfloathead[.][.][.]{.}{.}{.}{}[]|\\ +(Similarly |\setfloatfoot|.) +\end{desc} + +The arguments with a dot are similar to those of |\sethead|. The final +argument says the head is used when there is a float of +the specified types (default is |tp| in headers, and |bp| in footers). +For example: +\begin{verbatim} +\newpagestyle{main}{% + \sethead ... your definition + \setfoot ... your definition + \headrule + \footrule + \setfloathead{}{}{}{\setheadrule{0pt}}[p] + \setfloatfoot{}{}{}{\setfootrule{0pt}}[p]} +\end{verbatim} +removes the header/footer on float pages, including the rules. + +\begin{desc} +|\nextfloathead*{.}{.}{.}{}[]|\\ +|\nextfloathead[.][.][.]{.}{.}{.}{}[]|\\ +(Similarly |\nextfloatfoot|.) +\end{desc} + +You may force a header (respectively footer) when a certain float is +the first top one (respectively last bottom) with those commands just +before the corresponding float, where the arguments with a dot are +similar to those of |\sethead|. Those commands are used by +themselves, without putting them inside |\(re)newpagestyle|. So, to +empty the headline when a certain figure is placed at the top (because +it is a bleed, for example): +\begin{verbatim} +\nextfloathead{}{}{}{}[t] +\begin{figure} +... +\end{figure} +\end{verbatim} + +\section{Extra marks} + +Both \textsf{titlesec} and \textsf{titleps} provide tools for handling +extra marks, if you are using an $\epsilon$-\TeX{} based engine +(currently most of them) and load the \textsf{etex} package or +equivalent. The way they work are conceptually similar to the title +marks described above -- you set which commands or variables are to +get synchronized in heads and foots. To use extra marks, you have to +load them with the following package option: + +\begin{desc} +|extramarks| \qquad (package option) +\end{desc} + +Extra marks are subsidiary. If page styles are modified internally by +another package and the document does not make use of sectioning +commands, you might still need an empty title mark (like +\verb|\sectionmark{}|), as well as to synchronize the language by +hand. + +In many cases, the following ``short'' marks mechanism will be enough. +With it, you simply say with \verb|\newshormark| the name of a command +to be used in heads or foots, and then emit the mark at appropiated +places (short marks for variables are not available). An example +illustrates how this is carried out: +\begin{verbatim} +\newcommand\lemmatitle{} + +\newshortmark\lemmatitle + +\newcommand\lemma[1]{% + \renewcommand\lemmatitle{#1}% + \preshortmark\lemmatitle % if you want top marks + \pagebreak[2]% + \vspace{1em}% + \textbf{#1}\enspace + \shortmark\lemmatitle} + +\newpagestyle{main}{ + \sethead{}{\topshortmark\lemmatitle + --\firstshortmark\lemmatitle + --\botshortmark\lemmatitle + --\nexttopshortmark\lemmatitle}{}} + +\pagestyle{main} +\end{verbatim} + +Top marks require emitting the marks before the page break -- just use +the command \verb|\preshortmark| as shown above. Otherwise, you may +omit it. Unlike title marks and extra marks, the selector of short +marks (\verb|\topshortmark|, \verb|\firstshortmark|, +\verb|\botshortmark|, \verb|\nexttopshortmark|), is \textit{not} a +switch and must be always immediately followed by the command to be +retrieved. + +For a more general approach use the following tools. + +\begin{desc} +|\newmarkset{}| +\end{desc} + +A \textit{markset} contains a set of related commands and variables +intended to be emitted simultaneously as marks, so that their values +can be retrieved in heads/foots. A typical \textit{markset} could be +a title and its counter (and perhaps, in a multilingual document, the +active language, i.e., \verb|\languagename| in \textsf{babel}, or an +intermediate command). There is always a special unnamed +\textit{markset} for sectioning marks, which is the main one and +handled with the tools described above (with |title| in their names). + +\begin{desc} +|\newextramark{}{}|\\ +|\newextramark*{}{}| +\end{desc} + +Add to a \textit{markset} a command or a variable to be synchronized . +They are identical to \verb|\newtitlemark| and \verb|\newtitlemark*|, +except for the additional parameter with the \textit{markset} name. + +\begin{desc} +|\botextramarks{} \topextramarks{}|\\ +|\firstextramarks{} \nexttopextramarks{}|\\ +|\outerextramarks{} \innerextramarks{}| +\end{desc} + +The \verb|extra| counterparts of the \verb|title| commands described +above, with the same behaviour. For example: +\begin{verbatim} +\newcommand{\lemmatitle}{} +\newcounter{lemma} + +\newmarkset{lemma} +\newextramark{lemma}{\lemmatitle} +\newextramark*{lemma}{lemma} % ie, the counter `lemma' + +\newcommand{\lemma}[1]{% + \renewcommand{\lemmatitle}{#1}% + \stepcounter{lemma}% + \preextramark{lemma}% + \pagebreak[2]% + \vspace{1em}% + \textbf{(\arabic{lemma}) #1}\enspace + \extramark{lemma}} + +\newpagestyle{main}{ + \sethead{} + {\topextramarks{lemma}(\arabic{lemma}) \textbf{\lemmatitle}} + {}} + +\pagestyle{main} +\end{verbatim} + +\begin{desc} +|\settitlemarks*{,,...}| +\end{desc} + +By default, \LaTeX{} and \textsf{titleps} use a single \textit{markset} for +all sectioning levels. This is problematic, for example, in the +\textsf{article} class, because sections does not start a new page. +Consider the following piece of code: +\begin{verbatim} +\section{A section} +\subsection{A subsection} +\end{verbatim} +On odd pages with first marks and subsection titles, the head has +no title, because \verb|\subsection| is the second mark, not the +first one. + +To overcome this limitation, you can use the starred version of +\verb|\settitlemarks|, which creates parallel \textit{marksets} (one per +level) synchonized with the main \textit{markset}. They are retrieved like +other extra marks, but they are special in that you cannot emit them +by yourself -- they are always emitted by the corresponding +sectioning mark. So, with +\begin{verbatim} +\settitlemarks*{section,subsection} +\end{verbatim} +and a page style containing +\begin{verbatim} +\firstextramarks{subsection}\subsectiontitle +\end{verbatim} +you retrieve the mark emitted by the first \verb|\subsection|, even +if preceded by a \verb|\section|. (Top marks are best retrieved from +the main \textit{markset}.) + +They are extra marks, and therefore language synchronization has to be +done by hand -- add \verb|\languagename| or an intermediate command to +the main \textit{markset} with \verb|\newtitlemark| and, if you want, +define a command. For example: +\begin{verbatim} +% use an intermediate command because we'll need \foreignlanguage +\newcommand\titlelanguage{\languagename} +\newtitlemark{\titlelanguage} + +% define a command to ease defining page styles +\newcommand{\toplang}[1]{% + {\topextramarks{section}% + \foreignlanguage{\titlelanguage}{#1}}} +\end{verbatim} + +\section{A couple of examples} + +Because of the way marks are handled, special constructs like this are +allowed: +\begin{verbatim} +\newpagestyle{main}[\small\sffamily]{ + \sethead[\textbf{\thepage}] + [\textsl{\chaptertitle}] + [[\toptitlemarks\thesection--\bottitlemarks\thesection] + {\toptitlemarks\thesection--\bottitlemarks\thesection]} + {\textsl{\sectiontitle}} + {\textbf{\thepage}}} +\end{verbatim} +As you can see, the range of sections in a page with |\thesection| is +printed in both left and right heads. Of course, this example should +be fine tuned to collapse the ranges if there is a single section in a +page (with |\ifsamemark|), but it gives a hint of how to get stunning +headers. + +In this document, the following styles are used: +\begin{verbatim} +\widenhead{2.1pc}{0pc} +\renewpagestyle{plain}[\small\sffamily\slshape]{ + \footrule + \setfoot{}{\thepage}{}} +\newpagestyle{myps}[\small\sffamily\slshape]{ + \headrule + \sethead{titlesec -- titleps}{\sectiontitle}{\thepage}} +\end{verbatim} + +The following definitions provide page styles similar to those in +Lamport's \textit{The \LaTeX\ book} (with the \textsf{calc} package): +\begin{verbatim} +\widenhead*{0pt}{\marginparsep + \marginparwidth} % symmetrically +\renewpagestyle{plain}{} +\newpagestyle{latex}[\bfseries]{ + \headrule + \sethead[\thepage][][\chaptertitle] + {\thesection\ \sectiontitle}{}{\thepage}} +\pagestyle{latex} +\end{verbatim} + +% \section{Remarks} +% +% Page styles in standard \LaTeX{} are somewhat rudimentary. For +% example |\thispagestyle| is not always correctly synchronized with +% sectioning marks, and if you set |\pagestyle{plain}| and then +% |\thispagestyle{headings}|, its behaviour is not the expected one. +% The same happens if a page style defined in \textsf{titleps} is used +% in a |\thispagestyle| in the context of a standard page style -- you +% have to define the main one as well. + +% \section{Some tips and tricks} +% +% star |\*| +% +% split heads +% +% bible + +\end{document} + +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/macros/latex/contrib/titlesec/titlesec.pdf b/macros/latex/contrib/titlesec/titlesec.pdf new file mode 100644 index 0000000000..bf4525f3e9 Binary files /dev/null and b/macros/latex/contrib/titlesec/titlesec.pdf differ diff --git a/macros/latex/contrib/titlesec/titlesec.sty b/macros/latex/contrib/titlesec/titlesec.sty new file mode 100644 index 0000000000..f1f943fd21 --- /dev/null +++ b/macros/latex/contrib/titlesec/titlesec.sty @@ -0,0 +1,1708 @@ +% +% 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/07/16 v2.11 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 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. + +\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}% + \def\markboth##1##2{\protect\ttl@gmk{\protect\markboth{##1}{##2}}}% + \def\markright##1{\protect\ttl@gmk{\protect\markright{##1}}}% + \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@
whose content is +% {left}{right}{before}{after}{afterindent}. +% But if there is the page key, the name is +% \ttls@
/ + +\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@
, +% or \ttlf@
/ if there is the page spec, +% or \ttlf@.../* if numberless is true +% whose content is +% \ttl@{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@ and \ttlh@ 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{% + \expandafter\in@\expandafter\@startsection\expandafter{#1}% + \ifin@ + \expandafter\ttl@@extract#1#1% + \else + \PackageWarningNoLine{titlesec}% + {Non standard sectioning command detected\MessageBreak + 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. + diff --git a/macros/latex/contrib/titlesec/titlesec.tex b/macros/latex/contrib/titlesec/titlesec.tex new file mode 100644 index 0000000000..d10da1e040 --- /dev/null +++ b/macros/latex/contrib/titlesec/titlesec.tex @@ -0,0 +1,2106 @@ +% +% 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 +% + +\def\fileversion{2.11} +\def\docdate{2019/07/16} + +\documentclass[a4paper]{ltxguide} +\usepackage[sf,bf,compact,topmarks,calcwidth,pagestyles]{titlesec} +\usepackage{titletoc} +\def\gobble#1{} +\def\cs#1{\expandafter\gobble\string\\#1} +\makeatletter +\newenvironment{desc} + {\if@nobreak + \vskip-\lastskip + \vspace*{-2.5ex}% + \fi + \decl} + {\enddecl} +\makeatother + +\usepackage{textcomp,pslatex} +\usepackage[linktocpage]{hyperref} + +\title{The \textsf{titlesec}, \textsf{titleps} and \textsf{titletoc} +Packages\footnote{The \textsf{titlesec} package is currently at +version 2.10.2. \copyright{} 1998--2016 Javier Bezos. +The \textsf{titletoc} package is currently at +version 1.6. The \textsf{titleps} package is currently at version +1.1.1 \copyright{} 1999--2016 Javier Bezos. All Rights +Reserved.}} + +\author{Javier Bezos\footnote{For bug reports, comments and +suggestions go to \href{http://www.tex-tipografia.com/contact.html}% +{\texttt{http://www.tex-tipografia.com/contact.html}}. English +is not my strong point, so contact me when you find mistakes in the +manual. Other packages by the same author: \textsf{gloss} (with +Jos\'e Luis D\'{\i}az), \textsf{enumitem, accents, tensind, esindex, +dotlessi, babeltools}.}} + +\date{\docdate} + +\widenhead{2.1pc}{0pc} +\titlelabel{\thetitle.\quad} + +\renewpagestyle{plain}[\small\sffamily\slshape]{ + \footrule + \setfoot{}{\usepage}{}} + +\newpagestyle{myps}[\small\sffamily\slshape]{ + \headrule + \sethead{Titlesec}{\sectiontitle}{\usepage}} + +\pagestyle{myps} + +\newcommand{\examplesep}{% + \begin{center}% + \rule{4pt}{4pt}% + \end{center}} + +\contentsmargin{0pt} +\titlecontents{section}[1.8pc] + {\addvspace{3pt}\bfseries} + {\contentslabel[\thecontentslabel.]{1.8pc}} + {} + {\quad\thecontentspage} + +\titlecontents*{subsection}[1.8pc] + {\small} + {\thecontentslabel. } + {} + {, \thecontentspage} + [.---][.] + +\addtolength{\topmargin}{-3pc} +\addtolength{\textwidth}{6pc} +\addtolength{\oddsidemargin}{-2pc} +\addtolength{\textheight}{7pc} + +\raggedright +\parindent1em +\parskip0pt + +\begin{document} + +\maketitle +\tableofcontents +\section{Introduction} + +This package is essentially a replacement---partial or total---for the +\LaTeX{} macros related with sections---namely titles, headers and +contents. The goal is to provide new features unavailable in current +\LaTeX{}; if you just want a more friendly interface than that of +standard \LaTeX{} but without changing the way \LaTeX{} works you may +consider using \textsf{fancyhdr}, by Piet van Oostrum, \textsf{sectsty}, +by Rowland McDonnell, and \textsf{tocloft}, by Peter Wilson, which you +can make pretty things with.\footnote{Since the sectioning commands +are rewritten, their behaviour could be somewhat different +in some cases.} + +Some of the new features provided are: +\begin{itemize} +\item Different classes and ``shapes'' of titles, with tools for very +fancy formats. You can define different formats for left and right +pages, or numbered and unnumbered titles, measure the width of the +title, add a new section level, use graphics, and many more. The +Appendix shows a good deal of examples, so jump forward right now! + +\item Headers and footers defined with no |\...mark| intermediates, +and perhaps containing top, first \emph{and} bot marks at the same time. +Top marks correctly synchronized with titles, without +incompatibilities with the float mechanism. Decorative elements easily +added, including picture environments. + +\item Pretty free form contents, with the possibility of grouping +entries of different levels in a paragraph or changing the format +of entries in the middle of a document. +\end{itemize} +\textsf{Titlesec} works with the standard classes and with many +others, including the AMS ones, and it runs smoothly with +\textsf{hyperref}.\footnote{However, be aware the AMS classes +reimplement the original internal commands. These changes will be +lost here. The compatibility with \textsf{hyperref} has been tested +with \textsf{dvips}, \textsf{dvipdfm} and \textsf{pdftex} but it is an +unsupported feature. Please, check your version of +\textsf{hyperref} is compatible with \textsf{titlesec}.} +Unfortunately, it is not compatible with \textsf{memoir}, which +provides its own tools with a limited subset of the features available +in \textsf{titlesec}. + +As usual, load the package in the standard way with +|\usepackage|. Then, redefine the sectioning commands with the +simple, predefined settings (see section ``Quick Reference'') or with +the provided commands if you want more elaborate formats (see section +``Advanced Interface.'') In the latter case, you only need to +redefine the commands you'll use. Both methods are available at the +same time, but because |\part| is usually implemented in a +non-standard way, it remains untouched by the simple settings and +should be changed with the help of the ``Advanced Interface.'' + +\section{Quick Reference} +%~~~~~~~~~~~~~~~~~~~~~~ + +The easiest way to change the format is by means of a set of package +options and a couple of commands. If you feel happy with the +functionality provided by this set of tools, you need not go +further in this manual. Just read this section and ignore the +subsequent ones. + +\subsection{Format} + +There are three option groups controlling font, size and align. You +need not set all of these groups, since a default is provided for each +one; however, you must use at least an option from them if you want +this ``easy setup.'' +\begin{desc} +|rm sf tt md bf up it sl sc| +\end{desc} +Select the corresponding family/series/shape. Default is |bf|. + +\begin{desc} +|big medium small tiny| +\end{desc} +Set the size of titles. +Default is |big|, which gives the size of standard classes. +With |tiny|, sections (except chapters) are typed in the text +size. |medium| and |small| are intermediate layouts. + +\begin{desc} +|raggedleft center raggedright| +\end{desc} + +Control the alignment. + +\subsection{Spacing} + +\begin{desc} +|compact| +\end{desc} +This option is independent from those above and reduces the spacing +above and below the titles. + +\subsection{Uppercase} + +\begin{desc} +|uppercase| +\end{desc} + +\fbox{2.9} Uppercases titles. Depending on the class, it might not work in +\verb|\chapter| and \verb|\part|. + +\subsection{Tools} + +\begin{desc} +|\titlelabel{}| +\end{desc} +Changes the label format in sections, subsections, etc. A +|\thetitle| command is provided which is respectively |\thesection|, +|\thesubsection|, etc. The default value in standard classes is +\begin{verbatim} +\titlelabel{\thetitle\quad} +\end{verbatim} +and you may add a dot after the counter simply with +\begin{verbatim} +\titlelabel{\thetitle.\quad} +\end{verbatim} +That was done in this document. + +\begin{desc} +|\titleformat*{}{}| +\end{desc} + +This command allows to change the || of a sectioning +command, as for example: +\begin{verbatim} +\titleformat*{\section}{\itshape} +\end{verbatim} + +\section{Advanced Interface} +%~~~~~~~~~~~~~~~~~~~~~~~~ + +Two commands are provided to change the title format. The first one +is used for the ``internal'' format, i.~e., shape, font, label\dots, +the second one defines the ``external'' format, i.~e., spacing before +and after, indentation, etc. This scheme is intended to easy +definitions, since in most of cases you will want to modify either +spacing or format.\footnote{Information is ``extracted'' from the +class sectioning commands, except for chapter and part. Standard +definitions with |\cs{@startsection}| are presumed---if sections have +been defined without that macro, arbitrary values for the format an +the spacing are provided, which you may change later. (Sadly, there +is no way to catch the chapter or part formats, and one similar to +that of standard classes will be used.)} That redefines existing +sectioning commands, but does not create \emph{new} ones. New +sectioning levels can be added with |\titleclass|, as described below, +and then their format can be set with the commands described here. + +\subsection{Format} + +A set of shapes is provided, which controls the basic distribution of +elements in a title. The available shapes are: +\begin{description} +\item[hang] is the default value, with a hanging label. (Like the +standard |\section|.) + +\item[block] typesets the whole title in a block (a paragraph) without +additional formatting. Useful in centered titles\,\footnote{The label +will be slightly displaced to the left if the title is two or more +lines long and the \texttt{hang} shape is used, except with explicit +|\string\\|.} and special formatting (including graphic tools such as +|picture|, |pspicture|, etc.) + +\item[display] puts the label in a separate paragraph. (Like the +standard |\chapter|.) + +\item[runin] A run-in title, like the standard + |\paragraph|.\footnote{Well, not quite. The title is first boxed to + avoid some unexpected results if, for example, there is a + \texttt{\string\color} between the title and the + text. Unfortunately, due to an optimization done by \TeX{} + discretionaries may be lost. I have found no solution, except using + \textsf{luatex}, which works as one could expect. Anyway, if the + title doesn't contain hyphen or dashes, this is not usually a real + problem.} + +\item[leftmargin] puts the title at the left margin. Titles at the +very end of a page will be moved to the next one and will not stick +out in the bottom margin, which means large titles can lead to +underfull pages.\footnote{However, floats following the title a couple +of lines after will interfere with the page breaking used here and +sometimes the title may stick out.} In this case you may increase the +stretchability of the page elements, use |\raggedbottom| or use the +package option |nobottomtitles| described below. Since the mechanism +used is independent from that of the margin pars, they can overlap. +A deprecated synonymous is |margin|. + +\item[rightmargin] is like |leftmargin| but at the right margin. + +\item[drop] wraps the text around the title, provided the +first paragraph is longer than the title (if not, they overlap). +The comments in |leftmargin| also apply here. + +\item[wrap] is quite similar to drop. The only difference is +while the space reserved in drop for the title is fixed, in wrap is +automatically readjusted to the longest line. The limitations +explained below related to |calcwidth| also apply here. + +\item[frame] Similar to display, but the title will be framed. +\end{description} + +Note, however, some shapes do not make sense in chapters and +parts. + +\begin{desc} +|\titleformat{}[]{}{