When we write computer programs we use constants instead of repeating the same value over and over again in the program. Why not do the same in LaTeX – why repeat titles and other names that are used many times in the same document?
LaTeX may not be your favorite programming language but defining and using constants is very simple and does not require reading a thick manual. To define a command \DocTitle that gets replaced with it’s value wherever it’s being used simply type
\newcommand{\DocTitle}{My title}
But here is a problem; try later in Latex
\DocTitle is the doc title
There will be no space separating “My title” and “is”… Redefining
\newcommand{\DocTitle}{My title }
Will make a problem for say
\DocTitle, that is the doc title
Example LaTeX use…
To get around the space problem, keep the original version, but put a slash after \DocTitle\ like this, when you want a space after it.Thank you!