Emacs: Auto-Fill-Mode Alt-q function breaks lines in maths separator in LaTeX after Aquamacs update
After I updated Aquamacs, using Alt-q
(in a small auto-mode) to fill the paragraphs, when editing LaTeX document leads to the fact that each line is divided at the first appearance of the separator closing LaTeX, \)
. (Well, almost! See example below for one exception.)
Version Information: Aquamacs 3.2 GNU Emacs 24.4.51.2
.
Question
How can I tell Aquamacs / Emacs / Auto-Fill mode not to break lines at the first \)
one it sees on the line, but to actually fill the paragraph as it was used to do before the update?
Steps to reproduce this behavior
-
Help -> Diagnose and report bug -> Start Aquamacs without customizations
to get the "untouched" Aquamacs window. - Open the file named
testemacs.tex
and paste the Lorem Ipsum text twice to make two paragraphs. - Add small math expressions, delimited by LaTeX
\(
and delimiters\)
, at random places in the second paragraph. Leave the first paragraph as it is. - Enter
Alt-x auto-fill-mode
to enable autocomplete mode. - Go to each paragraph and type
Alt-q
to call the functionfill-paragraph
. - Observe the difference! See screenshot below:
As you can see, everywhere but the very last line, fill-paragraph
splits the line at the first closing delimiter \)
it sees. This makes the paragraph very ugly and damages the whole purpose of filling the paragraphs. How can I get rid of this behavior?
Modes
See screenshot below for operation modes:
source to share
This is a recent change to AUCTeX. You can customize the variable LaTeX-fill-break-at-separators
. By default it is
(\\\( \\\) \\\[ \\\])
which according to the documentation means that the lines will be split before or after these delimiters, unless the entire expression is placed on the line when filled. However, the behavior is not quite the same and as you can see it breaks the line unconditionally after the closing delimiters \)
and \]
. Removing the built-in math switches to \(
and \)
from this list restores the older behavior. I also found just removing \)
from this list to give acceptable results, see example 2 below. In the setting interface, just uncheck the "Close the built-in math switches"
Here is a concrete demo of the various settings.
-
default
LaTeX-fill-break-at-separators
equivalent(custom-set-variables '(LaTeX-fill-break-at-separators (quote (\\\( \\\) \\\[ \\\]))))
gives the following, with a line break after each \)
:
Let \( \gamma\colon \BbbR \times [0,T) \to \BbbR^2 \)
be a family of regular curves solving~\eqref{eq:c-flow}, with each
curve \( \gamma^t \)
of period~\( \Psi \)
and with \( \gamma^0 \)
strictly convex. Let \( \kappa_0(t) \)
be the minimum value of \( \kappa \)
on \( \gamma^t \).
Note that \( \kappa_0(t) \)
is achieved at some point \( (\psi,t) \),
so in particular \( \kappa_0(0) > 0 \).
-
No built-in math closure
(custom-set-variables '(LaTeX-fill-break-at-separators (quote (\\\( \\\[ \\\]))))
keeps math groups in line, but allows text after them:
Let \( \gamma\colon \BbbR \times [0,T) \to \BbbR^2 \) be a family of
regular curves solving~\eqref{eq:c-flow}, with each curve
\( \gamma^t \) of period~\( \Psi \) and with \( \gamma^0 \) strictly
convex. Let \( \kappa_0(t) \) be the minimum value of \( \kappa \) on
\( \gamma^t \). Note that \( \kappa_0(t) \) is achieved at some point
\( (\psi,t) \), so in particular \( \kappa_0(0) > 0 \).
-
Without any built-in math separator
(custom-set-variables '(LaTeX-fill-break-at-separators (quote (\\\[ \\\]))))
math groups can be divided along lines:
Let \( \gamma\colon \BbbR \times [0,T) \to \BbbR^2 \) be a family of
regular curves solving~\eqref{eq:c-flow}, with each curve \( \gamma^t
\) of period~\( \Psi \) and with \( \gamma^0 \) strictly convex. Let
\( \kappa_0(t) \) be the minimum value of \( \kappa \) on \( \gamma^t
\). Note that \( \kappa_0(t) \) is achieved at some point \( (\psi,t)
\), so in particular \( \kappa_0(0) > 0 \).
source to share