Using fill-paragraph
in AUCTeX normally respects the given indentation. However, if I use fill-paragraph
on a selection, only the first line will be indented, the other lines won't. Is there a way to correct this?
Example. I have the following LaTeX code
\begin{proposition}
For every right-angled triangle with side \(a,b\) and \(c\), where \(c\) is the hypotenuse, we have \(a^2 + b^2 = c^2\).
\end{proposition}
If my cursor is on the middle line, and I press M-q
(which executes fill-paragraph
), then I obtain
\begin{proposition}
For every right-angled triangle with side \(a,b\) and \(c\), where
\(c\) is the hypotenuse, we have \(a^2 + b^2 = c^2\).
\end{proposition}
which has the correct indentation. However, if I select the middle line and press M-q
, I get
\begin{proposition}
For every right-angled triangle with side \(a,b\) and \(c\), where
\(c\) is the hypotenuse, we have \(a^2 + b^2 = c^2\).
\end{proposition}
As you see, the indentation of the second line is incorrect.
I did some more research and experimentation. According to the AUCTeX documentation on Indenting, there is a special LaTeX-fill-region
, which does not seem to suffer from my problem. However, when I have selected text, M-q
uses fill-region
instead of LaTeX-fill-region
. How can I change this?
fill-paragraph-function
is set toLaTeX-fill-paragraph
. If it is and still not working as intended, try invokingLaTeX-fill-paragraph
directly (by the default it is bound to C-c C-q C-p).M-q
usesfill-region
instead ofLaTeX-fill-region
, when a region is selected.