### \titleclass - Change Section Behavior Source: https://context7.com/jbezos/titlesec/llms.txt The \titleclass command allows modification of sectioning command behavior, such as starting new pages or appearing inline. It supports classes like 'straight', 'top', 'page', and 'part'. ```APIDOC ## \titleclass - Change Section Behavior ### Description The `\titleclass` command changes the class of a sectioning command, controlling whether it starts a new page, appears at the top of a page, or runs inline with text. Available classes are: straight (default), top (like chapter), page (like part), and part. ### Method LaTeX Command ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```latex \documentclass{book} \usepackage{titlesec} % Make section behave like chapter (start new page, top of page) \titleclass{\section}{top} % Make chapter behave like section (no page break) \titleclass{\chapter}{straight} % Create a new sectioning level \titleclass{\subchapter}{straight}[\chapter] \newcounter{subchapter}[chapter] \renewcommand{\thesubchapter}{\thechapter.\arabic{subchapter}} \titleformat{\subchapter} {\normalfont\large\bfseries} {\thesubchapter} {1em} {} \titlespacing*{\subchapter}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex} % Page class - like \part, starts on new page \titleclass{\section}{page} \begin{document} \chapter{First Chapter} \subchapter{First Subchapter} Content here. \end{document} ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Creating Partial TOCs with \startcontents and \printcontents (LaTeX) Source: https://context7.com/jbezos/titlesec/llms.txt Demonstrates the creation of partial Tables of Contents using \startcontents and \printcontents. This is useful for generating mini-TOCs within specific sections or chapters, allowing customization of entry appearance and scope. ```latex \documentclass{book} \usepackage{titletoc} % Define a format for partial TOC entries \titlecontents{psection} % 'p' prefix for partial [0em] {\small} {\contentslabel{1.5em}} {} {\titlerule*[.5pc]{.}\contentspage} \titlecontents{psubsection} [1.5em] {\footnotesize} {\contentslabel{2em}} {} {\titlerule*[.5pc]{.}\contentspage} \begin{document} \tableofcontents \chapter{First Chapter} \startcontents[chapters] % Start tracking (named 'chapters') \printcontents[chapters] % Print partial TOC {p} % Prefix for entry names {1} % Start from level 1 (section) {} \section{First Section} \subsection{Subsection A} \subsection{Subsection B} \section{Second Section} \stopcontents[chapters] % Stop tracking \chapter{Second Chapter} \startcontents[chapters] \printcontents[chapters]{p}{1}{\setcounter{tocdepth}{2}} \section{Another Section} \subsection{Details} \stopcontents[chapters] \end{document} ``` -------------------------------- ### Configuring Headers and Footers with sethead and setfoot Source: https://context7.com/jbezos/titlesec/llms.txt Explains the usage of \sethead and \setfoot to define the content of headers and footers. It covers left, center, and right positions, and how to specify different content for even and odd pages, including the starred version for reversed behavior. ```latex \documentclass{book} \usepackage{titleps} \newpagestyle{myheadings}{ % \sethead[even-left][even-center][even-right]{odd-left}{odd-center}{odd-right} \sethead[\thepage][\textit{\chaptertitle}][] {}{\textit{\sectiontitle}}{\thepage} % \setfoot follows same pattern \setfoot[][\textit{Draft}][] {\textit{Draft}}{}{} } % Starred version reverses even/odd \newpagestyle{reversed}{ \sethead*{}{\sectiontitle}{\thepage} % Same on both sides but reversed } % Simple one-sided style \newpagestyle{simple}{ \sethead{}{\sectiontitle}{} \setfoot{}{\thepage}{} } \pagestyle{myheadings} \begin{document} \chapter{Introduction} \section{Background} Document content. \end{document} ``` -------------------------------- ### Apply Formatting Presets via Package Options Source: https://context7.com/jbezos/titlesec/llms.txt Demonstrates how to use titlesec package options to quickly apply common formatting styles like font changes, alignment, and spacing without custom commands. ```latex % Size options: big, medium, small, tiny \usepackage[medium]{titlesec} % Medium-sized titles % Font options: rm, sf, tt, md, bf, up, it, sl, sc \usepackage[sf,bf]{titlesec} % Sans-serif bold titles % Alignment: raggedleft, center, raggedright \usepackage[center]{titlesec} % Centered titles % Case transformation \usepackage[uppercase]{titlesec} % Uppercase titles % Chapter options \usepackage[rigidchapters]{titlesec} % Fixed height chapter titles \usepackage[rubberchapters]{titlesec} % Flexible chapter spacing % Bottom title protection \usepackage[nobottomtitles]{titlesec} % Prevent orphan titles \usepackage[nobottomtitles*]{titlesec} % Stricter orphan prevention % Indentation control \usepackage[indentafter]{titlesec} % Indent after all titles \usepackage[noindentafter]{titlesec} % No indent after titles % Title width calculation \usepackage[calcwidth]{titlesec} % Enable \titlewidth % Combined options \usepackage[medium,center,bf,compact]{titlesec} ``` -------------------------------- ### Custom Page Styles with titleps Package Source: https://context7.com/jbezos/titlesec/llms.txt Illustrates creating custom page styles using \newpagestyle, \sethead, and \setfoot. It shows how to include page numbers, chapter titles, and section titles in headers and footers, and how to use \settitlemarks. ```latex \documentclass{book} \usepackage{titleps} % Basic page style with section titles in header \newpagestyle{main}{ \sethead[\thepage][\chaptertitle][] % Even pages: page | chapter {}{\sectiontitle}{\thepage} % Odd pages: section | page } % Page style with rules \newpagestyle{ruled}[\small\sffamily]{ \headrule \sethead[\thepage][\chaptertitle][] {}{\sectiontitle}{\thepage} \setfoot[][\thepage][] {}{\thepage}{} \footrule } % Using settitlemarks to control which sections appear \newpagestyle{custom}{ \settitlemarks{chapter,section,subsection} \sethead{\thechapter}{\chaptertitle}{\thepage} } \pagestyle{main} \begin{document} \chapter{First Chapter} \section{First Section} Content here. \end{document} ``` -------------------------------- ### Registering Custom Lists with \contentsuse (LaTeX) Source: https://context7.com/jbezos/titlesec/llms.txt Shows how to register custom list files, such as a 'List of Algorithms', using the \contentsuse command. This allows titletoc to format entries for these custom lists, similar to the standard TOC. ```latex \documentclass{article} \usepackage{titletoc} % Register a custom list file \contentsuse{algorithm}{loa} % {entry-name}{file-extension} % Define the TOC entry format \titlecontents{algorithm} [0em] {} {Algorithm~\thecontentslabel:\quad} {} {\titlerule*[.5pc]{.}\contentspage} % Command to add algorithm entries \newcommand{\listofalgorithms}{\section*{List of Algorithms} \@starttoc{loa}} \newcounter{algorithm} \newcommand{\algorithm}[1]{\refstepcounter{algorithm} \addcontentsline{loa}{algorithm}{\protect\numberline{\thealgorithm}#1} \textbf{Algorithm \thealgorithm:} #1} \begin{document} \tableofcontents \listofalgorithms \section{Methods} \algorithm{Quicksort} \algorithm{Binary Search} \end{document} ``` -------------------------------- ### Assign Page Styles to Sections with \assignpagestyle Source: https://context7.com/jbezos/titlesec/llms.txt Explains how to associate specific page styles (e.g., empty, plain, or custom) with sectioning commands using \assignpagestyle. ```latex \documentclass{book} \usepackage{titlesec} % Assign 'empty' page style to chapter pages \assignpagestyle{\chapter}{empty} % Assign 'plain' page style to part pages \assignpagestyle{\part}{plain} % Custom page style for sections (requires titleps) \usepackage[pagestyles]{titlesec} \newpagestyle{sectionstyle}{ \sethead{\thesection}{}{\sectiontitle} } \assignpagestyle{\section}{sectionstyle} \begin{document} \chapter{Introduction} This page will have empty headers/footers. \end{document} ``` -------------------------------- ### Adding Rules to Headers and Footers with headrule and footrule Source: https://context7.com/jbezos/titlesec/llms.txt Demonstrates how to add horizontal rules to page styles using \headrule and \footrule. It shows how to apply default rules, customize their thickness with \setheadrule and \setfootrule, and remove them by setting the thickness to 0pt. ```latex \documentclass{article} \usepackage{titleps} \newpagestyle{withrules}{ \headrule % Default 0.4pt rule under header \footrule % Default 0.4pt rule above footer \sethead{}{\sectiontitle}{\thepage} \setfoot{}{\today}{} } % Custom rule thickness \newpagestyle{thickrules}{ \setheadrule{2pt} % 2pt rule under header \setfootrule{1pt} % 1pt rule above footer \sethead{}{\sectiontitle}{\thepage} \setfoot{}{\today}{} } % Remove rules (set to 0pt) \newpagestyle{norules}{ \setheadrule{0pt} \setfootrule{0pt} \sethead{}{\sectiontitle}{\thepage} } \pagestyle{withrules} \begin{document} \section{Test} Content with ruled headers and footers. \end{document} ``` -------------------------------- ### Create Dotted TOC Entries with titletoc Source: https://context7.com/jbezos/titlesec/llms.txt Shows how to use the \dottedcontents command as a shorthand for creating standard dotted table of contents entries. It allows for quick configuration of margins, above-code, label width, and dot spacing for various levels and lists. ```latex \documentclass{article} \usepackage{titletoc} % \dottedcontents{section}[left]{above-code}{label-width}{leader-width} \dottedcontents{section} [1.5em] % left margin {} {1.5em} % space for section number {.5pc} % dot spacing \dottedcontents{subsection} [3.8em] {\small} {2.3em} {.5pc} \dottedcontents{subsubsection} [6.1em] {\footnotesize} {3.2em} {.5pc} % For list of figures \dottedcontents{figure} [1.5em] {} {2.3em} {.5pc} \begin{document} \tableofcontents \section{Introduction} \subsection{Overview} \subsubsection{Details} \end{document} ``` -------------------------------- ### Extending Headers with widenhead Source: https://context7.com/jbezos/titlesec/llms.txt Explains the \widenhead command for extending headers into the margins. It covers setting uniform widening for both margins, asymmetric widening for even/odd pages, and using the starred version to swap even/odd page behavior. ```latex \documentclass{article} \usepackage{titleps} \newpagestyle{wide}{ % \widenhead[even-left][even-right]{odd-left}{odd-right} \widenhead{2cm}{2cm} % Extend 2cm into each margin \headrule \sethead{}{\sectiontitle}{\thepage} } % Different widening for even/odd pages \newpagestyle{asymmetric}{ \widenhead[1cm][2cm]{2cm}{1cm} \headrule \sethead[\thepage][\chaptertitle][] {}{\sectiontitle}{\thepage} } % Starred version: swap even/odd \newpagestyle{swapped}{ \widenhead*{1cm}{2cm} \sethead{}{\sectiontitle}{\thepage} } \pagestyle{wide} \begin{document} \section{Wide Header Section} The header extends beyond the text margins. \end{document} ``` -------------------------------- ### Titlesec Package Usage Source: https://context7.com/jbezos/titlesec/llms.txt Demonstrates the basic integration and usage of the Titlesec package for customizing sectioning commands and page styles. ```APIDOC ## Titlesec Package Integration ### Description This section outlines the typical steps for integrating and using the Titlesec package, along with related packages like titleps and titletoc, to customize document appearance. ### Method LaTeX Package Loading and Configuration ### Endpoint N/A (LaTeX Package) ### Parameters N/A ### Request Example ```latex \usepackage{titlesec} \usepackage{titleps} % Optional, often included with titlesec[pagestyles] \usepackage{titletoc} % For Table of Contents customization % Define custom format for chapter titles \titleformat{\chapter}[display] {\normalfont\huge\bfseries}{}{0pt}{\filcenter\MakeUppercase{#1}} % Define custom spacing for chapter titles \titlespacing*{\chapter} {0pt}{50pt}{40pt} % Define a custom page style that includes section information \newpagestyle{myheadings}{[ \fancyhf{} \fancyhead[L]{\nouppercase{\leftmark}} \fancyhead[R]{\thepage} ]} % Apply the custom page style \pagestyle{myheadings} % Customize Table of Contents appearance (optional) \titlecontents{chapter}[1em] {\bfseries} {\contentslabel{1.5em}\chaptername\thecontentslabel\quad} {\hspace*{-1.5em}} [\addvspace{10pt}] ``` -------------------------------- ### Package Options - Quick Formatting Presets Source: https://context7.com/jbezos/titlesec/llms.txt Titlesec offers various package options for rapid formatting, providing presets for size, font, alignment, case transformation, chapter behavior, and more. ```APIDOC ## Package Options - Quick Formatting Presets ### Description Titlesec provides numerous package options for quick setup of common formatting styles without writing custom `\titleformat` commands. ### Method LaTeX Package Options ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```latex % Size options: big, medium, small, tiny \usepackage[medium]{titlesec} % Medium-sized titles % Font options: rm, sf, tt, md, bf, up, it, sl, sc \usepackage[sf,bf]{titlesec} % Sans-serif bold titles % Alignment: raggedleft, center, raggedright \usepackage[center]{titlesec} % Centered titles % Case transformation \usepackage[uppercase]{titlesec} % Uppercase titles % Chapter options \usepackage[rigidchapters]{titlesec} % Fixed height chapter titles \usepackage[rubberchapters]{titlesec} % Flexible chapter spacing % Bottom title protection \usepackage[nobottomtitles]{titlesec} % Prevent orphan titles \usepackage[nobottomtitles*]{titlesec} % Stricter orphan prevention % Indentation control \usepackage[indentafter]{titlesec} % Indent after all titles \usepackage[noindentafter]{titlesec} % No indent after titles % Title width calculation \usepackage[calcwidth]{titlesec} % Enable \titlewidth % Combined options \usepackage[medium,center,bf,compact]{titlesec} ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Access Section Information with titlesec Source: https://context7.com/jbezos/titlesec/llms.txt Demonstrates using the titlesec package to set page styles that access section titles and numbering for headers and footers. It shows how to use \settitlemarks, \chaptertitle, \sectiontitle, and conditional display based on numbering. ```latex \documentclass{book} \usepackage{titleps} \newpagestyle{detailed}{ \settitlemarks{chapter,section,subsection} \sethead{ \toptitlemarks % Top mark on page \chaptertitle }{ \firsttitlemarks % First mark on page \sectiontitle }{ \bottitlemarks % Bottom mark on page \thepage } } % Conditional display based on numbering \newpagestyle{conditional}{ \sethead{ \ifthechapter{\thechapter.~}{}% Only show if numbered \chaptertitle }{}{\thepage} } % Using outertitlemarks for facing pages \newpagestyle{outer}{ \settitlemarks{chapter,section} \sethead[\outertitlemarks\chaptertitle][][\thepage] {\thepage}{}{\outertitlemarks\sectiontitle} } % innertitlemarks for inner margins \newpagestyle{inner}{ \sethead{\innertitlemarks\thesection}{\sectiontitle}{\thepage} } \pagestyle{detailed} \begin{document} \chapter{Test Chapter} \section{First Section} Content. \section{Second Section} More content. \end{document} ``` -------------------------------- ### Configure Section Behavior with \titleclass Source: https://context7.com/jbezos/titlesec/llms.txt Demonstrates how to change the behavior of sectioning commands (e.g., page breaks, alignment) and define new sectioning levels using the \titleclass command. ```latex \documentclass{book} \usepackage{titlesec} % Make section behave like chapter (start new page, top of page) \titleclass{\section}{top} % Make chapter behave like section (no page break) \titleclass{\chapter}{straight} % Create a new sectioning level \titleclass{\subchapter}{straight}[\chapter] \newcounter{subchapter}[chapter] \renewcommand{\thesubchapter}{\thechapter.\arabic{subchapter}} \titleformat{\subchapter} {\normalfont\large\bfseries} {\thesubchapter} {1em} {} \titlespacing*{\subchapter}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex} % Page class - like \part, starts on new page \titleclass{\section}{page} \begin{document} \chapter{First Chapter} \subchapter{First Subchapter} Content here. \end{document} ``` -------------------------------- ### titleformat Command Source: https://context7.com/jbezos/titlesec/llms.txt Explains the usage of the \titleformat command for defining the appearance of section titles. ```APIDOC ## \titleformat Command ### Description The `\titleformat` command is the core of Titlesec for customizing the look of sectioning commands (like \chapter, \section, \subsection, etc.). It allows you to specify the font, size, color, and layout of the title and its number. ### Method `\titleformat[shape][within][prepend-format][number-format][title-format][postpend-format]` ### Endpoint N/A (LaTeX Command) ### Parameters #### Command - **sectioning_command** (e.g., `chapter`, `section`, `subsection`) - Required - The sectioning command to format. #### Shape - **shape** (e.g., `display`, `block`, `drop`, `wrap`, `runin`, `hang`) - Optional - The overall layout shape for the title. #### Within - **within** (e.g., `part`, `chapter`) - Optional - Specifies that this format applies only when within a certain higher-level sectioning command. #### Prepend Format - **prepend-format** - Optional - LaTeX code to be placed before the title number and text. #### Number Format - **number-format** (e.g., `\thesection`, `\arabic`, `\Alph`) - Optional - How the section number should be displayed. #### Title Format - **title-format** - Optional - LaTeX code to format the title text itself (e.g., font changes, color). #### Postpend Format - **postpend-format** - Optional - LaTeX code to be placed after the title text. ### Request Example ```latex % Example: Display style for chapters with uppercase title and a rule below \titleformat{\chapter}[display] {\normalfont\huge\bfseries\filcenter} % Format for number and title {\chaptername\ \thechapter} % Number format {1em} % Space between number and title {\MakeUppercase{#1}\titlerule[0.8pt]} ``` ### Response N/A (Modifies document appearance) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Create Custom Marks with titlesec Source: https://context7.com/jbezos/titlesec/llms.txt Illustrates creating custom marks using \newtitlemark to track counters or macro values across page breaks. It also shows how to use extra mark sets for complex tracking and conditional content in headers/footers. ```latex \documentclass{article} \usepackage[extramarks]{titleps} % Track a counter \newcounter{example} \newtitlemark{\theexample} % Track a macro (starred version) \newtitlemark*{\currentauthor} \newcommand{\currentauthor}{} \newpagestyle{custom}{ \sethead{\theexample}{\currentauthor}{\thepage} } % Using extra mark sets for complex tracking \newmarkset{notes} \newextramark{notes}\notecontent \newcommand{\notecontent}{} \newcommand{\setnote}[1]{ \renewcommand{\notecontent}{#1}% \extramark{notes}% } \newpagestyle{withnotes}{ \sethead{}{\sectiontitle}{\thepage} \setfoot{}{\botextramarks{notes}\notecontent}{} } \pagestyle{custom} \begin{document} \stepcounter{example} \renewcommand{\currentauthor}{John Doe} \section{Test} Content with custom marks. \end{document} ``` -------------------------------- ### Customize Section Labels with \titlelabel Source: https://context7.com/jbezos/titlesec/llms.txt Shows how to globally modify the appearance of section labels, such as adding punctuation or parentheses, using the \titlelabel command. ```latex \documentclass{article} \usepackage{titlesec} % Add period after all section numbers \titlelabel{\thetitle.\quad} % Use parentheses around section numbers \titlelabel{(\thetitle)\quad} % Custom format with different separators \titlelabel{\thetitle~---~} \begin{document} \section{Introduction} \subsection{Background} Content follows. \end{document} ``` -------------------------------- ### Define TOC Entry Format with titletoc Source: https://context7.com/jbezos/titlesec/llms.txt Explains how to use the \titlecontents command from the titletoc package to completely control the appearance of table of contents entries. This includes indentation, formatting, filler, and page number placement for different levels. ```latex \documentclass{book} \usepackage{titletoc} % \titlecontents{section}[left]{above}{before with label}{before without label}{filler and page}[after] \titlecontents{chapter} [0pt] % left margin {\addvspace{1em}\bfseries} % above-code {\contentslabel{2em}} % before-code with number {\hspace*{-2em}} % before-code without number {\hfill\contentspage} % filler and page \titlecontents{section} [2em] % left margin (indentation) {} {\contentslabel{2em}} % numbered entry format {} {\titlerule*[.5pc]{.}\contentspage} \titlecontents{subsection} [4em] {\small} {\contentslabel{2.5em}} {} {\titlerule*[.5pc]{.}\contentspage} % Starred version for inline/block entries \titlecontents*{section} [0pt] {} {} {} {, \thecontentspage} [.~---~] % separator between entries [.] % final punctuation \begin{document} \tableofcontents \chapter{Introduction} \section{Background} \subsection{History} \end{document} ``` -------------------------------- ### Add Decorative Elements with \titleline and \titlerule Source: https://context7.com/jbezos/titlesec/llms.txt Illustrates how to enhance section titles with horizontal rules, custom thickness lines, and dotted patterns using \titleline and \titlerule. ```latex \documentclass{article} \usepackage[calcwidth]{titlesec} % Basic rule \titleformat{\section} {\normalfont\Large\bfseries} {\thesection} {1em} {} [\titlerule] % Rule after title % Rule with custom thickness \titleformat{\section} {\normalfont\Large\bfseries} {\thesection} {1em} {\titlerule[2pt]\vspace{4pt}} % Rule before title [\titlerule[0.4pt]] % Rule after title % Dotted rule with titlerule* \titleformat{\section} {\normalfont\Large\bfseries} {\thesection} {1em} {} [\titlerule*[.5pc]{.}] % Dotted line after title % Full-width line with titleline \titleformat{\section}[display] {\normalfont\Large\bfseries} {} {0pt} {\titleline*[c]{\titlerule[1pt]}\vspace{4pt}} % Using titlewidth (requires calcwidth option) \titleformat{\section}[block] {\filcenter\normalfont\Large\bfseries} {\thesection} {1em} {} [\titleline{\titlerule[0.4pt]}] \begin{document} \section{Decorated Section} Content here. \end{document} ``` -------------------------------- ### Formatting TOC Entries with \contentslabel and \contentspage (LaTeX) Source: https://context7.com/jbezos/titlesec/llms.txt Demonstrates how to precisely control the formatting and positioning of section labels (numbers) and page numbers within Table of Contents entries using \contentslabel and \contentspage commands. It shows custom label formats, alignment adjustments, and rule styles. ```latex \documentclass{article} \usepackage{titletoc} \titlecontents{section} [3em] {\addvspace{0.5em}} {\contentslabel[\thecontentslabel.]{2em}}% Custom label format {\hspace*{-2em}}% No label: pull left {\titlerule*[.5pc]{.}\contentspage[\thecontentspage]}% Default page format % Right-aligned labels \titlecontents{section} [3em] {} {\hspace*{-3em}\makebox[3em][r]{\thecontentslabel\hspace{1em}}} {} {\titlerule*{.}\contentspage} % contentspush - push subsequent lines \titlecontents{chapter} [0em] {\addvspace{1em}} {\contentspush{\thecontentslabel\quad}\bfseries} {\bfseries} {\hfill\contentspage} \begin{document} \tableofcontents \section{First Section} \section{Second Section} \end{document} ``` -------------------------------- ### Title Alignment Commands in Titlesec Source: https://context7.com/jbezos/titlesec/llms.txt Demonstrates how to use filright, filleft, filcenter, fillast, and filinner commands to control the alignment of section titles within their boxes. These commands are applied within the \titleformat macro. ```latex \documentclass{article} \usepackage{titlesec} % Right-aligned title (flush right) \titleformat{\section} {\filright\normalfont\Large\bfseries} {\thesection} {1em} {} % Left-aligned with right fill \titleformat{\section} {\filleft\normalfont\Large\bfseries} {\thesection} {1em} {} % Centered title \titleformat{\section} {\filcenter\normalfont\Large\bfseries} {\thesection} {1em} {} % Last line justified differently (fillast) \titleformat{\section} {\fillast\normalfont\Large\bfseries} {\thesection} {1em} {} % Two-sided alignment (inner/outer margins) \titleformat{\section} {\filinner\normalfont\Large\bfseries} {\thesection} {1em} {} \begin{document} \section{Aligned Section Title} Content follows. \end{document} ``` -------------------------------- ### LaTeX: Define Section Title Appearance with \titleformat Source: https://context7.com/jbezos/titlesec/llms.txt Demonstrates the use of the \titleformat command to customize the appearance of section headings in LaTeX. It showcases various shapes like display, runin, frame, block, hang, and leftmargin, along with formatting, labeling, and spacing options. ```latex \documentclass{article} \usepackage{titlesec} % Basic title format: shape, format, label, sep, before-code, after-code \titleformat{\section} {\normalfont\Large\bfseries} % format {\thesection} % label {1em} % separation between label and title {} % Display shape - label on separate line above title \titleformat{\chapter}[display] {\normalfont\huge\bfseries} {\chaptertitlename\ \thechapter} {20pt} {\Huge} % Runin shape - title runs into paragraph \titleformat{\paragraph}[runin] {\normalfont\normalsize\bfseries} {\theparagraph} {1em} {} % Frame shape - title in a box with rules \titleformat{\section}[frame] {\normalfont} {\filright\footnotesize\enspace SECTION \thesection\enspace} {8pt} {\Large\bfseries\filcenter} % Block shape - label and title on same baseline \titleformat{\section}[block] {\normalfont\Large\bfseries} {\thesection.} {1em} {} % Hang shape (default) - title hangs from label \titleformat{\subsection}[hang] {\normalfont\large\bfseries} {\thesubsection} {1em} {} % Margin shape - title in left margin \titleformat{\section}[leftmargin] {\normalfont\normalsize\bfseries\filleft} {\thesection} {.5em} {} \begin{document} \section{Introduction} Content following the section heading. \end{document} ``` -------------------------------- ### titlespacing Command Source: https://context7.com/jbezos/titlesec/llms.txt Details the \titlespacing command for controlling vertical spacing around section titles. ```APIDOC ## \titlespacing Command ### Description The `\titlespacing` command controls the vertical spacing before and after section titles, allowing fine-tuning of the document's layout. ### Method `\titlespacing*[counter]{command}{left}{before}{after}[rules]` ### Endpoint N/A (LaTeX Command) ### Parameters #### Command - **command** (e.g., `chapter`, `section`) - Required - The sectioning command whose spacing is being defined. #### Left - **left** - Optional - Horizontal indentation from the left margin. #### Before - **before** - Required - Vertical space before the title. #### After - **after** - Required - Vertical space after the title. #### Rules - **rules** - Optional - Specifies rules (like horizontal lines) to be placed above or below the title. ### Request Example ```latex % Example: Set specific spacing for sections \titlespacing{\section} {0pt} % Left indentation {3.5ex plus 1ex minus .2ex} % Space before {2.3ex plus .2ex} % Space after ``` ### Response N/A (Modifies document appearance) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### \titlelabel - Customize Section Label Format Source: https://context7.com/jbezos/titlesec/llms.txt The \titlelabel command allows for customization of the format of all section labels simultaneously, using #1 as a placeholder for the section number. ```APIDOC ## \titlelabel - Customize Section Label Format ### Description The `\titlelabel` command provides a simple way to change the format of all section labels at once, using `#1` as a placeholder for the section number. ### Method LaTeX Command ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```latex \documentclass{article} \usepackage{titlesec} % Add period after all section numbers \titlelabel{\thetitle.\quad} % Use parentheses around section numbers \titlelabel{(\thetitle)\quad} % Custom format with different separators \titlelabel{\thetitle~---~} \begin{document} \section{Introduction} \subsection{Background} Content follows. \end{document} ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Titletoc Package Options for Label Positioning and Formatting (LaTeX) Source: https://context7.com/jbezos/titlesec/llms.txt Illustrates various package options for the titletoc LaTeX package that control the appearance of labels within TOC entries. Options include label alignment (left/right), adding/removing periods after numbers, and controlling vertical spacing. ```latex % leftlabels (default) - labels flush left \usepackage[leftlabels]{titletoc} % Results in: "1. Title" with number left-aligned % rightlabels - labels flush right within their box \usepackage[rightlabels]{titletoc} % Results in: " 1. Title" with number right-aligned % dotinlabels - add period after section numbers \usepackage[dotinlabels]{titletoc} % Results in: "1. Title" % nodotinlabels (default) - no period after numbers \usepackage[nodotinlabels]{titletoc} % Results in: "1 Title" % Spacing options \usepackage[rigidseps]{titletoc} % Fixed vertical spacing \usepackage[rubberseps]{titletoc} % Flexible spacing (default) % Combined options \usepackage[rightlabels,dotinlabels,rigidseps]{titletoc} ``` -------------------------------- ### Define Custom Page Styles with Titleps Source: https://context7.com/jbezos/titlesec/llms.txt This snippet shows how to create a new page style using the titleps functionality included with titlesec. It enables the definition of headers and footers that can dynamically display section information. ```latex \usepackage[pagestyles]{titlesec} \newpagestyle{mystyle}{ \sethead{Header Left}{}{Header Right} \setfoot{Page \thepage}{}{} } \pagestyle{mystyle} ``` -------------------------------- ### \titleline and \titlerule - Decorative Elements Source: https://context7.com/jbezos/titlesec/llms.txt The \titleline and \titlerule commands are used to add horizontal rules and decorative lines to section titles, with options for thickness, style, and placement. ```APIDOC ## \titleline and \titlerule - Decorative Elements ### Description The `\titleline` and `\titlerule` commands add horizontal rules and decorative lines to section titles. ### Method LaTeX Command ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```latex \documentclass{article} \usepackage[calcwidth]{titlesec} % Basic rule \titleformat{\section} {\normalfont\Large\bfseries} {\thesection} {1em} {} [\titlerule] % Rule after title % Rule with custom thickness \titleformat{\section} {\normalfont\Large\bfseries} {\thesection} {1em} {\titlerule[2pt]\vspace{4pt}} % Rule before title [\titlerule[0.4pt]] % Rule after title % Dotted rule with titlerule* \titleformat{\section} {\normalfont\Large\bfseries} {\thesection} {1em} {} [\titlerule*[.5pc]{.}] % Dotted line after title % Full-width line with titleline \titleformat{\section}[display] {\filcenter\normalfont\Large\bfseries} {} {0pt} {\titleline*[c]{\titlerule[1pt]}\vspace{4pt}} % Using titlewidth (requires calcwidth option) \titleformat{\section}[block] {\filcenter\normalfont\Large\bfseries} {\thesection} {1em} {} [\titleline{\titlerule[0.4pt]}] \begin{document} \section{Decorated Section} Content here. \end{document} ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Customize Section Formatting with Titlesec Source: https://context7.com/jbezos/titlesec/llms.txt This snippet demonstrates how to define custom formatting for section headings using the \titleformat command. It allows for control over font styles, label formatting, and spacing before or after the title. ```latex \usepackage{titlesec} \titleformat{\section} {\normalfont\Large\bfseries} {\thesection}{1em}{} \titlespacing*{\section} {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex} ``` -------------------------------- ### LaTeX: Control Section Spacing with \titlespacing Source: https://context7.com/jbezos/titlesec/llms.txt Illustrates the usage of the \titlespacing command to manage the horizontal and vertical spacing around section titles in LaTeX documents. It covers parameters for left indent, space before, space after, and optional right margin, including the starred version to suppress paragraph indentation. ```latex \documentclass{article} \usepackage{titlesec} % \titlespacing{command}{left}{before-sep}{after-sep}[right-sep] \titlespacing{\section} {0pt} % left margin {3.5ex plus 1ex minus .2ex} % vertical space before {2.3ex plus .2ex} % vertical space after % Starred version: no indent for first paragraph after title \titlespacing*{\subsection} {0pt} {3.25ex plus 1ex minus .2ex} {1.5ex plus .2ex} % With right margin specification \titlespacing{\chapter} {0pt} % left {50pt} % before {40pt} % after [0pt] % right margin (optional) % Negative 'before' space for runin titles (space becomes after-sep) \titleformat{\paragraph}[runin]{\normalfont\bfseries}{\theparagraph}{1em}{} \titlespacing{\paragraph} {\parindent} {3.25ex plus 1ex minus .2ex} {1em} % horizontal space after runin title \begin{document} \section{Test Section} First paragraph content. Second paragraph content. \end{document} ``` -------------------------------- ### \assignpagestyle - Set Page Style for Sections Source: https://context7.com/jbezos/titlesec/llms.txt The \assignpagestyle command assigns a specific page style to pages containing certain sectioning commands, commonly used for chapters and parts. ```APIDOC ## \assignpagestyle - Set Page Style for Sections ### Description The `\assignpagestyle` command assigns a specific page style to pages containing certain sectioning commands, particularly useful for chapters and parts. ### Method LaTeX Command ### Endpoint N/A ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example ```latex \documentclass{book} \usepackage{titlesec} % Assign 'empty' page style to chapter pages \assignpagestyle{\chapter}{empty} % Assign 'plain' page style to part pages \assignpagestyle{\part}{plain} % Custom page style for sections (requires titleps) \usepackage[pagestyles]{titlesec} \newpagestyle{sectionstyle}{ \sethead{\thesection}{}{\sectiontitle} } \assignpagestyle{\section}{sectionstyle} \begin{document} \chapter{Introduction} This page will have empty headers/footers. \end{document} ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Controlling TOC Right Margin with \contentsmargin (LaTeX) Source: https://context7.com/jbezos/titlesec/llms.txt Explains how to use the \contentsmargin command to adjust the right margin for Table of Contents entries, affecting the position of page numbers. It illustrates setting a global margin and different margins for various section levels, including corrections for ragged right alignment. ```latex \documentclass{article} \usepackage{titletoc} % Set right margin for page numbers \contentsmargin{2.5em} % Different margins for different levels \titlecontents{chapter} [0pt] {\contentsmargin{3em}\bfseries} % Wider margin for chapters {\contentslabel{2em}} {} {\hfill\contentspage} \titlecontents{section} [2em] {\contentsmargin{2em}} % Narrower margin for sections {\contentslabel{2em}} {} {\titlerule*{.}\contentspage} % With correction for ragged right % \contentsmargin[correction]{margin} \titlecontents{section} [2em] {\contentsmargin[0.5em]{2.5em}} {\contentslabel{2em}} {} {\titlerule*{.}\contentspage} \begin{document} \tableofcontents \chapter{Long Chapter Title That Might Wrap} \section{Section Title} \end{document} ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.