AUCTeX Sync -- New Style Files
[packages] / xemacs-packages / auctex / style / tcolorbox.el
1 ;;; tcolorbox.el --- AUCTeX style for `tcolorbox.sty' (v4.00)
2
3 ;; Copyright (C) 2015, 2016 Free Software Foundation, Inc.
4
5 ;; Author: Tassilo Horn <tsdh@gnu.org>
6 ;; Maintainer: auctex-devel@gnu.org
7 ;; Created: 2015-01-04
8 ;; Keywords: tex
9
10 ;; This file is part of AUCTeX.
11
12 ;; AUCTeX is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; any later version.
16
17 ;; AUCTeX is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 ;; General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with AUCTeX; see the file COPYING.  If not, write to the Free
24 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 ;; 02110-1301, USA.
26
27 ;;; Commentary:
28
29 ;; This file adds support for `tcolorbox.sty' (v4.00) from 2017/02/16.
30
31 ;; This style file adds support for core macros and environments and
32 ;; their options provided by `tcolorbox.sty'.  Macros and environments
33 ;; provided by libraries should go in their own style files where the
34 ;; file is prefixed with `tcolorboxlib-',
35 ;; e.g. `tcolorboxlib-raster.el'.
36
37 ;; Libraries should also append their key=val option to variable
38 ;; `LaTeX-tcolorbox-keyval-options-full'.  This variable is called
39 ;; with macro `\tcbset'.
40
41 ;;; Code:
42
43 ;; Needed for compiling `pushnew':
44 (eval-when-compile (require 'cl))
45
46 ;; Needed for auto-parsing.
47 (require 'tex)
48
49 ;; FIXME: Anything missing?
50 (defvar LaTeX-tcolorbox-keyval-options
51   '(;; 4.1 Title
52     ("title")
53     ("notitle")
54     ("adjusted title")
55     ("adjust text")
56     ("squeezed title")
57     ("squeezed title*")
58     ("detach title")
59     ("attach title")
60     ("attach title to upper")
61     ;; 4.2 Subtitle
62     ("subtitle style")
63     ;; 4.3 Upper Part
64     ("upperbox" ("visible" "invisible"))
65     ("visible")
66     ("invisible")
67     ("saveto")
68     ;; 4.4 Lower Part
69     ("lowerbox" ("visible" "invisible" "ignored"))
70     ("savelowerto")
71     ("lower separated" ("true" "false"))
72     ("savedelimiter")
73     ;; 4.5 Colors and Fonts
74     ("colframe")
75     ("colback")
76     ("title filled" ("true" "false"))
77     ("colbacktitle")
78     ("colupper")
79     ("collower")
80     ("coltext")
81     ("coltitle")
82     ("fontupper" ("\\rmfamily" "\\sffamily" "\\ttfamily" "\\mdseries" "\\bfseries"
83                   "\\upshape" "\\itshape" "\\slshape" "\\scshape"
84                   "\\tiny"  "\\scriptsize" "\\footnotesize"
85                   "\\small" "\\normalsize" "\\large"
86                   "\\Large" "\\LARGE" "\\huge" "\\Huge" "\\normalfont"))
87     ("fontlower" ("\\rmfamily" "\\sffamily" "\\ttfamily" "\\mdseries" "\\bfseries"
88                   "\\upshape" "\\itshape" "\\slshape" "\\scshape"
89                   "\\tiny"  "\\scriptsize" "\\footnotesize"
90                   "\\small" "\\normalsize" "\\large"
91                   "\\Large" "\\LARGE" "\\huge" "\\Huge" "\\normalfont"))
92     ("fonttitle" ("\\rmfamily" "\\sffamily" "\\ttfamily" "\\mdseries" "\\bfseries"
93                   "\\upshape" "\\itshape" "\\slshape" "\\scshape"
94                   "\\tiny"  "\\scriptsize" "\\footnotesize"
95                   "\\small" "\\normalsize" "\\large"
96                   "\\Large" "\\LARGE" "\\huge" "\\Huge" "\\normalfont"))
97     ;; 4.6 Text Alignment
98     ("halign" ("justify" "left" "flush left" "right"
99                "flush right" "center" "flush center"))
100     ("halign lower" ("justify" "left" "flush left" "right"
101                      "flush right" "center" "flush center"))
102     ("halign title" ("justify" "left" "flush left" "right"
103                      "flush right" "center" "flush center"))
104     ("flushleft upper")
105     ("center upper")
106     ("flushright upper")
107     ("flushleft lower")
108     ("center lower")
109     ("flushright lower")
110     ("flushleft title")
111     ("center title")
112     ("flushright title")
113     ("valign" ("top" "center" "bottom" "scale" "scale*"))
114     ("valign upper" ("top" "center" "bottom" "scale" "scale*"))
115     ("valign lower" ("top" "center" "bottom" "scale" "scale*"))
116     ("valign scale limit")
117     ;; 4.7 Geometry:
118     ;; 4.7.1 Width
119     ("width")
120     ("text width")
121     ("add to width")
122     ;; 4.7.2 Rules
123     ("toprule")
124     ("bottomrule")
125     ("leftrule")
126     ("rightrule")
127     ("titlerule")
128     ("boxrule")
129     ;; 4.7.3 Arcs
130     ("arc")
131     ("circular arc")
132     ("bean arc")
133     ("octogon arc")
134     ("arc is angular")
135     ("arc is curved")
136     ("outer arc")
137     ("auto outer arc")
138     ;; 4.7.4 Spacing
139     ("boxsep")
140     ("left")
141     ("left*")
142     ("lefttitle")
143     ("leftupper")
144     ("leftlower")
145     ("right")
146     ("right*")
147     ("righttitle")
148     ("rightupper")
149     ("rightlower")
150     ("top")
151     ("toptitle")
152     ("bottom")
153     ("bottomtitle")
154     ("middle")
155     ;; 4.7.5 Size Shortcuts
156     ("size" ("normal" "title" "small" "fbox" "tight" "minimal"))
157     ("oversize")
158     ("toggle left and right" ("none" "forced" "evenpage"))
159     ;; 4.8 Corners
160     ("sharp corners" ("northwest" "northeast" "southwest" "southeast"
161                       "north" "south" "east" "west" "downhill" "uphill" "all"))
162     ("rounded corners" ("northwest" "northeast" "southwest" "southeast"
163                         "north" "south" "east" "west" "downhill" "uphill" "all"))
164     ("sharpish corners")
165     ;; 4.9 Transparency
166     ("opacityframe")
167     ("opacityback")
168     ("opacitybacktitle")
169     ("opacityfill")
170     ("opacityupper")
171     ("opacitylower")
172     ("opacitytext")
173     ("opacitytitle")
174     ;; 4.10 Height Control
175     ("natural height")
176     ("height")
177     ("height plus")
178     ("height from")
179     ("text height")
180     ("add to height")
181     ("add to natural height")
182     ("height fill" ("true" "false" "maximum"))
183     ("square")
184     ("space")
185     ("space to upper")
186     ("space to lower")
187     ("space to both")
188     ("space to")
189     ("split")
190     ("equal height group")
191     ("minimum for equal height group")
192     ("minimum for current equal height group")
193     ("use height from group")
194     ;; 4.11 Box Content Additions
195     ("before title")
196     ("after title")
197     ("before upper")
198     ("after upper")
199     ("after upper*")
200     ("before lower")
201     ("after lower")
202     ("after lower*")
203     ("text fill")
204     ("tabularx")
205     ("tabularx*")
206     ("tikz upper")
207     ("tikz lower")
208     ("tikznode upper")
209     ("tikznode lower")
210     ("tikznode")
211     ("varwidth upper")
212     ;; 4.12 Overlays
213     ("overlay")
214     ("no overlay")
215     ("overlay broken")
216     ("overlay unbroken")
217     ("overlay first")
218     ("overlay middle")
219     ("overlay last")
220     ("overlay unbroken and first")
221     ("overlay middle and last")
222     ("overlay unbroken and last")
223     ("overlay first and middle")
224     ;; 4.13 Floating Objects
225     ("floatplacement" ("htbp" "t" "b" "h" "p"))
226     ("float" ("htbp" "t" "b" "h" "p"))
227     ("float*" ("htbp" "t" "b" "h" "p"))
228     ("nofloat")
229     ("every float" ("\\centering" "\\raggedleft" "\\raggedright"))
230     ;; 4.14 Embedding into the Surroundings
231     ("before")
232     ("after")
233     ("parskip")
234     ("noparskip")
235     ("autoparskip")
236     ("nobeforeafter")
237     ("forces nobeforeafter")
238     ("baseline")
239     ("box align" ("bottom" "top" "center" "base"  ))
240     ("before skip")
241     ("after skip")
242     ("beforeafter skip")
243     ("left skip")
244     ("right skip")
245     ("leftright skip")
246     ("ignore nobreak" ("true" "false"))
247     ("before nobreak")
248     ;; 4.15 Bounding Box
249     ("enlarge top initially by")
250     ("enlarge bottom finally by")
251     ("enlarge top at break by")
252     ("enlarge bottom at break by")
253     ("enlarge top by")
254     ("enlarge bottom by")
255     ("enlarge left by")
256     ("enlarge right by")
257     ("enlarge by")
258     ("flush left")
259     ("flush right")
260     ("center")
261     ("grow to left by")
262     ("grow to right by")
263     ("toggle enlargement" ("none" "forced" "evenpage"))
264     ("spread inwards")
265     ("spread outwards")
266     ("move upwards")
267     ("move upwards*")
268     ;; FIXME: This one should be added w/ `breakable' lib:
269     ;; ("fill downwards")
270     ("spread upwards")
271     ("spread upwards*")
272     ("spread sidewards")
273     ("spread")
274     ("spread downwards")
275     ("shrink tight")
276     ("extrude left by")
277     ("extrude right by")
278     ("extrude top by")
279     ("extrude bottom by")
280     ("extrude by")
281     ;; 4.16 Layered Boxes and Every Box Settings
282     ("every box")
283     ("every box on layer 1")
284     ("every box on layer 2")
285     ("every box on layer 3")
286     ("every box on layer 4")
287     ("every box on higher layers")
288     ;; 4.17 Capture Mode
289     ("capture" ("minipage" "hbox" "fitbox"))
290     ("hbox")
291     ("minipage")
292     ;; 4.18 Text Characteristics
293     ("parbox" ("true" "false"))
294     ("hyphenationfix" ("true" "false"))
295     ;; 4.19 Files
296     ("tempfile")
297     ;; 4.21 Counters, Labels, and References
298     ("phantom")
299     ("nophantom")
300     ("label")
301     ("phantomlabel")
302     ;; FIXME: Are these types documented somewhere in cleveref.pdf?
303     ("label type")
304     ("no label type")
305     ("step")
306     ("step and label")
307     ("list entry")
308     ("list text")
309     ("add to list")
310     ("nameref")
311     ;; 4.22 Even and Odd Pages
312     ("check odd page" ("true" "false"))
313     ("if odd page")
314     ("if odd page or oneside")
315     ;; FIXME: These two should be added w/ `breakable' lib:
316     ;; ("if odd page*")
317     ;; ("if odd page or oneside*")
318     ;; 4.24 Miscellaneous
319     ("reset")
320     ("only")
321     ("code")
322     ("void")
323     ;; 6 Side by Side
324     ("sidebyside" ("true" "false"))
325     ("sidebyside align" ("center" "top" "bottom" "center seam"
326                          "top seam" "bottom seam"))
327     ("sidebyside gap")
328     ("lefthand width")
329     ("righthand width")
330     ("lefthand ratio")
331     ("righthand ratio")
332     ;; 8 Recording options
333     ("record")
334     ("no recording"))
335   "Key=value options for tcolorbox macros and environments.")
336
337 (defvar LaTeX-tcolorbox-keyval-options-local nil
338    "Buffer-local key=value options for tcolorbox macros and environments.")
339 (make-variable-buffer-local 'LaTeX-tcolorbox-keyval-options-local)
340
341 (defvar LaTeX-tcolorbox-keyval-options-full nil
342   "Key=value options of tcolorbox core and all loaded libraries.")
343 (make-variable-buffer-local 'LaTeX-tcolorbox-keyval-options-full)
344
345 (defvar LaTeX-tcolorbox-tcbox-options
346   '(;; 4.20 \tcbox Specials
347     ("tcbox raise")
348     ("tcbox raise base")
349     ("on line")
350     ("tcbox width" ("auto" "auto limited" "forced center"
351                     "forced left" "forced right" "minimum center"
352                     "minimum left" "minimum right")))
353   "Key=value options only for \\tcbox and \\tcboxmath from tcolorbox.sty.")
354
355 (defvar LaTeX-tcolorbox-init-options
356   '(;; 5 Initialization Option Keys
357     ;; 5.1 Numbered Boxes
358     ("auto counter")
359     ("use counter from")
360     ("use counter")
361     ("use counter*")
362     ("no counter")
363     ("number within" ("part" "chapter" "section" "subsection"))
364     ("number format" ("\\arabic" "\\roman" "\\Roman" "\\Alph" "\\alph"))
365     ("number freestyle")
366     ("crefname")
367     ("Crefname")
368     ("blend into" ("figures" "tables" "listings"))
369     ("blend before title" ("colon" "dash" "colon hang" "dash hang"))
370     ("blend before title code")
371     ;; 5.2 Lists of tcolorboxes
372     ("list inside")
373     ("list type"))
374   "Initialization key=value options for tcolorbox macros.")
375
376 (defvar LaTeX-tcolorbox-library-list
377   '("skins"
378     "vignette"
379     "raster"
380     "listings"
381     "listingsutf8"
382     "minted"
383     "theorems"
384     "breakable"
385     "magazine"
386     "fitting"
387     "hooks"
388     "xparse"
389     "external"
390     "documentation"
391     "many" "most" "all")
392   "List with libraries provided by tcolorbox package.")
393
394 ;; Setup for \newtcolorbox:
395 (TeX-auto-add-type "tcolorbox-newtcolorbox" "LaTeX" "tcolorbox-newtcolorboxes")
396
397 (defvar LaTeX-tcolorbox-newtcolorbox-regexp
398   `(,(concat "\\\\\\(re\\)?newtcolorbox"
399              "[ \t\n\r%]*"
400              "\\(?:\\[[^][]*"
401                "\\(?:{[^}{]*"
402                  "\\(?:{[^}{]*"
403                    "\\(?:{[^}{]*}[^}{]*\\)*"
404                  "}[^}{]*\\)*"
405                "}[^][]*\\)*"
406              "\\]\\)?"
407              "[ \t\n\r%]*"
408              "{\\([a-zA-Z0-9]+\\)}"
409              "[ \t\n\r%]*"
410              "\\(?:\\[\\([0-9]*\\)\\]\\)?"
411              "[ \t\n\r%]*"
412              "\\(\\[\\)?")
413     (2 3 4 1) LaTeX-auto-tcolorbox-newtcolorbox)
414   "Matches the arguments of \\newtcolorbox from tcolorbox package.")
415
416 ;; Setup for \newtcbox:
417 (TeX-auto-add-type "tcolorbox-newtcbox" "LaTeX" "tcolorbox-newtcboxes")
418
419 (defvar LaTeX-tcolorbox-newtcbox-regexp
420   `(,(concat "\\\\\\(re\\)?newtcbox"
421              "[ \t\n\r%]*"
422              "\\(?:\\[[^][]*"
423                "\\(?:{[^}{]*"
424                  "\\(?:{[^}{]*"
425                    "\\(?:{[^}{]*}[^}{]*\\)*"
426                  "}[^}{]*\\)*"
427                "}[^][]*\\)*"
428              "\\]\\)?"
429              "[ \t\n\r%]*"
430              "{\\\\\\([a-zA-Z]+\\)}"
431              "[ \t\n\r%]*"
432              "\\(?:\\[\\([0-9]*\\)\\]\\)?"
433              "[ \t\n\r%]*"
434              "\\(\\[\\)?")
435     (2 3 4 1) LaTeX-auto-tcolorbox-newtcbox)
436   "Matches the arguments of \\newtcbox from tcolorbox package.")
437
438 ;; Setup for \tcbuselibrary:
439 (TeX-auto-add-type "tcolorbox-tcbuselibrary" "LaTeX" "tcbuselibraries")
440
441 (defvar LaTeX-tcolorbox-tcbuselibrary-regexp
442   '("\\\\tcbuselibrary{\\([^}]+\\)}"
443     1 LaTeX-auto-tcolorbox-tcbuselibrary)
444   "Matches the arguments of \\tcbuselibrary from tcolorbox package.")
445
446 (defun LaTeX-tcolorbox-load-used-libraries ()
447   "Check which tcolorbox libraries are loaded and run respective style hooks.
448 This functions checks the arguments of \\tcbuselibrary and the
449 name of libraries given in the optional argument of \\usepackage
450 call for tcolorbox and runs the style hook for them.  The file
451 for style must have the prefix \"tcolorboxlib-\" in the name,
452 e.g. \"tcolorboxlib-raster.el\"."
453   (when (LaTeX-tcolorbox-tcbuselibrary-list)
454     (let (libs)
455       (dolist (x (LaTeX-tcolorbox-tcbuselibrary-list))
456         (push (TeX-replace-regexp-in-string "[ %\n\r\t]" "" (car x)) libs))
457       (setq libs (mapconcat #'identity libs ","))
458       (dolist (x (split-string libs "," t))
459         (TeX-run-style-hooks (concat "tcolorboxlib-" x)))))
460   (when (assoc "tcolorbox" LaTeX-provided-package-options)
461     (let ((opts (cdr (assoc "tcolorbox" LaTeX-provided-package-options))))
462       (dolist (x opts)
463         (when (member x LaTeX-tcolorbox-library-list)
464           (TeX-run-style-hooks (concat "tcolorboxlib-" x)))))))
465
466 (defun LaTeX-tcolorbox-update-style-key ()
467   "Update some key=values in `LaTeX-tcolorbox-keyval-options-local'."
468   ;; Update the key=values for coloring.
469   (let* ((keys '("colframe"
470                  "colback"
471                  "colbacktitle"
472                  "colupper"
473                  "collower"
474                  "coltext"
475                  "coltitle"))
476          (tmp (copy-alist LaTeX-tcolorbox-keyval-options-local)))
477     (dolist (key keys)
478       (setq tmp (assq-delete-all (car (assoc key tmp)) tmp))
479       (pushnew
480        (list key (mapcar #'car (LaTeX-xcolor-definecolor-list))) tmp :test #'equal))
481     (setq LaTeX-tcolorbox-keyval-options-local (copy-alist tmp)))
482   (setq LaTeX-tcolorbox-keyval-options-full
483         (copy-alist LaTeX-tcolorbox-keyval-options-local)))
484
485 (defun LaTeX-tcolorbox-auto-prepare ()
486   "Clear various LaTeX-tcolorbox-* variables before parsing."
487   (setq LaTeX-auto-tcolorbox-newtcolorbox  nil
488         LaTeX-auto-tcolorbox-newtcbox      nil
489         LaTeX-auto-tcolorbox-tcbuselibrary nil))
490
491 (defun LaTeX-tcolorbox-auto-cleanup ()
492   "Process parsed results."
493   ;; Process new env's from \newtcolorbox
494   (dolist (newtcbox (apply #'append LaTeX-tcolorbox-newtcolorbox-list))
495     (let ((box (nth 0 newtcbox))
496           (arg (nth 1 newtcbox))
497           (opt (nth 2 newtcbox))
498           (renew (when (string= (nth 3 newtcbox) "re")
499                    (nth 3 newtcbox))))
500       ;; When renew'ing, delete any entry from
501       ;; `LaTeX-environment-list' first:
502       (when renew
503         (setq LaTeX-environment-list
504               (assq-delete-all
505                (car (assoc box (LaTeX-environment-list)))
506                LaTeX-environment-list)))
507       (cond (;; opt. 1st argument and mandatory argument(s)
508              (and arg (not (string= arg ""))
509                   opt (not (string= opt  "")))
510              (LaTeX-add-environments
511               (list box
512                     'LaTeX-env-args
513                     (vector 'TeX-arg-key-val 'LaTeX-tcolorbox-keyval-options-local)
514                     (1- (string-to-number arg)))))
515             (;; mandatory argument(s) only
516              (and arg (not (string= arg ""))
517                   (string-equal opt ""))
518              (LaTeX-add-environments
519               (list box (string-to-number arg))))
520             (t ; No args
521              (LaTeX-add-environments (list box))))))
522   ;;
523   ;; Process new macros from \newtcbox
524   (dolist (newtcbox (apply #'append LaTeX-tcolorbox-newtcbox-list))
525     (let ((box (nth 0 newtcbox))
526           (arg (nth 1 newtcbox))
527           (opt (nth 2 newtcbox))
528           (renew (when (string= (nth 3 newtcbox) "re")
529                    (nth 3 newtcbox))))
530       ;; When renew'ing, delete any entry from `TeX-symbol-list'
531       ;; first:
532       (when renew
533         (setq TeX-symbol-list
534               (assq-delete-all
535                (car (assoc box (TeX-symbol-list)))
536                TeX-symbol-list)))
537       (cond (;; opt. 1st argument and mandatory argument(s)
538              (and arg (not (string= arg ""))
539                   opt (not (string= opt  "")))
540              (TeX-add-symbols (list box
541                                (vector 'TeX-arg-key-val 'LaTeX-tcolorbox-keyval-options-local)
542                                (1- (string-to-number arg)))))
543             (;; mandatory argument(s) only
544              (and arg (not (string= arg ""))
545                   (string-equal opt ""))
546              (TeX-add-symbols (list box (string-to-number arg))))
547             (t ; No args -- in pratice, this will probably never happen
548              (TeX-add-symbols (list box))))))
549   ;;
550   ;; Update key=vals
551   (LaTeX-tcolorbox-update-style-key)
552   ;;
553   ;; Load style hooks for libraries, if any.
554   (LaTeX-tcolorbox-load-used-libraries))
555
556 (add-hook 'TeX-auto-prepare-hook #'LaTeX-tcolorbox-auto-prepare t)
557 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-tcolorbox-auto-cleanup t)
558 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
559
560 (TeX-add-style-hook
561  "tcolorbox"
562  (lambda ()
563
564    ;; Activate the buffer-local version of key-vals.
565    (setq LaTeX-tcolorbox-keyval-options-local
566          (copy-alist LaTeX-tcolorbox-keyval-options))
567
568    ;; Collect key=val's from libraries in
569    ;; `LaTeX-tcolorbox-keyval-options-full'; \tcbset needs this:
570    (setq LaTeX-tcolorbox-keyval-options-full
571          (copy-alist LaTeX-tcolorbox-keyval-options-local))
572
573    ;; Add tcolorbox to the parser.
574    (TeX-auto-add-regexp LaTeX-tcolorbox-newtcolorbox-regexp)
575    (TeX-auto-add-regexp LaTeX-tcolorbox-newtcbox-regexp)
576    (TeX-auto-add-regexp LaTeX-tcolorbox-tcbuselibrary-regexp)
577
578    ;; We just run the style hook for `xcolor' which is loaded by pgf.sty
579    (TeX-run-style-hooks "xcolor")
580
581    ;; FIXME: Anything missing?
582    (TeX-add-symbols
583
584     ;; 1.3 Libraries
585     '("tcbuselibrary"
586       (TeX-arg-eval mapconcat #'identity
587                     (TeX-completing-read-multiple
588                      (TeX-argument-prompt optional nil "Libraries")
589                      LaTeX-tcolorbox-library-list) ","))
590
591     ;; 3 Macros for Box Creation
592     '("tcblower" 0)
593
594     '("tcbset"
595       (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-full))
596
597     '("tcbsetforeverylayer"
598       (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local))
599
600     '("tcbox"
601       [ TeX-arg-eval TeX-read-key-val optional
602                      (append
603                       LaTeX-tcolorbox-tcbox-options
604                       LaTeX-tcolorbox-keyval-options-local) ]
605       t)
606
607     '("newtcolorbox"
608       [ TeX-arg-key-val LaTeX-tcolorbox-init-options ]
609       "Name"
610       [ TeX-arg-define-macro-arguments ]
611       (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local))
612
613     '("renewtcolorbox"
614       [ TeX-arg-key-val LaTeX-tcolorbox-init-options ]
615       (TeX-arg-eval completing-read
616                     (TeX-argument-prompt optional nil "Color box")
617                     (LaTeX-tcolorbox-newtcolorbox-list))
618       [ TeX-arg-define-macro-arguments ]
619       (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local))
620
621     '("newtcbox"
622       [ TeX-arg-key-val LaTeX-tcolorbox-init-options ]
623       TeX-arg-macro
624       [ TeX-arg-define-macro-arguments ]
625       (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local))
626
627     '("renewtcbox"
628       [ TeX-arg-key-val LaTeX-tcolorbox-init-options ]
629       (TeX-arg-eval
630        (lambda ()
631          (let ((macro (completing-read
632                        (TeX-argument-prompt optional nil "Macro: \\" t)
633                        (LaTeX-tcolorbox-newtcbox-list))))
634            (concat TeX-esc macro))))
635       [ TeX-arg-define-macro-arguments ]
636       (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local))
637
638     '("tcolorboxenvironment"
639       TeX-arg-environment
640       (TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local))
641
642     ;; 4.16 Layered Boxes and Every Box Settings
643     '("tcbsetmanagedlayer" "Number")
644
645     ;; 4.22 Even and Odd Pages
646     '("tcbifoddpage" 2)
647     '("tcbifoddpageoroneside" 2)
648     '("thetcolorboxnumber" 0)
649     '("thetcolorboxpage" 0)
650
651     ;; 5.2 Lists of tcolorboxes
652     '("tcblistof"
653       [ TeX-arg-eval completing-read
654                      (TeX-argument-prompt optional nil "Macro")
655                      (if (< (LaTeX-largest-level) 2)
656                          '("\\chapter" "\\section" "\\subsection" "\\subsubsection")
657                        '("\\section" "\\subsection" "\\subsubsection")) ]
658       2)
659
660     ;; 7 Saving and Loading of Verbatim Texts
661     '("tcbusetemp")
662
663     ;; 8 Recording
664     '("tcbstartrecording" [ "File name" ])
665     '("tcbstoprecording")
666     '("tcbrecord" t)
667     '("tcbinputrecords" [ TeX-arg-file ]) ) ; Terminate TeX-add-symbols
668
669    (LaTeX-add-environments
670     ;; 3 Macros for Box Creation: Main env
671     '("tcolorbox" LaTeX-env-args
672       [ TeX-arg-key-val LaTeX-tcolorbox-keyval-options-local ])
673
674     ;; 7 Saving and Loading of Verbatim Texts
675     '("tcbverbatimwrite" "File name")
676     '("tcbwritetemp"))
677
678    ;; Do not indent text in verbatim environments:
679    (make-local-variable 'LaTeX-indent-environment-list)
680    (add-to-list 'LaTeX-indent-environment-list
681                 '("tcbverbatimwrite" current-indentation) t)
682    (add-to-list 'LaTeX-indent-environment-list
683                 '("tcbwritetemp" current-indentation) t)
684
685    ;; Fontification
686    (when (and (featurep 'font-latex)
687               (eq TeX-install-font-lock 'font-latex-setup))
688      (font-latex-add-keywords '(("tcbuselibrary"        "{")
689                                 ("tcbset"               "{")
690                                 ("tcbsetforeverylayer"  "{")
691                                 ("tcbox"                "[{")
692                                 ("newtcolorbox"         "[{[[{")
693                                 ("renewtcolorbox"       "[{[[{")
694                                 ("newtcbox"             "[{[[{")
695                                 ("renewtcbox"           "[{[[{")
696                                 ("tcolorboxenvironment" "{{")
697                                 ("tcbsetmanagedlayer"   "{"))
698                               'function)))
699  LaTeX-dialect)
700
701 (defvar LaTeX-tcolorbox-package-options LaTeX-tcolorbox-library-list
702   "Package options for the tcolorbox package.")
703
704 ;;; tcolorbox.el ends here