Search code examples
colorsmacroslatexoverleaf

Error while defining a \newcommand using xcolor package


I am required to show the changes while I am editing a Latex document. So I have defined some colours variables as follows:

\usepackage{xcolor}
\usepackage{ulem}
\newcommand{\added}[1]{{\color{NavyBlue}{{}ADDED: #1}}}
\newcommand{\deleted}[1]{{\color{red}{DELETED: \sout{#1}}}}
\newcommand{\comment}[1]{{\color{ForestGreen}{[#1]}}}

This would then be used in the document as follows:

\begin{document}

Hi
I am showing that \deleted{I am deleting my old words}, \added{adding some new words} and \comment{offering some comments.}


\end{document}

This is creating errors, can anyone plz help?


Solution

  • NavyBlue, ForrestGreen etc. are normally not defined. You need to use the dvipsnames option if you want to use such names.

    \documentclass{article}
    
    \usepackage[dvipsnames]{xcolor}
    \usepackage{ulem}
    \newcommand{\added}[1]{{\color{NavyBlue}{{}ADDED: #1}}}
    \newcommand{\deleted}[1]{{\color{red}{DELETED: \sout{#1}}}}
    \newcommand{\comment}[1]{{\color{ForestGreen}{[#1]}}}
    
    \begin{document}
    
    Hi
    I am showing that \deleted{I am deleting my old words}, \added{adding some new words} and \comment{offering some comments.}
    
    
    \end{document}
    

    enter image description here