4

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

2 Answers 2

4

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 \).
3
  • Thank you, that worked just as you said. For others who may find this useful: the variable belongs to the LaTeX group.
    – G Philip
    Apr 29, 2015 at 14:24
  • I still think this is a bug somehow. At least the documentation of the variable is not accurate. It says that the line break will be inserted if the block does not fit on the line. Instead the line break is inserted unconditionally.
    – Thomas
    Nov 7, 2015 at 12:12
  • @Thomas Agreed the documentation is buggy on this. Nov 7, 2015 at 12:21
0

I will also note that Aquamacs is broken: it overwrites the default fill-paragraph (which takes no arguments in GNU Emacs) with a function from fill-adapt, which takes one argument.

This breaks all packages that use fill-paragraph, essentially.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.