% % 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.13} \def\docdate{2019/10/16} \documentclass[a4paper]{ltxguide} \usepackage[sf,bf,compact,topmarks,calcwidth,pagestyles]{titlesec} \usepackage{titletoc,color} \def\gobble#1{} \def\cs#1{\expandafter\gobble\string\\#1} \definecolor{notes}{rgb}{.75, .3, .3}% \makeatletter \newenvironment{desc} {\if@nobreak \vskip-\lastskip \vspace*{-2.5ex}% \fi \decl} {\enddecl} \def\@begintheorem#1#2{% \list{}{}% \global\advance\@listdepth\m@ne \item[{\sffamily\bfseries\color{notes}\MakeUppercase{#1}}]}% \newtheorem{warning}{Warning} \newtheorem{note}{Note} \newtheorem{example}{Example} \makeatother \usepackage{textcomp} \usepackage[linktocpage]{hyperref} \title{The \textsf{titlesec}, \textsf{titleps} and \textsf{titletoc} Packages\footnote{The \textsf{titlesec} package is currently at version 2.13. \copyright{} 1998--2019 Javier Bezos.}} \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 \begin{note} Please, report any issues you find on \texttt{https://github.com/jbezos/titlesec/issues}, which is better than just complaining on an e-mail list or a web forum. Forking and pull requests are welcome. \end{note} \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{}[]{}{