## Section38.5Titles of Divisions

The titlesec package cooperates with “traditional” divisions, such as \chapter and \section, to style the start of each division, containing its PreTeXt <title> and in most instances, its number. If a division is credited to (multiple) <author>, then that information can be styled, and there are plans (2018-09-30) for epigraphs.

PreTeXt manages numbered versus unnumbered divisions, the correct level for one-off divisions like a <preface> or <appendix>, and the specialized divisions such as <exercises> and <references>. A style writer creates two styles at each level of the hierarchy, for a numbered variant, and an unnumbered variant. titlesec uses a numberless key to indicate the latter. A named template, such as

<xsl:template name="titlesec-section-style">


would produce text containing complete titlesec commands \titleformat and \titlespacing in both numbered and unnumbered variants.

There are five macros created by PreTeXt at the start of each division. For example, \authorsptx is a comma-separated list of the content of all the <author> elements for the division, in the order given. Look in the output to find the others nearby. A robust style will include this information, even if the first use of the style may not have any divisions credited to others.

The table of contents and the index are created by a single macro. This creates a small technical challenge, since PreTeXt never has a chance to write the contents of the heading and must take what it is given. The upshot is that the \titleptx macro will be wrong or empty. So instead, use the titlesec device of using the macro parameter #1 for the title in the correct argument of \titleformat. We have enabled this possibility through the package's explicit option. We believe the numberless variant of a <chapter> of a <book>, and the numberless variant of a <section> of an <article>, are the only places this is necessary. 2019-09-30: we will contemplate if this should be the rule and the \titleptx macro will go away. Advise if you see a good answer, either way.

2019-09-30: these templates are highly likely to break into two modes (format and spacing), with a @match that can react to <chapter>, <section>, etc., perhaps differently for books versus articles. The change will only imply some minor editing to achieve the same end result, so don't hold back waiting.