0

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?

4
  • You’re going to need to make your question more detailed, with a more concrete example.
    – db48x
    Commented Sep 15, 2023 at 7:53
  • @db48x You are right, I added an example and realized this might be a problem specific to AUCTeX. Commented Sep 15, 2023 at 8:00
  • I don’t see the problem you’re describing. Make sure fill-paragraph-function is set to LaTeX-fill-paragraph. If it is and still not working as intended, try invoking LaTeX-fill-paragraph directly (by the default it is bound to C-c C-q C-p).
    – d125q
    Commented Sep 15, 2023 at 9:59
  • @d125q As explained in my last edit, the problem is that M-q uses fill-region instead of LaTeX-fill-region, when a region is selected. Commented Sep 15, 2023 at 11:32

0

Your Answer

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