19

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.

lockstep
  • 250,273
Ubik
  • 191

1 Answers1

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

\begin{document}
\WHP

\WHP.
\end{document}