views:

625

answers:

2

I'm working on a large project involving multiple documents typeset in LaTeX. I want to be consistent in my use of symbols, so it might be a nice idea to define a command for every symbol that has a specific meaning throughout the project. Does anyone have any experience with this? Are there issues I should pay attention to?

A little more specific. Say that, throughout the document I would denote something called permability by a script P, would it be an idea to define

\providecommand{\permeability}{\mathscr{P}}

or would this be more like the case "defining a command for $n$"?

+2  A: 

I have been doing this for anything that has a specific meaning and is longer than a single symbol, mostly to save typing:

\newcommand{\objId}{\mbox{$\mathit{objId}$}\xspace} 
\newcommand{\insOp}[1]{#1\mbox{$^+$}\xspace} 
\newcommand{\delOp}[1]{#1\mbox{$^-$}\xspace}

However then I noticed that I stopped making inconsistency errors (objId vs ObjId vs ObjID), so I agree that it is a nice idea.

However I am not sure if it is a good idea in case symbols in the output are, well, single Latin symbols, as in:

\newcommand{\numOfObjs}{$n$}

It is too easy to type a single symbol and forget about it even though a command was defined for it.

EDIT: using your example IMHO it'd be a good idea to define \permeability because it is more than a single P that you have to type in without the command. But it's a close call.

Laurynas Biveinis
Thanks. I think I'll use command, especially because I tend to change my notation sometimes.
Martijn
+2  A: 

A few tips:

  • Using \providecommand will define that command only if it's not been previously defined. So if you're not getting the results you expected, you may be trying to define a command that's been defined elsewhere.
  • If you wrap the math in your commands with \ensuremath, it will do the right thing regardless of whether you're in math mode when you issue the command:

    \providecommand{\permeability}{\ensuremath{\mathscr{P}}}
    Now I can easily use \permeability in text or $\permeability$ in math mode.
    
  • Using your own commands allows you to easily change the typographical representation of something later. For instance:

    \newcommand{\vect}[1]{\ensuremath{\mathbf{#1}}}
    

    would print \vect{x} as a boldfaced x. If you later decide you prefer arrows above your vectors, you could change the command to:

    \newcommand{\vect}[1]{\ensuremath{\vec{#1}}}
    
godbyk