pi@eng.cam.ac.uk (Pablo Iglesias) (03/28/91)
I wrote the following: > I want to create a command in LaTeX which would do the following: > > \negate{A} would give me -A. > \negate{-A} would give me A. I want to thank the several people who answered my query. The following, due to David Carlisle was the first answer I got, and seemed to do what I wanted quite well. -Pablo % Document Type: LaTeX % Master File: xx.tex % \documentstyle{article} \makeatletter \def\neg@te{\@ifnextchar-{\@gobble}{-}} \def\negate#1{\neg@te#1} \makeatother \begin{document} $\negate{-7}$ $\negate{88}$ $\negate{99} + \negate{-99} = 0$ \end{document} -- Pablo Iglesias Phone : +44 223 332813 Department of Engineering Fax : +44 223 332662 Cambridge University email : pi@eng.cam.ac.uk Cambridge, CB2 1RD, UK
pi@eng.cam.ac.uk (Pablo Iglesias) (03/28/91)
I wrote > I want to create a command in LaTeX which would do the following: > > \negate{A} would give me -A. > \negate{-A} would give me A. I want to thank the several people who answered my query. The following, due to David Carlisle was the first solution that I got, and it did exactly what I wanted. I include it in case anyone else wants to know. -Pablo -------------------------------------------------- % Document Type: LaTeX % Master File: xx.tex % \documentstyle{article} \makeatletter \def\neg@te{\@ifnextchar-{\@gobble}{-}} \def\negate#1{\neg@te#1} \makeatother \begin{document} $\negate{-7}$ $\negate{88}$ $\negate{99} + \negate{-99} = 0$ \end{document} -- Pablo Iglesias Phone : +44 223 332813 Department of Engineering Fax : +44 223 332662 Cambridge University email : pi@eng.cam.ac.uk Cambridge, CB2 1RD, UK