Hi Denis, 2017-06-13 12:51 GMT+02:00 Denis Bitouzé <dbito...@wanadoo.fr>: > Hi, > > does AUCTeX provide something making life easier for inline-math > expressions (`|' standing for the cursor position): > > - `\(|\)', > - `$|$' (OK, it's easy to type two dollar signs and go back to write the > expression between the dollar signs, but would be better if done by > a shortcut)?
Yes, of course ;-) You have to customize the `TeX-electric-math' option (https://www.gnu.org/software/auctex/manual/auctex.html#index-TeX_002delectric_002dmath): -- User Option: TeX-electric-math If the variable is non-nil and you type '$' outside math mode, AUCTeX will automatically insert the opening and closing symbols for an inline equation and put the point between them. The opening symbol will blink when 'blink-matching-paren' is non-nil. If 'TeX-electric-math' is nil, typing '$' simply inserts '$' at point, this is the default. Besides 'nil', possible values for this variable are '(cons "$" "$")' for TeX inline equations '$...$', and '(cons "\\(" "\\)")' for LaTeX inline equations '\(...\)'. If the variable is non-nil and point is inside math mode right between a couple of single dollars, pressing '$' will insert another pair of dollar signs and leave the point between them. Thus, if 'TeX-electric-math' is set to '(cons "$" "$")' you can easily obtain a TeX display equation '$$...$$' by pressing '$' twice in a row. (Note that you should not use double dollar signs in LaTeX because this practice can lead to wrong spacing in typeset documents.) In addition, when the variable is non-nil and there is an active region outside math mode, typing '$' will put around the active region symbols for opening and closing inline equation and keep the region active, leaving point after the closing symbol. By pressing repeatedly '$' while the region is active you can toggle between an inline equation, a display equation, and no equation. To be precise, '$...$' is replaced by '$$...$$', whereas '\(...\)' is replaced by '\[...\]'. If you want to automatically insert '$...$' in plain TeX files, and '\(...\)' in LaTeX files by pressing '$', add the following to your init file (add-hook 'plain-TeX-mode-hook (lambda () (set (make-variable-buffer-local 'TeX-electric-math) (cons "$" "$")))) (add-hook 'LaTeX-mode-hook (lambda () (set (make-variable-buffer-local 'TeX-electric-math) (cons "\\(" "\\)")))) > In the same vein, I know constructing display-math expressions with > `\[...\]': > > - has some drawbacks if `amsmath' is not loaded, I believe this is fixed if you have a recent LaTeX version (2015/01/01 or newer, which is in TeX Live 2016). > - is synonym to `\begin{equation*}...\end{equation*}' if `amsmath' is > loaded, > > but does AUCTeX provide something for `\[|\]'? If you set `LaTeX-electric-left-right-brace' (https://www.gnu.org/software/auctex/manual/auctex.html#index-LaTeX_002delectric_002dleft_002dright_002dbrace) to non nil, as you as you type "\[", the closing "\]" is inserted after point. Bye, Mosè _______________________________________________ auctex mailing list auctex@gnu.org https://lists.gnu.org/mailman/listinfo/auctex