Text FormattingTest for Space as next Character

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

Test for Space as next Character

Post by Laurentius »

I tried \@ifnextchar\space and \@ifnextchar\@sptoken to check if the next character was a space, but it didn't work.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Re: Test for Space as next Character

Post by cgnieder »

Can you show us for what purpose or in what cases you want to test for a space? It might be easier to look for everything than a space...

Regards
site moderator & package author
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Test for Space as next Character

Post by josephwright »

\@ifnextchar deliberately skips spaces, so this will not work! As suggested, the use case might be handy here so we can suggest a good solution.
Joseph Wright
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Test for Space as next Character

Post by nlct »

amsgen (amsmath) provides \new@ifnextchar that can be used instead of \@ifnextchar if following spaces shouldn't be ignored, so maybe that might work.

Regards
Nicola Talbot
Post Reply