当前位置:   article > 正文

obsidian最强数学公式插件:latex suite文档翻译

latex suite

对于日常使用markdown做笔记涉及数学公式来说,latex suite这个插件不要太方便。只要输入几个关键字(触发器)就能出来完整的latex公式。下面把官方文档和默认的触发器功能翻译一下。

原文地址:
https://github.com/artisticat1/obsidian-latex-suite/blob/1.4.5/DOCS.md

Snippets 代码片段

Snippets are formatted as follows: 代码片段格式如下:


{trigger: string, replacement: string, options: string, description?: string, priority?: number}

  • 1
  • 2
  • 3
  • trigger : The text that triggers this snippet.
  • 触发器:触发代码的文字
  • replacement : The text to replace the trigger with.
  • 替换内容:替换触发器的文本
  • options : See below.
  • 选项:看下面的解释
  • priority (optional): This snippet’s priority. Snippets with higher priority are run first. Can be negative. Defaults to 0.
  • 优先级:可选。代码片段优先级。高优先级的代码片段先运行。可以是负数,默认是0.
  • description (optional): A description for this snippet.
  • 描述:可选。代码片段的注释。

Options选项

  • m : Math mode. Only run this snippet inside math
  • m:数学模式,这个片段只在数学公式内有效。($$代码段)
  • t : Text mode. Only run this snippet outside math
  • t:文本模式。这个片段只在数学公式外有效。
  • A : Auto. Expand this snippet as soon as the trigger is typed. If omitted, the Tab key must be pressed to expand the snippet
  • A:自动。一旦输入触发器文字,就自动替换为代码段。如果没有此参数,必须要按下Tab键才会触发替换。
  • r : Regex. The trigger will be treated as a regular expression
  • r:正则表达式。触发器会被当做公式表达式。
  • w : Word boundary. Only run this snippet when the trigger is preceded by (and followed by) a word delimiter, such as ., ,, or -.
  • w:符号边界。这个代码段只有被指定的字符如,,.,-前后包围时才有效。
    Multiple options can be used at once.多个选项可以同时使用。如rm,ma。

Tabstops定位点

  • Insert tabstops for the cursor to jump to using $X, where X is a number starting from 0.
    使用$X作为定位点,其中X从0开始。
  • Pressing Tab will move the cursor to the next tabstop.
    按下Tab键指针将会移动到下一个定位点
  • Tabstops can have placeholders. Use the format ${X:text}, where text is the text that will be selected by the cursor on moving to this tabstop.
    定位点可以有占位符,格式是${X:text}。指针移动到当前定位点时会选中text内容。
  • Tabstops with the same number, X, will all be selected at the same time.
    如果多个定位点有相同的编号X,那么将会同时被选中。

Examples


{trigger: "//", replacement: "\\frac{$0}{$1}$2", options: "mA"}
输入'//' ,替换为除法公式。
{trigger: "dint", replacement: "\\int_{${0:0}}^{${1:\\infty}} $2 d${3:x}", options: "mA"}

{trigger: "outp", replacement: "\\ket{${0:\\psi}} \\bra{${0:\\psi}} $1", options: "mA"}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

Regex公式

  • Use the r option to create a regex snippet.
    使用r选项创建公式代码段
  • In the trigger, surround an expression with brackets () to create a capturing group.
    在触发器中,使用括号包住表达式创建一个输入组。
  • Inside the replacement string, strings of the form [[X]] will be replaced by matches in increasing order of X, starting from 0.
    replacement字符串中,格式为[[X]]的字符串将会被触发器输入组中对应顺序的字符替代。

Warnings警告

  • Some characters, such as \, +, and ., are special characters in regex. If you want to use these literally, remember to escape them by inserting two backslashes (\\) before them!
    某些字符如 \, +, and .,在公式中是特殊字符。如果要使用这些字符,需要在前面加上转义符\\

Example例子

The snippet代码段


{trigger: "([A-Za-z])(\\d)", replacement: "[[0]]_{[[1]]}", options: "rA"}

  • 1
  • 2
  • 3

详细解释:
触发器中,第一个括号内表明可以输入任何字母,第二个括号表明输入数字。
替换内容表示用第一个字母加_加第二个数字作为替换文本。
这个触发器表示将形如x2的输入变为x_{2},也就是 x 2 x_{2} x2

Variables变量

The following variables are available for use in a trigger or replacement:
在触发器和替换内容中可以使用以下变量

  • ${VISUAL} : Can be inserted in a replacement. When the snippet is expanded, " V I S U A L " i s r e p l a c e d w i t h t h e c u r r e n t s e l e c t i o n . ‘ {VISUAL}" is replaced with the current selection. ` VISUAL"isreplacedwiththecurrentselection.‘{VISUAL} :可以插入替换内容,当代码段展开时,${VISUAL}` 被替换为当前选择内容。
  • Visual snippets will not expand unless text is selected.

一些有用的代码段定义

title:进入数学模式

{trigger: "mk", replacement:"$$0$", options: "tA"}

文本模式下输入"mk"进入单行数学模式

{trigger: "dm", replacement: "\$\$\n$0\n\$\$", options: "tAw"},

文本模式下输入"dm"进入多行数学模式

{trigger: "beg", replacement: "\\begin{$0}\n$1\n\\end{$0}", options: "mA"}

文本模式下输入"beg"进入多行数学模式并加入begin和end块
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
title:罗马字符
    {trigger: "@a", replacement: "\\alpha", options: "mA"},
    {trigger: "@A", replacement: "\\alpha", options: "mA"},
    {trigger: "@b", replacement: "\\beta", options: "mA"},
    {trigger: "@B", replacement: "\\beta", options: "mA"},
    {trigger: "@c", replacement: "\\chi", options: "mA"},
    {trigger: "@C", replacement: "\\chi", options: "mA"},
    {trigger: "@g", replacement: "\\gamma", options: "mA"},
    {trigger: "@G", replacement: "\\Gamma", options: "mA"},
    {trigger: "@d", replacement: "\\delta", options: "mA"},
    {trigger: "@D", replacement: "\\Delta", options: "mA"},
    {trigger: "@e", replacement: "\\epsilon", options: "mA"},
    {trigger: "@E", replacement: "\\epsilon", options: "mA"},
    下略
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
title:罗马字符后面加其他字符
    {trigger: "\\\\(${GREEK}|${SYMBOL})([A-Za-z])", replacement: "\\[[0]] [[1]]", options: "rmA"},
    默认情况下罗马字符后面不加空格就加其他字符会出错,以上代码段自动在罗马字符后加空格。
    {trigger: "\\\\(${GREEK}|${SYMBOL}) sr", replacement: "\\[[0]]^{2}", options: "rmA"},
    罗马字符的平方
    {trigger: "\\\\(${GREEK}|${SYMBOL}) cb", replacement: "\\[[0]]^{3}", options: "rmA"},
    罗马字符的立方
    {trigger: "\\\\(${GREEK}|${SYMBOL}) rd", replacement: "\\[[0]]^{$0}$1", options: "rmA"},
    罗马字符后自动加上n次方括号并把光标移动到括号内
    {trigger: "\\\\(${GREEK}|${SYMBOL}) hat", replacement: "\\hat{\\[[0]]}", options: "rmA"},
    罗马字符上面加戴帽符号
    {trigger: "\\\\(${GREEK}|${SYMBOL}) dot", replacement: "\\dot{\\[[0]]}", options: "rmA"},
    罗马字符上面加点符号
    {trigger: "\\\\(${GREEK}|${SYMBOL}) bar", replacement: "\\bar{\\[[0]]}", options: "rmA"},
    罗马字符上面加平均符号
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
title:操作符
    {trigger: "te", replacement: "\\text{$0}", options: "m"},
    加入文本
    {trigger: "sr", replacement: "^{2}", options: "mA"},
    平方符号
    {trigger: "cb", replacement: "^{3}", options: "mA"},
    立方符号
    {trigger: "rd", replacement: "^{$0}$1", options: "mA"},
    n次方(上标)
    {trigger: "_", replacement: "_{$0}$1", options: "mA"},
    下标
    {trigger: "sts", replacement: "_\\text{$0}", options: "rmA"},
    另一个下标
    {trigger: "sq", replacement: "\\sqrt{ $0 }$1", options: "mA"},
    开方
    {trigger: "//", replacement: "\\frac{$0}{$1}$2", options: "mA"},
    除法
    {trigger: "ee", replacement: "e^{ $0 }$1", options: "mA"},
    指数函数
    {trigger: "([A-Za-z])(\\d)", replacement: "[[0]]_{[[1]]}", options: "rmA", description: "Auto letter subscript", priority: -1},
    自动加下标
    {trigger: "\\\\mathbf{([A-Za-z])}(\\d)", replacement: "\\mathbf{[[0]]}_{[[1]]}", options: "rmA"},
    {trigger: "([A-Za-z])_(\\d\\d)", replacement: "[[0]]_{[[1]]}", options: "rmA"},
    {trigger: "conj", replacement: "^{*}", options: "mA"},
    {trigger: "bar", replacement: "\\bar{$0}", options: "mA"},
    {trigger: "hat", replacement: "\\hat{$0}", options: "mA"},
    {trigger: "dot", replacement: "\\dot{$0}", options: "mA"},
    {trigger: "([^\\\\])(arcsin|arccos|arctan|arccot|arccsc|arcsec|sin|cos|tan|cot|csc)", replacement: "[[0]]\\[[1]]", options: "rmA"},
    {trigger: "\\\\(arcsin|arccos|arctan|arccot|arccsc|arcsec|sin|cos|tan|cot|csc)([A-Za-gi-z])", replacement: "\\[[0]] [[1]]", options: "rmA"}, // Insert space after trig funcs. Skips letter "h" to allow sinh, cosh, etc.
    三角函数后面自动加空格
    {trigger: "\\\\(arcsinh|arccosh|arctanh|arccoth|arcsch|arcsech|sinh|cosh|tanh|coth|csch)([A-Za-z])", replacement: "\\[[0]] [[1]]", options: "rmA"}, // Insert space after trig funcs
    同上
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
title:视觉效果。注意要选中一个字符串然后输入触发器命令。
    {trigger: "U", replacement: "\\underbrace{ ${VISUAL} }_{ $0 }", options: "mA"},
    下大括号
    {trigger: "B", replacement: "\\underset{ $0 }{ ${VISUAL} }", options: "mA"},
    上下结构
    {trigger: "C", replacement: "\\cancel{ ${VISUAL} }", options: "mA"},
    斜线
    {trigger: "K", replacement: "\\cancelto{ $0 }{ ${VISUAL} }", options: "mA"},
    斜线带指数
    {trigger: "S", replacement: "\\sqrt{ ${VISUAL} }", options: "mA"},
    开方
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
title:数学符号
    {trigger: "ooo", replacement: "\\infty", options: "mA"},
    {trigger: "sum", replacement: "\\sum", options: "mA"},
    {trigger: "prod", replacement: "\\prod", options: "mA"},
    {trigger: "lim", replacement: "\\lim_{ ${0:n} \\to ${1:\\infty} } $2", options: "mA"},
    {trigger: "pm", replacement: "\\pm", options: "m"},
    {trigger: "...", replacement: "\\dots", options: "mA"},
    {trigger: "<->", replacement: "\\leftrightarrow ", options: "mA"},
    {trigger: "->", replacement: "\\to", options: "mA"},
    {trigger: "!>", replacement: "\\mapsto", options: "mA"},
    {trigger: "invs", replacement: "^{-1}", options: "mA"},
    {trigger: "\\\\\\", replacement: "\\setminus", options: "mA"},
    {trigger: "||", replacement: "\\mid", options: "mA"},
    {trigger: "and", replacement: "\\cap", options: "mA"},
    {trigger: "orr", replacement: "\\cup", options: "mA"},
    {trigger: "inn", replacement: "\\in", options: "mA"},
    {trigger: "\\subset eq", replacement: "\\subseteq", options: "mA"},
    {trigger: "set", replacement: "\\{ $0 \\}$1", options: "mA"},
    {trigger: "=>", replacement: "\\implies", options: "mA"},
    {trigger: "=<", replacement: "\\impliedby", options: "mA"},
    {trigger: "iff", replacement: "\\iff", options: "mA"},
    {trigger: "e\\xi sts", replacement: "\\exists", options: "mA", priority: 1},
    {trigger: "===", replacement: "\\equiv", options: "mA"},
    {trigger: "Sq", replacement: "\\square", options: "mA"},
    {trigger: "!=", replacement: "\\neq", options: "mA"},
    {trigger: ">=", replacement: "\\geq", options: "mA"},
    {trigger: "<=", replacement: "\\leq", options: "mA"},
    {trigger: ">>", replacement: "\\gg", options: "mA"},
    {trigger: "<<", replacement: "\\ll", options: "mA"},
    {trigger: "~~", replacement: "\\sim", options: "mA"},
    {trigger: "\\sim ~", replacement: "\\approx", options: "mA"},
    {trigger: "prop", replacement: "\\propto", options: "mA"},
    {trigger: "nabl", replacement: "\\nabla", options: "mA"},
    {trigger: "del", replacement: "\\nabla", options: "mA"},
    {trigger: "xx", replacement: "\\times", options: "mA"},
    {trigger: "**", replacement: "\\cdot", options: "mA"},
    {trigger: "pal", replacement: "\\parallel", options: "mA"},


    {trigger: "xnn", replacement: "x_{n}", options: "mA"},
    {trigger: "xii", replacement: "x_{i}", options: "mA"},
    {trigger: "xjj", replacement: "x_{j}", options: "mA"},
    {trigger: "xp1", replacement: "x_{n+1}", options: "mA"},
    {trigger: "ynn", replacement: "y_{n}", options: "mA"},
    {trigger: "yii", replacement: "y_{i}", options: "mA"},
    {trigger: "yjj", replacement: "y_{j}", options: "mA"},


    {trigger: "mcal", replacement: "\\mathcal{$0}$1", options: "mA"},
    {trigger: "ell", replacement: "\\ell", options: "mA"},
    {trigger: "lll", replacement: "\\ell", options: "mA"},
    {trigger: "LL", replacement: "\\mathcal{L}", options: "mA"},
    {trigger: "HH", replacement: "\\mathcal{H}", options: "mA"},
    {trigger: "CC", replacement: "\\mathbb{C}", options: "mA"},
    {trigger: "RR", replacement: "\\mathbb{R}", options: "mA"},
    {trigger: "ZZ", replacement: "\\mathbb{Z}", options: "mA"},
    {trigger: "NN", replacement: "\\mathbb{N}", options: "mA"},
    {trigger: "II", replacement: "\\mathbb{1}", options: "mA"},
    {trigger: "\\mathbb{1}I", replacement: "\\hat{\\mathbb{1}}", options: "mA"},
    {trigger: "AA", replacement: "\\mathcal{A}", options: "mA"},
    {trigger: "BB", replacement: "\\mathbf{B}", options: "mA"},
    {trigger: "EE", replacement: "\\mathbf{E}", options: "mA"},

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
title:导数
    // Derivatives
    {trigger: "par", replacement: "\\frac{ \\partial ${0:y} }{ \\partial ${1:x} } $2", options: "m"},
    导数,注意要用tab展开
    {trigger: "pa2", replacement: "\\frac{ \\partial^{2} ${0:y} }{ \\partial ${1:x}^{2} } $2", options: "mA"},
    二阶导数
    {trigger: "pa3", replacement: "\\frac{ \\partial^{3} ${0:y} }{ \\partial ${1:x}^{3} } $2", options: "mA"},
    三阶导数
    {trigger: "pa([A-Za-z])([A-Za-z])", replacement: "\\frac{ \\partial [[0]] }{ \\partial [[1]] } ", options: "rm"},
    导数指定函数名
    {trigger: "pa([A-Za-z])([A-Za-z])([A-Za-z])", replacement: "\\frac{ \\partial^{2} [[0]] }{ \\partial [[1]] \\partial [[2]] } ", options: "rm"},
    多函数导数
    {trigger: "pa([A-Za-z])([A-Za-z])2", replacement: "\\frac{ \\partial^{2} [[0]] }{ \\partial [[1]]^{2} } ", options: "rmA"},
    二阶导数
    {trigger: "de([A-Za-z])([A-Za-z])", replacement: "\\frac{ d[[0]] }{ d[[1]] } ", options: "rm"},
    导数除法表示dy/dx
    {trigger: "de([A-Za-z])([A-Za-z])2", replacement: "\\frac{ d^{2}[[0]] }{ d[[1]]^{2} } ", options: "rmA"},
    {trigger: "ddt", replacement: "\\frac{d}{dt} ", options: 
    导数除法表示d/dt
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
title:积分
    {trigger: "oinf", replacement: "\\int_{0}^{\\infty} $0 \\, d${1:x} $2", options: "mA"},
    0到正无穷积分
    {trigger: "infi", replacement: "\\int_{-\\infty}^{\\infty} $0 \\, d${1:x} $2", options: "mA"},
    正负无穷积分
    {trigger: "dint", replacement: "\\int_{${0:0}}^{${1:\\infty}} $2 \\, d${3:x} $4", options: "mA"},
	指定下限积分
    {trigger: "oint", replacement: "\\oint", options: "mA"},
    {trigger: "iiint", replacement: "\\iiint", options: "mA"},
    {trigger: "iint", replacement: "\\iint", options: "mA"},
    {trigger: "int", replacement: "\\int $0 \\, d${1:x} $2", options: "mA"},
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
title:环境(矩阵、排列等)
    // Environments
    {trigger: "pmat", replacement: "\\begin{pmatrix}\n$0\n\\end{pmatrix}", options: "mA"},
    {trigger: "bmat", replacement: "\\begin{bmatrix}\n$0\n\\end{bmatrix}", options: "mA"},
    {trigger: "Bmat", replacement: "\\begin{Bmatrix}\n$0\n\\end{Bmatrix}", options: "mA"},
    {trigger: "vmat", replacement: "\\begin{vmatrix}\n$0\n\\end{vmatrix}", options: "mA"},
    {trigger: "Vmat", replacement: "\\begin{Vmatrix}\n$0\n\\end{Vmatrix}", options: "mA"},
    {trigger: "case", replacement: "\\begin{cases}\n$0\n\\end{cases}", options: "mA"},
    {trigger: "align", replacement: "\\begin{align}\n$0\n\\end{align}", options: "mA"},
    {trigger: "array", replacement: "\\begin{array}\n$0\n\\end{array}", options: "mA"},
    {trigger: "matrix", replacement: "\\begin{matrix}\n$0\n\\end{matrix}", options: "mA"},
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
title:括号
    {trigger: "lr(", replacement: "\\left( $0 \\right) $1", options: "mA"},
    {trigger: "lr|", replacement: "\\left| $0 \\right| $1", options: "mA"},
    {trigger: "lr{", replacement: "\\left\\{ $0 \\right\\} $1", options: "mA"},
    {trigger: "lr[", replacement: "\\left[ $0 \\right] $1", options: "mA"},
    {trigger: "lra", replacement: "\\left< $0 \\right> $1", options: "mA"},
    {trigger: "avg", replacement: "\\langle $0 \\rangle $1", options: "mA"},
    {trigger: "(", replacement: "(${VISUAL})", options: "mA"},
    {trigger: "[", replacement: "[${VISUAL}]", options: "mA"},
    {trigger: "{", replacement: "{${VISUAL}}", options: "mA"},
    {trigger: "(", replacement: "($0)$1", options: "mA"},
    {trigger: "{", replacement: "{$0}$1", options: "mA"},
    {trigger: "[", replacement: "[$0]$1", options: "mA"},
    {trigger: "mod", replacement: "|$0|$1", options: "mA"},
    {trigger: "norm", replacement: "\\|$0\\|$1", options: "mA", priority: 1},
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/297503
推荐阅读
  

闽ICP备14008679号