乳胶环境中组织模式的段落填充 [英] Paragraph filling for org-mode inside latex environment
问题描述
我开始使用组织模式撰写数学论文,因此大量使用了乳胶环境,例如证明
,定理
,引理
等。例如,我经常写
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}
问题是在组织模式下,填充段
(或 Mq
)在乳胶环境中不起作用。这使我的生活变得复杂,因为一些证明可能很长,编译为pdf时会达到几页,而且我无法以org-mode有效地格式化它们。我在手册中找不到有关控制段落填充的选项的任何信息。在这种情况下是否可以启用填充段
?
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:
#+BEGIN_proof
...
#+END_proof
这将导出为 \begin {proof } ... \end {proof}
。它还可以让您在块内使用org语法,并填充段落。
This gets exported as \begin{proof}...\end{proof}
. It also lets you use org syntax inside the block, and fill paragraph works.
如果您不想这样做,可以尝试 visual行模式
作为解决方法。
if you don't want to do that, maybe try visual-line-mode
as a workaround.
编辑:更改填充段落的行为
如果想让段落在乳胶环境中工作,则必须更深入地研究。填充是通过 org.el
中的 org-fill-paragraph
完成的,默认情况下,此功能会忽略乳胶环境。要更改此设置,请转到函数末尾并替换
If you want fill paragraph to work in latex environments, you have to dig a little deeper. Filling is done by org-fill-paragraph
in org.el
and this function ignores latex environments by default. To change this, go to the end of the function and replace
;; Ignore every other element.
(otherwise t)
with
(latex-environment nil) ;; use default fill-paragraph
;; Ignore every other element.
(otherwise t)
如果您不想更改组织来源,则可以请改用建议,例如
If you'd rather not change the org sources, you could use advice instead, e.g.
(defun org-fill-paragraph--latex-environment (&rest args)
"Use default fill-paragraph in latex environments."
(not (eql (org-element-type (org-element-context)) 'latex-environment)))
(advice-add 'org-fill-paragraph :before-while #'org-fill-paragraph--latex-environment)
这篇关于乳胶环境中组织模式的段落填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!