1 ;;; floatrow.el --- AUCTeX style for `floatrow.sty' (v0.3b)
3 ;; Copyright (C) 2017 Free Software Foundation, Inc.
5 ;; Author: Arash Esbati <arash@gnu.org>
6 ;; Maintainer: auctex-devel@gnu.org
10 ;; This file is part of AUCTeX.
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)
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.
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
29 ;; This file adds support for `floatrow.sty' (v0.3b) from 2009/08/02.
30 ;; `floatrow.sty' is part of TeXLive.
32 ;; `floatrow.sty' is a powerful package and the documentation long.
33 ;; It is expected that this style is not feature complete. One
34 ;; deliberate decision is that this style does not offer any package
35 ;; options: Please use the command `\floatsetup' to set the options
38 ;; This style also alters the way AUCTeX inserts the environments
39 ;; "table" and "figure" (cf. function `LaTeX-floatrow-env-init'). If
40 ;; you want the original behavior, try `C-c C-e rawfigure' or `C-c C-e
41 ;; rawtable' which include the environments incl. the macro \RawFloats
42 ;; at the beginning of the environment (cf. function
43 ;; `LaTeX-floatrow-env-figure-raw').
45 ;; Another deliberate decision is the implementation of commands like
46 ;; `\ffigbox' and `\ttabbox': When invoked with `C-c C-m ffigbox RET',
47 ;; the final result will look like this with cursor being at *:
50 ;; \caption{query for a caption}%
51 ;; \label{prefix:is-chosen-acc-to-current-environment}%
54 ;; This gives users the freedom to insert any command where point is.
55 ;; The mandatory arguments are not part of the fontification as
56 ;; commands like `\includegraphics' or `tabular' environments have their
61 ;; Needed for compiling `pushnew':
62 (eval-when-compile (require 'cl))
64 ;; Needed for auto-parsing.
67 (defvar LaTeX-floatrow-key-val-options
68 '(;; 3.1.1 Float Style
69 ("style" ("plain" "plaintop" "Plaintop"
71 "boxed" "Boxed" "BOXED"
72 "shadowbox" "Shadowbox" "SHADOWBOX"
73 "doublebox" "Doublebox" "DOUBLEBOX"
74 "wshadowbox" "Wshadowbox" "WSHADOWBOX"))
75 ;; 3.1.2 Font Settings
76 ("font" ("scriptsize" "footnotesize" "small" "normalsize" "large"
77 "Large" "normalfont" "up" "it" "sl" "sc" "md" "bf"
79 ("footfont" ("scriptsize" "footnotesize" "small" "normalsize" "large"
80 "Large" "normalfont" "up" "it" "sl" "sc" "md" "bf"
82 ;; 3.1.3 Position of Caption
83 ("capposition" ("top" "TOP" "bottom" "beside"))
84 ;; 3.1.4 Position of Beside Caption
85 ("capbesideposition" ("left" "right" "inside" "outside"
86 "top" "bottom" "center"))
87 ;; 3.1.5 Defining The Width of Beside Caption
88 ("capbesidewidth" ("none" "sidefil"))
89 ;; 3.1.6 Defining Width of Object
90 ("floatwidth" ("\\hsize" "\\textwidth" "\\columnwidth" "\\linewidth"))
91 ;; 3.1.7 Other Settings for Beside Captions
92 ("capbesideframe" ("yes" "no"))
93 ;; 3.1.8 Defining Float Foot Position (Legends and Footnotes)
94 ("footposition" ("default" "caption" "bottom"))
95 ;; 3.1.9 Vertical Alignment of Float Elements
96 ("heightadjust" ("all" "caption" "object" "none" "nocaption" "noobject"))
97 ("valign" ("t" "c" "b" "s"))
98 ;; 3.1.10 Facing Layout
99 ("facing" ("yes" "no"))
100 ;; 3.1.11 Object Settings
101 ("objectset" ("justified" "centering" "raggedright" "RaggedRight" "raggedleft"))
102 ;; 3.1.12 Defining Float Margins
103 ("margins" ("centering" "raggedright" "raggedleft"
104 "hangright" "hanginside" "hangoutside"))
105 ;; 3.1.13 Defining Float Separators
106 ("floatrowsep" ("columnsep" "quad" "qquad" "hfil" "hfill" "none"))
107 ("capbesidesep" ("columnsep" "quad" "qquad" "hfil" "hfill" "none"))
108 ;; 3.1.14 Defining Float Rules/Skips
109 ("precode" ("none" "thickrule" "rule" "lowrule" "captionskip"))
110 ("rowprecode" ("none" "thickrule" "rule" "lowrule" "captionskip"))
111 ("midcode" ("none" "thickrule" "rule" "lowrule" "captionskip"))
112 ("postcode" ("none" "thickrule" "rule" "lowrule" "captionskip"))
113 ("rowpostcode" ("none" "thickrule" "rule" "lowrule" "captionskip"))
114 ;; 3.1.15 Defining Float Frames
115 ("framestyle" ("fbox" "colorbox" "FRcolorbox" "corners"
116 "doublebox" "shadowbox" "wshadowbox"))
118 ("framearound" ("none" "object" "all" "row" "none"))
119 ("framefit" ("yes" "no"))
120 ("rowfill" ("yes" "no"))
121 ;; 3.1.16 Settings for Colored Frames
123 ("colorframecorners")
124 ;; 3.1.17 Defining Float Skips
127 ;; 3.1.18 Defining Float Footnote Rule's Style
128 ("footnoterule" ("normal" "limited" "fullsize" "none"))
129 ;; 3.1.19 Managing Floats with [H] Placement Option
130 ("doublefloataswide" ("yes" "no"))
131 ("floatHaslist" ("yes" "no"))
132 ;; 7.2.1 Additions in The floatrow Package to longtable package
133 ("LTcapwidth" ("table" "contents")))
134 "Key=value options for floatrow macros and environments.")
136 (defvar LaTeX-floatrow-key-val-options-local nil
137 "Buffer-local key=value options for floatrow macros and environments.")
138 (make-variable-buffer-local 'LaTeX-floatrow-key-val-options-local)
140 (defvar LaTeX-floatrow-supported-float-types
141 '("figure" "table" ; Standard LaTeX
142 "widefigure" "widetable" "widefloat" ; Standard figure* & table*
143 "wrapfigure" "wraptable" "wrapfloat" ; wrapfig.sty
144 "rotfigure" "rottable" "rotfloat" ; rotating.sty
145 "widerotfigure" "widerottable" "widerotfloat" ; for 2-col & wide
146 "figurerow" "tablerow" "floatrow" ; inside floatrow env's
147 "capbesidefigure" "capbesidetable" ; floats with beside captions
149 "longtable" ; longtable.sty
150 "subfigure" "subtable" "sub") ; subcaption.sty
151 "List of float types supported by floatrow.sty.")
153 ;; Setup for \newfloatcommand
154 (TeX-auto-add-type "floatrow-newfloatcommand" "LaTeX")
156 (defvar LaTeX-floatrow-newfloatcommand-regexp
157 '("\\\\newfloatcommand{\\([^}]+\\)}" 1 LaTeX-auto-floatrow-newfloatcommand)
158 "Matches the arguments of \"\\newfloatcommand\" from floatrow.sty.")
160 ;; Setup for various \Declare* macros:
161 (TeX-auto-add-type "floatrow-DeclareNewOption" "LaTeX")
163 (defvar LaTeX-floatrow-DeclareNewOption-regexp
167 (mapconcat #'identity
168 '("FloatStyle" ; 3.6.1 Float Style Option (style=)
169 "FloatFont" ; 3.6.2 Float Font Option (font=)
170 "FloatVCode" ; 3.6.3 Option for Float Rules/Skips (precode= etc.)
171 "ColorBox" ; 3.6.4 Settings for Colored Frame (colorframeset=)
172 "CBoxCorners" ; colorframecorners=
173 "ObjectSet" ; 3.6.5 Object Justification Option (objectset=)
174 "MarginSet" ; 3.6.6 Option for Float Box Alignment/Settings (margins=)
175 "FloatSeparators" ; 3.6.7 Float Separators Options (floatrowsep=, capbesidesep=)
176 "FloatFootnoterule") ; 3.6.8 Option for Footnote Rule's Style (footnoterule=)
180 (0 1 2) LaTeX-auto-floatrow-DeclareNewOption)
181 "Matches the arguments of \"\\Declare*\" from floatrow.sty.")
183 ;; Setup for \newseparated(label|ref):
184 (TeX-auto-add-type "floatrow-newseparatedlabel-ref" "LaTeX")
186 (defvar LaTeX-floatrow-newseparatedlabel-ref-regexp
194 (2 1) LaTeX-auto-floatrow-newseparatedlabel-ref)
195 "Matches the arguments \"\\newseparated(label|ref)\" command from floatrow.sty.")
197 ;; Setup for \DeclareNewFloatType:
198 (TeX-auto-add-type "floatrow-DeclareNewFloatType" "LaTeX")
200 (defvar LaTeX-floatrow-DeclareNewFloatType-regexp
201 '("\\\\DeclareNewFloatType{\\([^}]+\\)}"
202 1 LaTeX-auto-floatrow-DeclareNewFloatType)
203 "Matches the argument of \"\\DeclareNewFloatType\" command from floatrow.sty.")
205 ;; Plug them into the machinery.
206 (defun LaTeX-floatrow-auto-prepare ()
207 "Clear various \"LaTeX-floatrow\" variables before parsing."
208 (setq LaTeX-auto-floatrow-newfloatcommand nil
209 LaTeX-auto-floatrow-DeclareNewOption nil
210 LaTeX-auto-floatrow-newseparatedlabel-ref nil
211 LaTeX-auto-floatrow-DeclareNewFloatType nil))
213 (defun LaTeX-floatrow-auto-cleanup ()
214 "Process parsed results from floatrow package."
215 ;; Replace initially the way fig & tab env's are inserted:
216 (LaTeX-floatrow-env-init)
218 ;; Process new key=val options:
219 (when (LaTeX-floatrow-DeclareNewOption-list)
220 (LaTeX-floatrow-update-key-val-options))
222 ;; Process new float commands like \ffigbox:
223 (when (LaTeX-floatrow-newfloatcommand-list)
224 (dolist (cmd (mapcar #'car (LaTeX-floatrow-newfloatcommand-list)))
225 (TeX-add-symbols `(,cmd LaTeX-floatrow-arg-floatbox))
226 (when (and (featurep 'font-latex)
227 (eq TeX-install-font-lock 'font-latex-setup))
228 (font-latex-add-keywords `((,cmd "[[["))
231 ;; Process new label/ref commands:
232 (when (LaTeX-floatrow-newseparatedlabel-ref-list)
233 (let (floatrow-run-reftex-compile-vars)
234 (dolist (elt (LaTeX-floatrow-newseparatedlabel-ref-list))
235 (let ((cmd (car elt))
237 (if (string= type "ref")
238 ;; More fun w/ referencing macros:
239 (TeX-add-symbols `(,cmd TeX-arg-ref))
240 ;; Less fun w/ label defining macros. Add cmd to
242 (TeX-add-symbols `(,cmd TeX-arg-define-label))
243 ;; For AUCTeX, parse the argument of the new macro and add
244 ;; it to `LaTeX-auto-label':
246 `(,(concat "\\\\" cmd "{\\([^\n\r%\\{}]+\\)}") 1 LaTeX-auto-label))
247 ;; For RefTeX, append cmd to `reftex-label-regexps and set
248 ;; floatrow-run-reftex-compile-vars to t:
249 (when (and (boundp 'reftex-label-regexps)
250 (fboundp 'reftex-compile-variables)
253 (mapconcat #'identity reftex-label-regexps "|"))))
254 (add-to-list (make-local-variable 'reftex-label-regexps)
255 (concat "\\\\" cmd "{\\(?1:[^}]*\\)}") t)
256 (setq floatrow-run-reftex-compile-vars t)))
257 ;; Fontify macros as reference:
258 (when (and (featurep 'font-latex)
259 (eq TeX-install-font-lock 'font-latex-setup))
260 (font-latex-add-keywords `((,cmd "{"))
262 ;; Run `reftex-compile-variables' if needed only once:
263 (when floatrow-run-reftex-compile-vars
264 (reftex-compile-variables))))
266 ;; Process new floattypes:
267 (when (LaTeX-floatrow-DeclareNewFloatType-list)
268 (LaTeX-floatrow-arg-declare-new-floattype nil t))
270 ;; Add elements from `LaTeX-floatrow-supported-float-types' to
271 ;; `LaTeX-caption-supported-float-types':
272 (when (boundp 'LaTeX-caption-supported-float-types)
273 (make-local-variable 'LaTeX-caption-supported-float-types)
274 (dolist (float LaTeX-floatrow-supported-float-types)
275 (add-to-list 'LaTeX-caption-supported-float-types float t))) )
277 (add-hook 'TeX-auto-prepare-hook #'LaTeX-floatrow-auto-prepare t)
278 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-floatrow-auto-cleanup t)
279 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
281 (defun LaTeX-floatrow-update-key-val-options ()
282 "Update buffer-local key-val options before offering for completion."
283 (let ((vcode-keys '("precode" "rowprecode" "midcode" "postcode" "rowpostcode"))
284 (sep-keys '("floatrowsep" "capbesidesep")))
285 (dolist (keyvals (LaTeX-floatrow-DeclareNewOption-list))
286 (let* ((key (cond ((string= (nth 1 keyvals) "FloatStyle")
288 ((string= (nth 1 keyvals) "FloatFont")
290 ((string= (nth 1 keyvals) "FloatVCode")
292 ((string= (nth 1 keyvals) "ColorBox")
294 ((string= (nth 1 keyvals) "CBoxCorners")
296 ((string= (nth 1 keyvals) "ObjectSet")
298 ((string= (nth 1 keyvals) "MarginSet")
300 ((string= (nth 1 keyvals) "FloatSeparators")
302 ((string= (nth 1 keyvals) "FloatFootnoterule")
305 (val (nth 2 keyvals))
306 (val-match (cadr (assoc key LaTeX-floatrow-key-val-options-local)))
307 (temp (copy-alist LaTeX-floatrow-key-val-options-local))
308 (opts (cond ((string= key "precode")
309 (dolist (x vcode-keys)
310 (setq temp (assq-delete-all (car (assoc x temp)) temp)))
312 ((string= key "floatrowsep")
313 (setq temp (dolist (x sep-keys)
314 (assq-delete-all (car (assoc x temp)) temp)))
317 (assq-delete-all (car (assoc key temp)) temp)))))
318 (cond ((string= key "precode")
319 (dolist (x vcode-keys)
320 (pushnew (list x (TeX-delete-duplicate-strings (append (list val) val-match)))
321 opts :test #'equal)))
322 ((string= key "floatrowsep")
324 (pushnew (list x (TeX-delete-duplicate-strings (append (list val) val-match)))
325 opts :test #'equal)))
327 (pushnew (list key (TeX-delete-duplicate-strings (append (list val) val-match)))
328 opts :test #'equal)))
329 (setq LaTeX-floatrow-key-val-options-local (copy-alist opts))))))
331 (defun LaTeX-floatrow-arg-floatbox (optional)
332 "Query and insert arguments of float box commands from floatrow.sty.
333 If OPTIONAL is non-nil, indicate optional argument during query."
334 ;; Query for the optional arguments; ask for "vertpos" only if
335 ;; "height" is given. let-bind `TeX-arg-*-brace' for
336 ;; `TeX-argument-insert':
337 (let* ((TeX-arg-opening-brace "[")
338 (TeX-arg-closing-brace "]")
339 (width (completing-read
340 (TeX-argument-prompt t nil "Width")
341 (mapcar (lambda (x) (concat TeX-esc (car x)))
342 (LaTeX-length-list))))
343 (height (completing-read
344 (TeX-argument-prompt t nil "Height")
345 (mapcar (lambda (x) (concat TeX-esc (car x)))
346 (LaTeX-length-list))))
347 (vertpos (if (string= height "")
350 (TeX-argument-prompt t nil "Vertical alignment")
351 '("t" "c" "b" "s")))))
352 (TeX-argument-insert width t)
353 ;; Insert an extra pair of brackets if only `height' is given,
354 ;; otherwise it will become `width'
355 (when (and (string= width "")
356 height (not (string= height "")))
358 (TeX-argument-insert height t)
359 (TeX-argument-insert vertpos t))
360 ;; Now query for the (short-)caption. Also check for the
361 ;; float-type; if we're inside (sub)?floatrow*?, then check for the
362 ;; next outer environment:
363 (let* ((currenv (if (string-match "floatrow\\*?\\_>" (LaTeX-current-environment))
364 (LaTeX-current-environment 2)
365 (LaTeX-current-environment)))
366 (caption (TeX-read-string
367 (TeX-argument-prompt optional nil "Caption")))
369 (when (>= (length caption) LaTeX-short-caption-prompt-length)
371 (TeX-argument-prompt t nil "Short caption")))))
372 (indent-according-to-mode)
373 ;; The final result will look like this with * being point:
380 ;; We are inside the 1. mandatory arg: Save the pos & insert `}{':
381 (insert TeX-grcl TeX-grop)
382 (if (and caption (not (string= caption "")))
384 ;; If caption, move to EOL, delete any spaces and hide the line end
386 (delete-horizontal-space)
388 ;; Add a newline and the caption
390 (insert (LaTeX-compose-caption-macro caption short-caption))
391 ;; If we have a caption, then we probably also want a
392 ;; label. Hide EOL end and proceed to enter a label
395 (when (LaTeX-label currenv 'environment)
396 ;; Move point to end of line and hide EOL
398 (delete-horizontal-space)
400 (newline-and-indent))
401 ;; Now close the group
403 (indent-according-to-mode)
405 ;; Otherwise, only insert a }
406 (insert TeX-grcl)))))
408 (defun LaTeX-floatrow-env-init ()
409 "Replace AUCTeX entries in the variable `LaTeX-environment-list'.
410 After loading the style hook floatrow.el, delete the entries for
411 figure*? and table*? from variable `LaTeX-environment-list' and
412 replace them with the ones offered by the style. Original
413 entries are available under \"rawfigure*?\" and \"rawtable*?\"."
414 (LaTeX-environment-list)
415 (dolist (env '("figure" "figure*" "table" "table*"))
416 (setq LaTeX-environment-list
417 (assq-delete-all (car (assoc env LaTeX-environment-list))
418 LaTeX-environment-list))
419 (LaTeX-add-environments `(,env LaTeX-floatrow-env-figure)
420 `(,(concat "raw" env) LaTeX-floatrow-env-figure-raw))))
422 (defun LaTeX-floatrow-env-figure (environment)
423 "Create floating ENVIRONMENT suitable for floatrow macros."
424 (let ((float (and LaTeX-float
426 (TeX-argument-prompt t nil "Float position")
428 (LaTeX-insert-environment environment
429 (unless (zerop (length float))
430 (concat LaTeX-optop float LaTeX-optcl)))))
432 (defun LaTeX-floatrow-env-figure-raw (env)
433 "Create raw floating ENV with floatrow.sty.
434 Also insert the macro \"\\RawFloats\" when finished with user
436 (let ((environment (TeX-replace-regexp-in-string "raw" "" env)))
437 (LaTeX-env-figure environment)
439 ;; `LaTeX-find-matching-begin' will not work for us as we don't
440 ;; know how user answers queries from AUCTeX, hence we search
441 ;; back for `environment':
442 (re-search-backward (concat "\\\\begin{" environment "}") nil t)
445 (indent-according-to-mode)
446 (insert TeX-esc "RawFloats"))))
448 (defun LaTeX-floatrow-arg-declare-new-options (optional prompt key)
449 "Query and insert user-defined values to keys provided by floatrow.sty.
450 If OPTIONAL is non-nil, ask for an optional argument and insert
451 it in square brackets. PROMPT replaces the standard one. KEY is
452 a string and corresponds to first parsed element in
453 `LaTeX-floatrow-DeclareNewOption-regexp'."
454 (let ((val (TeX-read-string
455 (TeX-argument-prompt optional prompt "New value option"))))
456 (LaTeX-add-floatrow-DeclareNewOptions
457 (list (concat TeX-esc "Declare" key TeX-grop val TeX-grcl)
459 (LaTeX-floatrow-update-key-val-options)
460 (TeX-argument-insert val optional)
462 (TeX-read-key-val optional LaTeX-floatrow-key-val-options-local) optional)))
464 (defun LaTeX-floatrow-arg-newseparatedlabel/ref (optional type)
465 "Query and insert user defined label and reference macros from floatrow.sty.
466 If OPTIONAL is non-nil, insert the argument in brackets. TYPE is
467 the string \"label\" or \"ref\"."
468 (let ((cmd (TeX-read-string
469 (if (string= type "label")
470 (TeX-argument-prompt optional nil "Label command: \\" t)
471 (TeX-argument-prompt optional nil "Reference command: \\" t)))))
472 (LaTeX-add-floatrow-newseparatedlabel-refs (list cmd type))
473 (if (string= type "label")
474 (TeX-add-symbols `(,cmd TeX-arg-define-label))
475 (TeX-add-symbols `(,cmd TeX-arg-ref)))
476 (TeX-argument-insert cmd optional TeX-esc)))
478 (defun LaTeX-floatrow-arg-declare-new-floattype (optional &optional cleanup)
479 "Query and insert the first argument of \"DeclareNewFloatType\" macro from floatrow.sty.
480 If OPTIONAL is non-nil, insert the argument in brackets. If
481 CLEANUP in non-nil, skip the query and insert process as we are
482 inside the function `LaTeX-floatrow-auto-cleanup' and process
483 only the parsed items."
484 (let ((type (if cleanup
485 (mapcar #'car (LaTeX-floatrow-DeclareNewFloatType-list))
486 (list (TeX-read-string
487 (TeX-argument-prompt optional nil "Environment type"))))))
488 ;; If not inside `LaTeX-floatrow-auto-cleanup', add user input to
489 ;; list of new floats and insert it
491 (LaTeX-add-floatrow-DeclareNewFloatTypes (car type))
492 (TeX-argument-insert (car type) optional))
493 ;; Make the next variables buffer local
494 (make-local-variable 'LaTeX-floatrow-supported-float-types)
495 (when (boundp 'LaTeX-caption-supported-float-types)
496 (make-local-variable 'LaTeX-caption-supported-float-types))
497 ;; Process new float type(s): a) add type to list of known
498 ;; environments incl. "raw" version b) add different flavors of
499 ;; type to `LaTeX-floatrow-supported-float-types' c) check if
500 ;; `LaTeX-caption-supported-float-types' is bound and add
501 ;; different flavors of type to it as well
503 (LaTeX-add-environments `(,elt LaTeX-floatrow-env-figure)
504 `(,(concat "raw" elt) LaTeX-floatrow-env-figure-raw))
505 (add-to-list 'LaTeX-floatrow-supported-float-types elt t)
506 (add-to-list 'LaTeX-floatrow-supported-float-types (concat "wide" elt) t)
507 (add-to-list 'LaTeX-floatrow-supported-float-types (concat elt "row") t)
508 (add-to-list 'LaTeX-floatrow-supported-float-types (concat "capbeside" elt) t)
509 (when (boundp 'LaTeX-caption-supported-float-types)
510 (add-to-list 'LaTeX-caption-supported-float-types elt t)
511 (add-to-list 'LaTeX-caption-supported-float-types (concat "wide" elt) t)
512 (add-to-list 'LaTeX-caption-supported-float-types (concat elt "row") t)
513 (add-to-list 'LaTeX-caption-supported-float-types (concat "capbeside" elt) t)))))
519 ;; Add floatrow to the parser
520 (TeX-auto-add-regexp LaTeX-floatrow-DeclareNewOption-regexp)
521 (TeX-auto-add-regexp LaTeX-floatrow-newfloatcommand-regexp)
522 (TeX-auto-add-regexp LaTeX-floatrow-newseparatedlabel-ref-regexp)
523 (TeX-auto-add-regexp LaTeX-floatrow-DeclareNewFloatType-regexp)
525 ;; Activate the buffer-local version of key-vals
526 (setq LaTeX-floatrow-key-val-options-local
527 (copy-alist LaTeX-floatrow-key-val-options))
529 ;; Add pre-defined float commands:
530 (LaTeX-add-floatrow-newfloatcommands
531 "ffigbox" "fcapside" "ttabbox")
535 ;; 2.1 The \floatbox Macro
536 ;; \floatbox[<preamble>]{<captype>}[<width>][<height>][<vert pos>]{<caption>}{<object>}
538 [ TeX-arg-eval completing-read
539 (TeX-argument-prompt optional nil "Preamble")
540 '("\\capbeside" "\\nocapbeside" "\\captop") ]
541 (TeX-arg-eval completing-read
542 (TeX-argument-prompt optional nil "Float type")
543 LaTeX-floatrow-supported-float-types)
544 LaTeX-floatrow-arg-floatbox)
546 ;; 2.2 Creation of Personal Commands for Float Boxes
550 (let ((cmd (TeX-read-string
551 (TeX-argument-prompt optional nil "Command"))))
552 (LaTeX-add-floatrow-newfloatcommands cmd)
554 `(,cmd LaTeX-floatrow-arg-floatbox))
556 (TeX-arg-eval completing-read
557 (TeX-argument-prompt optional nil "Float type")
561 '("renewfloatcommand"
562 (TeX-arg-eval completing-read
563 (TeX-argument-prompt optional nil "Command")
564 (LaTeX-floatrow-newfloatcommand-list))
565 (TeX-arg-eval completing-read
566 (TeX-argument-prompt optional nil "Float type")
571 ;; 2.2.2 Predefined Float Box Commands
573 LaTeX-floatrow-arg-floatbox)
576 LaTeX-floatrow-arg-floatbox)
579 LaTeX-floatrow-arg-floatbox)
582 '("CenterFloatBoxes" 0)
584 '("BottomFloatBoxes" 0)
585 '("PlainFloatBoxes" 0)
588 ;; 3 Float Layout Settings
590 [ TeX-arg-eval completing-read
591 (TeX-argument-prompt optional nil "Float type")
592 LaTeX-floatrow-supported-float-types ]
593 (TeX-arg-key-val LaTeX-floatrow-key-val-options-local))
595 ;; 3.2 Settings for Current Float Environment
597 (TeX-arg-key-val LaTeX-floatrow-key-val-options-local))
599 ;; 3.3 Clearing of Settings for Current Float Type
601 (TeX-arg-eval completing-read
602 (TeX-argument-prompt optional nil "Float type")
603 LaTeX-floatrow-supported-float-types))
605 ;; 3.4 Temporary Clearing of All Float Settings
606 '("killfloatstyle" 0)
608 ;; 3.6.1 Float Style Option (style=)
609 '("DeclareFloatStyle"
610 (LaTeX-floatrow-arg-declare-new-options "New style option"
613 ;; 3.6.2 Float Font Option (font=)
615 (LaTeX-floatrow-arg-declare-new-options "New font option"
618 ;; 3.6.3 Option for Float Rules/Skips (precode= etc.)
619 '("DeclareFloatVCode"
620 (LaTeX-floatrow-arg-declare-new-options "New rules/skip option"
623 ;; 3.6.4 Settings for Colored Frame (colorframeset=)
625 (LaTeX-floatrow-arg-declare-new-options "New colored frame option"
628 ;; (colorframecorners=)
629 '("DeclareCBoxCorners"
630 (LaTeX-floatrow-arg-declare-new-options "New colored corner option"
633 ;; 3.6.5 Object Justification Option (objectset=)
635 (LaTeX-floatrow-arg-declare-new-options "New object justification"
638 ;; 3.6.6 Option for Float Box Alignment/Settings (margins=)
640 (LaTeX-floatrow-arg-declare-new-options "New alignment option"
643 '("setfloatmargins" 2)
644 '("setfloatmargins*" 2)
647 '("floatboxmargins" 2)
648 '("floatrowmargins" 2)
649 '("floatcapbesidemargins" 2)
651 ;; 3.6.7 Float Separators Options (floatrowsep=, capbesidesep=)
652 '("DeclareFloatSeparators"
653 (LaTeX-floatrow-arg-declare-new-options "New separator option"
656 ;; 3.6.8 Option for Footnote Rule's Style (footnoterule=)
657 '("DeclareFloatFootnoterule"
658 (LaTeX-floatrow-arg-declare-new-options "New footnote rule option"
659 "FloatFootnoterule"))
661 ;; 4 Creation of New Float Types
662 '("DeclareNewFloatType"
663 (LaTeX-floatrow-arg-declare-new-floattype)
664 (TeX-arg-key-val (("placement" ("tbp" "t" "b" "p"))
667 ("within" ("chapter" "section" "subsection"))
668 ("relatedcapstyle" ("yes" "no")))))
670 ;; 6.2 Support of The Label-Sublabel References
671 '("newseparatedlabel"
672 (LaTeX-floatrow-arg-newseparatedlabel/ref "label") 2)
675 (LaTeX-floatrow-arg-newseparatedlabel/ref "ref") t)
677 '("makelabelseparator" t) ) ;; terminate TeX-add-symbols
680 (LaTeX-add-environments
681 ;; 2.3 Building Float Row
682 '("floatrow" [ "Number of beside floats" ])
684 ;; 6.1 Managing of Float Parts With the subfloatrow Environment
685 '("subfloatrow" [ "Number of beside floats" ])
686 '("subfloatrow*" [ "Number of beside floats" ]))
688 ;; 2.1.1 Float Box Width Equals to The Width of Object Contents
689 (LaTeX-add-lengths "FBwidth" "FBheight" "Xhsize")
692 (when (and (featurep 'font-latex)
693 (eq TeX-install-font-lock 'font-latex-setup))
694 (font-latex-add-keywords '(("floatbox" "[{[[[")
699 (font-latex-add-keywords '(("newfloatcommand" "{{[[")
700 ("renewfloatcommand" "{{[[")
703 ("thisfloatsetup" "{")
704 ("clearfloatsetup" "{")
705 ("killfloatstyle" "")
706 ("DeclareFloatStyle" "{{")
707 ("DeclareFloatFont" "{{")
708 ("DeclareFloatVCode" "{{")
709 ("DeclareColorBox" "{{")
710 ("DeclareCBoxCorners" "{{")
711 ("DeclareObjectSet" "{{")
712 ("DeclareMarginSet" "{{")
713 ("DeclareFloatSeparators" "{{")
714 ("DeclareFloatFootnoterule" "{{")
715 ("newseparatedlabel" "{{{")
716 ("newseparatedref" "{{")
717 ("makelabelseparator" "{")
718 ("DeclareNewFloatType" "{{")
723 (defvar LaTeX-floatrow-package-options nil
724 "Prompt for package options for the floatrow package.")
726 ;;; floatrow.el ends here