2016-11-08 70 views
1

我使用Sublime片段來創建一個Latex狀態機模板。然而,它什麼都不做(當我輸入「stmach」並按下標籤時,stmach消失,但不包括乳膠代碼)。我不明白爲什麼,因爲我所有的其他代碼片段工作正常。Latex Sublime snippet

如果我刪除一些線路中的片段,它的工作原理,但我需要整個塊:/

<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> 

注意,乳膠代碼工作沒有任何錯誤或警告。

回答

2

$字符在Sublime Text snippets中有特殊含義,因此需要轉義才能生效。

您可以用前面的反斜線轉義,因爲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

+0

謝謝,像魅力一樣工作:) – Nakrule