Markdown 中的 Vim 语法和 Latex 数学

问题描述 投票:0回答:2

我使用 ViM 在 Markdown 中编写文档,并且还使用 Latex

$$
符号进行数学运算(我使用 pandoc 进行编译)。问题是 ViM 语法不会忽略美元符号内的下划线
_
,这非常烦人。例如,如果我写这个:

$$ a_1 = 0 $$

然后,由于使用了下划线,Vim 会将以下所有文本突出显示为斜体。

我该如何改变它?

如果我能用不同的格式突出显示里面的内容

$
,那就太好了。

vim latex markdown pandoc vim-syntax-highlighting
2个回答
18
投票

我已将这些行放入我的 .vimrc 中。它适用于同一行上的内联数学和块模式数学。

" This gets rid of the nasty _ italic bug in tpope's vim-markdown
" block $$...$$
syn region math start=/\$\$/ end=/\$\$/
" inline math
syn match math '\$[^$].\{-}\$'

" actually highlight the region we defined as "math"
hi link math Statement

编辑:此后我写了一篇名为 Vim 语法高亮显示 Markdown、Liquid 和 MathJax 的博客文章。


0
投票

只需安装https://github.com/sheerun/vim-polyglot

md文件中的latex会显示如下:

© www.soinside.com 2019 - 2024. All rights reserved.