乳胶崇高片段 [英] Latex Sublime snippet

查看:114
本文介绍了乳胶崇高片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Sublime 代码段来创建 Latex 状态机模板.但是,它什么都不做(当我输入stmach"并按 Tab 键时,stmach 消失了,但未包含 Latex 代码).我不明白为什么,因为我所有的其他片段都运行良好.

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

<内容><![CDATA[\begin{中心}\begin{tikzpicture}[shorten >=1pt,node distance=4.5cm,on grid,auto]\tikzstyle{every state}=[draw=blue!50,verythick,fill=blue!20] % 节点颜色\node[state,initial,initial text=reset, initial where=below] (配置) {$conf$};% 节点名称和位置\node[state] (init) [右下=配置] {$init$};\path[->] % 箭头(配置)edge [bend left] 节点 {finishConfiguration=1} (init)(在里面)edge [bend left] 节点{}(配置);\end{tikzpicture}\end{中心}]]></内容><!-- 可选:设置 tabTrigger 来定义如何触发代码段 --><tabTrigger>stmach</tabTrigger><!-- 可选:设置范围以限制代码段将触发的位置--><scope>text.tex</scope>

请注意,Latex 代码可以正常工作,没有任何错误或警告.

解决方案

$ 字符在 Sublime Text 片段中具有特殊含义,因此需要转义才能有效.

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

转义时的样子:

I'm using a Sublime snippet to create a Latex state machine template. However, it does nothing (when I type "stmach" and press tab, stmach disappears but the Latex code isn't included). I don't understand why, as all my other snippets are working fine.

If I remove some lines in the snippet, it works, but I need the whole block :/

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

Note that the Latex code works without any error or warning.

解决方案

The $ character has special meaning in Sublime Text snippets, and therefore needs to be escaped to be valid.

You can escape them with a preceding backslash, as the 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>


Using the syntax highlighting from https://github.com/sublimehq/Packages/pull/576 makes the problem clearer, as ST unfortunately doesn't offer any feedback, as you have seen:

How it looks when escaped:

这篇关于乳胶崇高片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆