Hi all,
I'm writing a text, where I often need two words highlighted. So instead of writing
- \emph{map} all the time, I tried
- \newcommand{\map}{\emph{map}} so that I can write \map instead.
However I had to observe that the produced output is not always the same. I had a sentence like "... two functions \map and ...". It happened that there was no space between "map" and "and" in the output. When I however switch back to "... two functions \emph{map}and ..." it looks ok.
Is there anything I'm doing wrong with the newcommand? Or am I missing something?
Thanks,
Tim
Text Formatting ⇒ \emph{...} and \newcommand{\emph{...}} not the same?
-
- Posts: 1
- Joined: Tue Jul 28, 2009 1:24 pm
\emph{...} and \newcommand{\emph{...}} not the same?
Hi,
after a command spaces are ignored. You could try including the space explicitle in the command definition, but then you will encounter problems if the next character after the command is, for example, a period.
One way to solve this is to use the xspace package:
after a command spaces are ignored. You could try including the space explicitle in the command definition, but then you will encounter problems if the next character after the command is, for example, a period.
One way to solve this is to use the xspace package:
Code: Select all
\documentclass{article}
\usepackage{xspace}
\newcommand\map{\emph{map}\xspace}
\begin{document}
text text \map text text text
text text \map.
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...