LaTeX command for constant text


In most theses or studies, you need to use certain notions very often, so a straigth-forward approach would be writing a small command for them. This way, you can change the notion or its formatting without having to change every occurence in the text. One would expect this to be fairly simple and it also is. However, there are some traps concerning the formatting. An example command would be:

\newcommand{\bpel}{
\textit{WS-BPEL}
}

The problem with this command is that it enters an additional freespace before and sometimes also after the text. To avoid the freespace before the text you have to make sure that there is no linebreak after the second opening curly brackets which can be done with %. To resolve the freespace after the text, there is a very convenient package named xspace. So the correct newcommand would be:

\newcommand{\bpel}{%
\textit{WS-BPEL}\xspace
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s