如何在 LaTeX 中进行条件格式化?

如何在 LaTeX 中进行条件格式化?

我对格式化以下代码感兴趣,以便如果满足条件(Add = 0 和 Del = 0),则我的文档将打印出“没有添加或删除”。否则,文档将打印出带有 Add 和 Del 值的项目符号列表。

AddName = 0
DelName = 0
cat("\\newcommand{\\Add}{",AddName,"}",sep="")
cat("\\newcommand{\\Delete}{",DelName,"}",sep="")

\if <\Add = 0 AND \Del = 0> 
  <\normal{There are no additions or deletions.}>
\fi

\begin{compactitem}
    \item[$\bullet$ \Add { } {\color{OliveGreen}\bf{+}}:]
    \item[$\bullet$ \Del { } {\color{red}\bf{-}}:]
\end{compactitem}

我在网上找不到太多文档,以下是我收到的错误消息:

> \if <\Add = 0 AND \Del = 0> 
Error: unexpected input in "\"
>   <\normal{There are no additions or deletions.}>
Error: unexpected '<' in "  <"
> \fi
Error: unexpected input in "\"

> \begin{compactitem}
Error: unexpected input in "\"
> \item[$\bullet$ \Add { } {\color{OliveGreen}\bf{+}}:]
Error: unexpected input in "\"
> \item[$\bullet$ \Del { } {\color{red}\bf{-}}:]
Error: unexpected input in "\"
> \end{compactitem}
Error: unexpected input in "\"

有人可以帮我调试这些错误吗?

相关内容