0

I am interested in formatting the following code such that if a conditional is met (Add = 0 and Del = 0), then my document prints out "There are no additions or deletions". Otherwise, the document prints out a bulleted list with the values of Add and 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}

I could not find too much documentation online, and here are the error messages I get:

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

Can someone please help me debug these errors?

  • Maybe you should have a look at the ifthen package and booleans in LaTeX. It is easy to setup \ifthenelse{\boolean{add}\AND\boolean{del}}{}{}. – TeXnician Jun 30 '17 at 12:30
  • Btw: < and > should only be used in math mode or something \ifnum like. – TeXnician Jun 30 '17 at 12:31
  • 1
    @TeXnician it is not mentioned anywhere but based on previous questions i assume that this is R syntax not tex (the error messages do not come from tex either) – David Carlisle Jun 30 '17 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.