There is a new LaTeX package: "contract". Inside a contract environment there are two new sectioning commands:


The section command of Clause is on the level of a section, the SubSection is on the level of a subsection.

There are only optional arguments! So: \Clause{something}doesn't exist.

The most used command will be

\Clause[title=some clausetitle]

Q: Can you help me to make Emacs aware of this sectioning command in LaTeX/PS major mode (I guess this is done by AUCTeX)? If the contract package is loaded, I'd like to have a sectioning command \Clause[].

Please be aware, that there is a package scrjura which comes with a sectioning command \Clause{}. Unfortunately I have to use either scrjura or contract (never both in the same file, of course).

Almost ten years ago I've been asking a similar question. So I wrote a style file called "contract.el" and saved it besides the former "scrjura.el" in ~/.emacs.d/auctex/style.

Style files:


 (lambda ()
   (LaTeX-section-list-add-locally '(("Clause" 3)
            ("SubClause" 4)      
                     ("subsection" 4)
                     ("subsubsection" 5)
                     ("paragraph" 6)
                     ("subparagraph" 7)))


 (lambda ()
   (LaTeX-section-list-add-locally '(("Clause" 3)
            ("SubClause" 4)      
                     ("subsection" 4)
                     ("subsubsection" 5)
                     ("paragraph" 6)
                     ("subparagraph" 7)))

Having both style files doubles the output after C-=, I get the name of each clause twice. Q: If somebody could help me to get rid of double lines.




  \Clause[title=whatever first]

  Some text.

  Next paragraph.

  \Clause[title= Closing]

  Whatever more text. 
  • One question per post, please.
    – Drew
    Commented Jun 11 at 17:09

1 Answer 1


I don't think it is possible to hook the macro \Clause which takes an optional key-val argument into the machinery how AUCTeX inserts sectioning commands without a bigger surgery. Therefore I suggest you go the standard way by doing C-c C-m Clause RET where the corresponding AUCTeX style file can look like this (which is 0-tested):

;;; contract.el --- AUCTeX style for `contract.sty' (v0.91)  -*- lexical-binding: t; -*-

(defconst LaTeX-contract-clause-key-val
  "Key=val options for the \\Clause macro.")

 (lambda ()


      [TeX-arg-key-val LaTeX-contract-clause-key-val])
      [TeX-arg-key-val LaTeX-contract-clause-key-val])
    '("ellipsispar" ["Number of paragraphs to omit"])

   (let ((macs '("refL" "refS" "refN" "refClause" "refClauseN"
                 "refPar" "refParL" "refParS" "refParN"
                 "refSentence" "refSentenceL"" refSentenceS" "refSentenceN")))
     (dolist (mac macs)
       (TeX-add-symbols `(,mac TeX-arg-ref)))
     (when (and (featurep 'font-latex)
                (eq TeX-install-font-lock 'font-latex-setup))
        (mapcar (lambda (x) (list x "{")) macs)

   (LaTeX-paragraph-commands-add-locally '("Clause" "SubClause"))

   (LaTeX-add-counters "par" "sentence")

   ;; Fontification
   (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))
     (font-latex-add-keywords '(("contractSetup" "{")
                                ("ellipsispar"   "["))
     (font-latex-add-keywords '(("Clause" "["))
     (font-latex-add-keywords '(("SubClause" "["))

(defconst LaTeX-contract-package-options-list
  (let ((len (mapcar (lambda (x) (concat TeX-esc (car x)))
    `(("juratotoc" ("true" "false" "number"))
      ("juratocindent" ,len)
      ("juratocnumberwidth" ,len)
      ("juratitlepagebreak" ("true" "false"))
      ("clausemark" ("both" "false" "forceboth" "forceright" "right"))
      ("parnumber" ("true" "false" "auto" "manual"))
      ("ref" ("long" "numeric"
              "clauseonly" "onlyclause" "ClauseOnly" "OnlyClause"
              "parlong" "longpar" "ParL"
              "parnumeric" "numericpar" "ParN"
              "paroff" "nopar"
              "parshort" "shortpar" "ParS" "sentencelong" "longsentence"
              "sentencenumeric" "numericsentence" "SentenceN"
              "sentenceoff" "nosentence" "sentenceshort" "shortsentence"
  "Alist of package options for the contract package.")

(defun LaTeX-contract-package-option ()
  "Read the contract package options from the user."
  (TeX-read-key-val t LaTeX-contract-package-options-list))

;;; contract.el ends here

I suggest you take the above to auctex-devel mailing list and report back how it works. Once the style is really operational, it can be added to AUCTeX distro.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.