;;; titlesec.el --- AUCTeX style for `titlesec.sty' (v2.11) -*- lexical-binding: t; -*- ;; Copyright (C) 2016--2022 Free Software Foundation, Inc. ;; Author: Arash Esbati ;; Maintainer: auctex-devel@gnu.org ;; Created: 2015-09-19 ;; Keywords: tex ;; This file is part of AUCTeX. ;; AUCTeX is free software; you can redistribute it and/or modify it ;; under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. ;; AUCTeX is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with AUCTeX; see the file COPYING. If not, write to the Free ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ;; 02110-1301, USA. ;;; Commentary: ;; This file adds support for `titlesec.sty' (v2.11) from ;; 2019/07/16. `titlesec.sty' is part of TeXLive. ;;; Code: (require 'tex) (require 'latex) ;; Silence the compiler: (declare-function font-latex-add-keywords "font-latex" (keywords class)) (defvar LaTeX-titlesec-key-val-options '(("page" ("even" "odd")) ("numberless")) "Key=value options for \"\\titleformat\" and \"\\titlespacing\" macros provided by \"titlesec.sty\".") (defvar LaTeX-titlesec-section-command-list '("part" "chapter" "section" "subsection" "subsubsection" "paragraph" "subparagraph") "List of sectioning commands available in \"titlesec.sty\".") (defvar LaTeX-titlesec-section-shape-list '("hang" "block" "display" "runin" "leftmargin" "rightmargin" "drop" "wrap" "frame") "List of sectioning shapes available for \"\\titleformat\" command.") (defun LaTeX-titlesec-section-command-list () "Remove \"chapter\" from variable `LaTeX-titlesec-section-command-list' and return the remainder. Removal is based on the return value of function `LaTeX-largest-level'. Items returned are prefixed with `TeX-esc'." (mapcar (lambda (elt) (concat TeX-esc elt)) (if (< (LaTeX-largest-level) 2) LaTeX-titlesec-section-command-list (remove "chapter" LaTeX-titlesec-section-command-list)))) (defun LaTeX-titlesec-titlespec-key-val-options () "Return key=val's for the 1st arg of \"\\titleformat\" and \"\\titlespacing\". Depending on the returned value of the function `LaTeX-largest-level', append a \"name\" key with corresponding values to `LaTeX-titlesec-key-val-options'. The values are retrieved from `LaTeX-titlesec-section-command-list'. The values of this list are also added stand-alone as keys." (append `(("name" ,(mapcar (lambda (elt) (concat TeX-esc elt)) (if (< (LaTeX-largest-level) 2) LaTeX-titlesec-section-command-list (remove "chapter" LaTeX-titlesec-section-command-list))))) (mapcar #'list (mapcar (lambda (elt) (concat TeX-esc elt)) (if (< (LaTeX-largest-level) 2) LaTeX-titlesec-section-command-list (remove "chapter" LaTeX-titlesec-section-command-list)))) LaTeX-titlesec-key-val-options)) (TeX-add-style-hook "titlesec" (lambda () ;; Load "titleps.el" when "pagestyles" package option is given (when (LaTeX-provided-package-options-member "titlesec" "pagestyles") (TeX-run-style-hooks "titleps")) (TeX-add-symbols ;; 2.4. Tools '("titlelabel" t) ;; \titleformat*{}{} '("titleformat*" (TeX-arg-key-val (LaTeX-titlesec-titlespec-key-val-options)) t) ;; 3. Advanced Interface ;; \titleformat{}[]{}{