Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Possible Duplicate:
\newcommand and spacing
No space following macro without argument

I want to use \newabbrev for some abbreviations, but the spacing is off. With \newabbrev, I get spacing both before a new word and before a period. With a simple \newcommand it's the other way around. What do I do?

\documentclass{article}
\usepackage{abbrevs}
\newabbrev{\whp}{with high probability}
\newcommand{\whpcmd}{with high probability}
\begin{document}
\setlength{\parindent}{0in}
The event occurs \whp by our previous argument. We get spacing, using \verb|\newabbrev|.

Edit: Specifically, why does the abbreviation get the space before the period? That doesn't seem to make sense.

The event occurs \whpcmd by our previous argument. No spacing (bad), Using \verb|\newcommand|.

The event occurs \whp. We get spacing (bad), using \verb|\newabbrev|.

The event occurs \whpcmd. No spacing, Using \verb|\newcommand|.

\end{document}
share|improve this question

marked as duplicate by lockstep, Andrey Vihrov, Yiannis Lazarides, egreg, Thorsten Mar 17 '12 at 17:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
The reason why there's no spacing in the second case is because command eats all the following whitespace. You can protect it by empty braces: ... occurs \whpcmd{} by our ... –  tohecz Mar 17 '12 at 10:06
    
You could use \newcommand and the xspace package, which will add a space only if the next character is not a punctuation mark. Have a look at this question (possible duplicate) –  ienissei Mar 17 '12 at 10:25
2  
While having abbreviations for commonly used phrases may seem attractive, it's not very useful in the long run, as it makes the document unreadable, particularly when it's opened some time after it has been written. Look at tex.stackexchange.com/questions/17730/newcommand-and-spacing –  egreg Mar 17 '12 at 11:00
    
Looks like I'm going to try to ween myself off the abbreviation like @egreg suggests, although that doesn't resolve the issue per se. –  einpoklum Mar 17 '12 at 16:43
    
I don't think this question is a duplicate. Other questions on the same topic do not refer to the abbrevs package. This package claims to intelligently detect when a space is required, without using \xspace. –  haggai_e Mar 18 '12 at 8:57

Browse other questions tagged or ask your own question.