emacsemacs24aquamacs

Emacs: After Aquamacs update, Auto-Fill-Mode's Alt-q breaks lines at maths delimiter in LaTeX


After I updated Aquamacs, using Alt-q (in the Auto-Fill minor mode) to fill paragraphs when editing a LaTeX document results in each line being broken at the first occurrence of the LaTeX maths closing delimiter, \). (Well, almost! See the example below for the one exception.)

Version information: Aquamacs 3.2 GNU Emacs 24.4.51.2.

Question

How do I tell Aquamacs/Emacs/Auto-Fill mode not to break lines at the first \) that it sees on a line, but to actually fill in the paragraph as it used to do before the update?

Steps to reproduce this behaviour

  1. Help -> Diagnose and report bug -> Start Aquamacs without customizations to get a "pristine" Aquamacs window.
  2. Open a file named testemacs.tex and paste the Lorem Ipsum text, twice to make two paragraphs.
  3. Add small maths expressions delimited by the LaTeX delimiters \( and \), at random places in the second paragraph. Leave the first paragraph as it is.
  4. Type Alt-x auto-fill-mode to enable Auto-Fill mode.
  5. Go to each paragraph and type Alt-q to invoke the fill-paragraph function.
  6. Observe the difference! See the screenshot below:

Image showing line breaks at maths delimiters

As you can see, everywhere except on the very last line, fill-paragraph breaks the line at the first closing delimiter \) that it sees. This makes the paragraph look really ugly, and defeats the whole purpose of filling-in paragraphs. How can I get rid of this behaviour?

Modes

Please see the screenshot below for the modes in operation:

Modes information


Solution

  • This is a recent change in AUCTeX. You can customize the variable LaTeX-fill-break-at-separators. By default it is

     (\\\( \\\) \\\[ \\\])
    

    which according to the documentation means that lines will be broken before or after these separators if the whole expression does not fit on the line when filling. However, the behaviour is not quite that and as you see it will unconditionally break the line after the closing delimiters \) and \]. Removing the inline math switches \( and \) from this list restores the older behaviour. I also find just removing \) from this list to give acceptable results, see example 2 below. In the customization interface just uncheck "Closing Inline Math Switches"

    Here is a concrete demonstration of different settings.

    1. default value of LaTeX-fill-break-at-separators, equivalent to

      (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 \).
    
    1. Without inline math closing

      (custom-set-variables
       '(LaTeX-fill-break-at-separators (quote (\\\( \\\[ \\\]))))
      

    keeps math groups on a 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 \).
    
    1. Without any inline math delimiter

      (custom-set-variables
       '(LaTeX-fill-break-at-separators (quote (\\\[ \\\]))))
      

    math groups may be split over 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 \).