General ⇒ custom macros
custom macros
I'm new to the forum and I hope I'm posting it in the right place.
I'm looking for a way to define a general command that will generate other macros. For example create a command called
"\newAnimal" that receives 2 arguments name and description and for the following input "\newAnimal{CAT}{9 souls animal}" generates the following macros \animalCAT which writes "CAT" in blue and \descriptionCAT writes "9 souls animal"
Thanks
Gaby
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
custom macros
Code: Select all
\usepackage{etoolbox}
\newrobustcmd*{\newAnimal}[2]{%
\csdef{animal#1}{\textcolor{blue}{#1}}%
\csdef{description#1}{#2}%
}