views:

5684

answers:

4

In Latex how can I define a string variable whose content is used intead of the variable in the compiled pdf? Let's say I'm writing a tech doc on a software and I wnat to define the package name in the preamble or somewhere so that if its name changes I don't have to replace it in a lot of places but only in one place

Thanks

+14  A: 

add the following to you preamble:

\newcommand{\newCommandName}{text to insert}

Then you can just use \newCommandName{} in the text

For more info on \newcommand, see e.g. wikibooks

second
That's exactly what I needed, thank you very much!
Andrea
+2  A: 

You can try with \newcommand although I hope there is something more appropriate.

piotrsz
Thank you very much
Andrea
+3  A: 

For variables describing distances, you would use \newlength (and manipulate the values with \setlength, \addlength, \settoheight, \settolength and \settodepth).

Similarly you have access to \newcounter for things like section and figure numbers which should increment throughout the document. I've used this one in the past to provide code samples that were numbered separatly of other figures...

Also of note is \makebox which allows you to store a bit of laid-out document for later re-use (and for use with \settolength...).

dmckee
+2  A: 

Use \def command:

\def \variable {Something that's better to use as a variable}
plaes