WinEdt && LaTex(四)—— 自定义新命令(newcommand、def)

1. 新建命令

使用如下的命令: ewcommand{name}[num]{definition}

该命令(newcommand)有两个参数,第一个 name 是你想要建立的命令的名称,第二个definition是命令的定义,num是可选的,用于指定新命令所需的参数数目(最多 9 个)。如果不给出这个参数,默认就是 0。新建命令的使用和内置命令没有明显的区别。

  • 1),替代经常出现的文本内容

    
    ewcommand{	nss}{The not so Short Introduction to LaTeX}

    含参数,

    
    ewcommand{	xist}[1]
    {This is the emph{#1} Short Introduction to LaTeX}
    
    	xist{not so}\
    	xist{very}

2. def

为了书写的方便;

defE{mathrm{E}}
defVar{mathrm{Var}}
defCov{mathrm{Cov}}

3. 举例

  • 逆时针 反转 90°

    usepackage{amsmath, graphicx}
    
    ewcommand{indep}{
    otatebox[origin=c]{90}{$models$}}

    定义完成之后,便可以使用了:

    $X indep Y$
原文地址:https://www.cnblogs.com/mtcnn/p/9422478.html