Latex Sublime片段

时间:2016-11-08 07:27:29

标签: sublimetext3 sublimetext-snippet

我正在使用Sublime代码段来创建Latex状态机模板。但是,它什么都不做(当我键入“stmach”并按Tab键时,stmach消失,但不包括Latex代码)。我不明白为什么,因为我所有的其他片段都工作正常。

如果我删除片段中的某些行,它可以正常工作,但我需要整个块:/

<snippet>
<content><![CDATA[
    \begin{center}
        \begin{tikzpicture}[shorten >=1pt,node distance=4.5cm,on grid,auto]

        \tikzstyle{every state}=[draw=blue!50,very thick,fill=blue!20] % Node color

        \node[state,initial,initial text=reset, initial where=below] (configuration) {$conf$}; % Node name and position
        \node[state] (init) [below right=of configuration] {$init$};

        \path[->] % Arrow
        (configuration)
            edge  [bend left]                 node {finishConfiguration=1} (init)

        (init)
            edge  [bend left]                 node {} (configuration);

        \end{tikzpicture}
    \end{center}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>stmach</tabTrigger> 
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.tex</scope>

请注意,Latex代码无任何错误或警告。

1 个答案:

答案 0 :(得分:2)

$字符在Sublime Text代码段中具有特殊含义,因此需要转义为有效。

您可以使用前面的反斜杠转义它们,如documentation shows

<snippet>
<content><![CDATA[
    \begin{center}
        \begin{tikzpicture}[shorten >=1pt,node distance=4.5cm,on grid,auto]

        \tikzstyle{every state}=[draw=blue!50,very thick,fill=blue!20] % Node color

        \node[state,initial,initial text=reset, initial where=below] (configuration) {\$conf\$}; % Node name and position
        \node[state] (init) [below right=of configuration] {\$init\$};

        \path[->] % Arrow
        (configuration)
            edge  [bend left]                 node {finishConfiguration=1} (init)

        (init)
            edge  [bend left]                 node {} (configuration);

        \end{tikzpicture}
    \end{center}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>stmach</tabTrigger> 
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.tex</scope>
</snippet>

使用https://github.com/sublimehq/Packages/pull/576中的语法突出显示使问题更加清晰,因为ST很遗憾没有提供任何反馈,如您所见: invalid snippet

转义时的外观如何: valid snippet

相关问题