I started using org-mode to write mathematical papers so I make a heavy use of latex environments such as proof
, theorem
, lemma
, etc. For example I often write
\begin{proof}
a very long proof follows
\end{proof}
The problem is that in org-mode the fill-paragraph
(or M-q
) doesn't work inside latex environments. This complicates my life because some proofs can be very long, reaching several pages when compiled to pdf, and I am unable to efficiently format them in org-mode. I couldn't find any information in the manual on options controlling paragraph filling. Is it possible to enable fill-paragraph
in this case?
The problem disappears if you use an org block instead of a latex environment:
This gets exported as
\begin{proof}...\end{proof}
. It also lets you use org syntax inside the block, and fill paragraph works.if you don't want to do that, maybe try
visual-line-mode
as a workaround.Edit: change fill-paragraph behaviour
If you want fill paragraph to work in latex environments, you have to dig a little deeper. Filling is done by
org-fill-paragraph
inorg.el
and this function ignores latex environments by default. To change this, go to the end of the function and replacewith
If you'd rather not change the org sources, you could use advice instead, e.g.