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.

I have trouble with macros expanding to an abbreviated expression. Say I have \WHP which expands to "with high prob." (artificial example). I want to avoid the dot after the abbreviation colliding with full stops later on, like

"We concluded that hypothesis holds \WHP."

which should not expand to

"We concluded that hypothesis holds with high prob.."

but simply end with one full stop.

share|improve this question

1 Answer 1

\documentclass{article}
\makeatletter
\def\WHP{with high prob\@ifnextchar.{}{.}}% test of next token 
\makeatother

\begin{document}
\WHP

\WHP.
\end{document}
share|improve this answer
9  
Or better yet, make the \@ifnextchar.{}{.} bit a separate macro and use it in the definition of any abbreviation. –  Harald Hanche-Olsen Feb 25 '11 at 20:27
1  
Thanks a lot. This will be my \xdot macro from now on. Oh, and for the sake of good typography I'll throw a \@ in there after the dot. –  Ubik Feb 25 '11 at 20:55
    
How can I use this in the glossaries package for the \gls{...} and related commands, for abbreviations and the like which may end in a dot. –  Nicholas Hamilton Jun 17 '13 at 10:43
    
@ADP: show an example –  Herbert Jun 17 '13 at 11:09
    
@Herbert, I have posted a question: tex.stackexchange.com/questions/119537/… –  Nicholas Hamilton Jun 17 '13 at 12:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.