转自:Inside_Zhang

1. 新建命令

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

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

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

\newcommand{\tnss}{The not so Short Introduction to \LaTeX}
 
  • 1

含参数,

\newcommand{\txist}[1]
{This is the \emph{#1} Short Introduction to \LaTeX}

\txist{not so}\\
\txist{very}
 
  • 1
  • 2
  • 3
  • 4
  • 5

2. def

为了书写的方便;

\def\E{\mathrm{E}}
\def\Var{\mathrm{Var}}
\def\Cov{\mathrm{Cov}}
 
  • 1
  • 2
  • 3

3. 举例

  • 逆时针 反转 90°

\usepackage{amsmath, graphicx}
\newcommand{\indep}{\rotatebox[origin=c]{90}{$\models$}}
 
  • 1
  • 2

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

$X \indep Y$
 
  • 1
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐