[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: change dollars to displaymath or equation*
From: |
Tassilo Horn |
Subject: |
Re: change dollars to displaymath or equation* |
Date: |
Mon, 10 Jan 2022 12:23:16 +0100 |
User-agent: |
mu4e 1.7.5; emacs 29.0.50 |
Tohiko Looka <toh.looka@gmail.com> writes:
Hi!
> If you use smart-paren, you can add the following so that \( \)
> is added every time you press $ (not following a backslash).
>
> (sp-with-modes '(latex-mode)
> (sp-local-pair "$" nil :actions :rem)
> (sp-local-pair "\\(" "\\)"
> :unless '(sp-point-before-same-p
> sp-latex-point-after-backslash)
> :trigger-wrap "$"
> :trigger "$"
> :actions '(wrap insert autoskip navigate)))
AUCTeX already has `TeX-electric-math', see (info "(auctex) Quotes").
--8<---------------cut here---------------start------------->8---
TeX and LaTeX users often look for a way to insert inline equations
like '$...$' or '\(...\)' simply typing '$'. AUCTeX helps them through
the customizable variable 'TeX-electric-math'.
-- 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 '\[...\]'.
--8<---------------cut here---------------end--------------->8---
Bye,
Tassilo