【问题标题】:Latex Sublime snippet乳胶崇高片段
【发布时间】:2017-03-21 17:50:50
【问题描述】:

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

如果我删除 sn-p 中的一些行,它可以工作,但我需要整个块:/

<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 代码可以正常工作,不会出现任何错误或警告。

【问题讨论】:

    标签: sublimetext3 sublimetext-snippet


    【解决方案1】:

    $ 字符在 Sublime Text sn-ps 中具有特殊含义,因此需要转义才有效。

    您可以使用前面的反斜杠将它们转义,如 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 很遗憾没有提供任何反馈,正如您所见:

    转义后的样子:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-19
      • 2015-11-20
      • 1970-01-01
      • 1970-01-01
      • 2014-01-18
      相关资源
      最近更新 更多