Text Formatting ⇒ \emph{...} and \newcommand{\emph{...}} not the same?
-
tim-kiefer
- Posts: 1
- Joined: Tue Jul 28, 2009 1:24 pm
\emph{...} and \newcommand{\emph{...}} not the same?
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
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
\emph{...} and \newcommand{\emph{...}} not the same?
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}