I would like to make a command in LaTeX that prints something if it is preceded by a certain character and something else if it is preceded by any other character.
With \@ifnextchar
I can base the output on the character after the command:
\documentclass{article}
\makeatletter
\newcommand\mycommand{\@ifnextchar h{I see an h\ }{I don't see an h\ }}
\makeatother
\begin{document}
\mycommand h %output: I see an h h
\mycommand n %output: I don't see an h n
\end{document}
I would like to do this, but basing the output on the character before my command.
microtype
is not an option).