1 ;;; paracol.el --- AUCTeX style for `paracol.sty' (v1.32)
3 ;; Copyright (C) 2016 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 `paracol.sty' (v1.32) from 2015/10/10.
30 ;; `paracol.sty' is part of TeXLive.
32 ;; `paracol.sty' provides an environment (paracol) and a command
33 ;; (\switchcolumn) which take a star as the second (!) optional
34 ;; argument. In order to make the input process easier for the users,
35 ;; this style provides the environment `paracol*' and the command
36 ;; `switchcolumn*' in the list of completion after entering C-c C-e or
37 ;; C-c C-m (or C-c RET).
39 ;; Further, `\switchcolumn' takes a third optional argument containing
40 ;; text which will be inserted spanned over the columns. This style
41 ;; does not ask for this argument. If you need it, just enter it by
42 ;; hand after the completion. This is a deliberate decision since I
43 ;; think that over the time, the annoyance factor of hitting `RET'
44 ;; will be larger than the number of times where this argument is
49 (defun TeX-arg-paracol-switchcolumn* (optional)
50 "Query and insert the column argument of \\switchcolum macro.
51 If OPTIONAL is non-nil, insert the result in square brackets."
52 (let ((col (TeX-read-string
53 (TeX-argument-prompt optional nil "Column"))))
54 (when (and col (not (string= col "")))
57 (TeX-argument-insert col optional)))))
63 (LaTeX-add-environments
64 ;; 7.1 Environment paracol
65 ;; \begin{paracol}[numleft]{num}[text] body \end{paracol}
66 ;; \begin{paracol}[numleft]*{num}[text] body \end{paracol}
67 '("paracol" [ "Number left" ] "Number of columns" [ "Text across columns" ] )
70 (let ((numleft (TeX-read-string
71 (TeX-argument-prompt t nil "Number left")))
72 (numcol (TeX-read-string
73 (TeX-argument-prompt nil nil "Number of columns")))
75 (TeX-argument-prompt t nil "Text across columns"))))
76 (LaTeX-insert-environment
77 ;; Simply feed the function with "paracol", other option is
79 ;; (replace-regexp-in-string (regexp-quote "*") "" env)
82 (when (and numleft (not (string= numleft "")))
83 (format "[%s]" numleft))
85 (format "{%s}" numcol)
86 (when (and txt (not (string= txt "")))
87 (format "[%s]" txt)))))))
89 ;; 7.2 Column-Switching Command and Environments
90 ;; \begin{column} body \end{column}
91 ;; \begin{column*}[text] body \end{column*}
93 '("column*" [ "Text across columns" ] )
95 ;; \begin{nthcolumn}{col} body \end{nthcolumn}
96 ;; \begin{nthcolumn*}{col}[text] body \end{nthcolumn*}
97 '("nthcolumn" "Column")
98 '("nthcolumn*" "Column" [ "Text across columns" ] )
100 ;; \begin{leftcolumn} body \end{leftcolumn}
101 ;; \begin{leftcolumn*}[text] body \end{leftcolumn*}
102 ;; \begin{rightcolumn} body \end{rightcolumn}
103 ;; \begin{rightcolumn*}[text] body \end{rightcolumn*}
105 '("leftcolumn*" [ "Text across columns" ] )
107 '("rightcolumn*" [ "Text across columns" ] ))
110 ;; 7.2 Column-Switching Command and Environments
111 ;; \switchcolumn[col]
112 ;; \switchcolumn[col]*[text]
113 '("switchcolumn" [ "Column" ] )
114 '("switchcolumn*" [ TeX-arg-paracol-switchcolumn* ] )
116 '("ensurevspace" TeX-arg-length)
118 ;; 7.3 Commands for Column and Gap Width
119 ;; \columnratio{r0, r1, ... , rk}[r0', r1', ... , rk']
120 '("columnratio" "Fraction(s)" [ "Fraction(s)" ] )
122 ;; \setcolumnwidth{s0, s1, ... , sk}[s0', s1', ... , sk']
123 ;; with s as width/gap
124 '("setcolumnwidth" "Width/Gap" [ "Width/Gap" ] )
126 ;; 7.4 Commands for Two-Sided Typesetting and Marginal Note Placement
127 ;; \twosided[t1t2 ... tk]
128 '("twosided" [ "Features (combination of p, c, m, b)" ])
130 ;; \marginparthreshold{k}[k']
131 '("marginparthreshold" "Number of columns" [ "Number of columns" ] )
133 ;; 7.5 Commands for Counters
134 ;; \globalcounter{ctr}
136 '("globalcounter" TeX-arg-counter)
139 ;; \localcounter{ctr}
140 '("localcounter" TeX-arg-counter)
142 ;; \definethecounter{ctr}{col}{rep}
143 '("definethecounter" TeX-arg-counter "Column" t)
146 '("synccounter" TeX-arg-counter)
149 ;; 7.6 Page-Wise Footnotes
151 (TeX-arg-eval completing-read
152 (TeX-argument-prompt optional nil "Layout")
155 ;; \footnote*[num]{text}
156 ;; \footnotemark*[num]
157 ;; \footnotetext*[num]{text}
158 ;; Copied from `latex.el'
160 (TeX-arg-conditional TeX-arg-footnote-number-p ([ "Number" ]) nil)
163 (TeX-arg-conditional TeX-arg-footnote-number-p ([ "Number" ]) nil)
166 (TeX-arg-conditional TeX-arg-footnote-number-p ([ "Number" ]) nil))
168 '("fncounteradjustment" 0)
169 '("nofncounteradjustment" 0)
171 ;; 7.7 Commands for Coloring Texts and Column-Separating Rules
172 ;; \columncolor[mode]{color}[col]
174 ;; This clashes if colortbl.el is loaded since it provides a
175 ;; command with the same name but different arguments. We add
176 ;; the command only here but not for fontification
177 '("columncolor" (TeX-arg-conditional (member "xcolor" (TeX-style-list))
182 ;; \normalcolumncolor[col]
183 '("normalcolumncolor" [ "Column" ] )
184 '("coloredwordhyphenated" 0)
185 '("nocoloredwordhyphenated" 0)
187 ;; \colseprulecolor[mode]{color}[col]
188 ;; \normalcolseprulecolor[col]
189 '("colseprulecolor" (TeX-arg-conditional (member "xcolor" (TeX-style-list))
193 '("normalcolseprulecolor" [ "Column" ] )
195 ;; 7.8 Commands for Background Painting
196 ;; \backgroundcolor{region}[mode]{color}
197 ;; \backgroundcolor{region(x0,y0)}[mode]{color}
198 ;; \backgroundcolor{region(x0,y0)(x1,y1)}[mode]{color}
200 (TeX-arg-eval completing-read
201 (TeX-argument-prompt optional nil "Region")
202 '("c" "g" "s" "f" "n" "p" "t" "b" "l" "r"
203 "C" "G" "S" "F" "N" "P" "T" "B" "L" "R"))
204 (TeX-arg-conditional (member "xcolor" (TeX-style-list))
208 ;; \nobackgroundcolor{region}
209 '("nobackgroundcolor"
210 (TeX-arg-eval completing-read
211 (TeX-argument-prompt optional nil "Region")
212 '("c" "g" "s" "f" "n" "p" "t" "b" "l" "r"
213 "C" "G" "S" "F" "N" "P" "T" "B" "L" "R")))
215 ;; \resetbackgroundcolor
216 '("resetbackgroundcolor" 0)
218 ;; 7.9 Control of Contents Output
219 ;; \addcontentsonly{file}{col}
221 (TeX-arg-eval completing-read
222 (TeX-argument-prompt optional nil "Content file")
223 '("toc" "lof" "lot"))
228 ; \switchcolumn should get its own line:
229 (LaTeX-paragraph-commands-add-locally "switchcolumn")
232 (when (and (featurep 'font-latex)
233 (eq TeX-install-font-lock 'font-latex-setup))
234 ;; FIXME: Syntax is \switchcolumn[num]*[text].
235 ;; font-latex.el doesn't handle the case
236 ;; where `*' comes after the first `['.
237 ;; Therefore, we use this compromise to
238 ;; get something fontified at least.
239 (font-latex-add-keywords '(("switchcolumn" "*["))
241 (font-latex-add-keywords '(("flushpage" "*["))
243 (font-latex-add-keywords '(("footnote" "*[{")
244 ("footnotemark" "*[")
245 ("footnotetext" "*[{"))
247 (font-latex-add-keywords '(("ensurevspace" "{")
249 ("setcolumnwidth" "{[")
251 ("marginparthreshold" "{[")
253 ;; \globalcounter{ctr} or
254 ;; \globalcounter* We ignore `{' since
255 ;; font-latex.el doesn't handle a
256 ;; missing bracket nicely.
257 ("globalcounter" "*")
258 ("definethecounter" "{{{")
260 ("syncallcounters" "")
261 ("footnotelayout" "{")
262 ("fncounteradjustment" "")
263 ("nofncounteradjustment" "")
264 ("normalcolumncolor" "[")
265 ("coloredwordhyphenated" "")
266 ("nocoloredwordhyphenated" "")
267 ("colseprulecolor" "[{[")
268 ("normalcolseprulecolor" "[")
269 ("backgroundcolor" "{[{")
270 ("nobackgroundcolor" "{")
271 ("resetbackgroundcolor" "")
272 ("addcontentsonly" "{{"))
276 (defvar LaTeX-paracol-package-options nil
277 "Package options for the paracol package.")
279 ;;; paracol.el ends here