There is almost nothing really bad if you use _
in command names, provided you have
\catcode`\_=11
before starting the definition of those commands and never revert the choice.
You can even continue to use _
in math formulas by adding
\mathcode`\_=\string"8000
\begingroup
\catcode`\_=\active
\global\let_\sb
\endgroup
However such a naming scheme is non standard and definitely not recommendable. With some babel
languages it may even go wrong.
I don't see how
\command_with_underscore
will increase readability over
\NEcommand
that's as easily searchable.
An example, just to show how this can work.
\documentclass{article}
% Start of document commands
\catcode`\_=11
\mathcode`\_=\string"8000
\begingroup
\catcode`\_=\active
\global\let_\sb
\endgroup
\newcommand{\foreign_buyer}{whatever}
\begin{document}
Here we use \foreign_buyer, and also a formula $a_{1}$.
\end{document}

Starting a command name with \if
is definitely bad practice, unless it is a real conditional, introduced with \newif
.
Notice that without \catcode`\_=11
, when you say
\def\if_foreign_buyer{...}
you're actually (re)defining the very important primitive command \if
and this will cause sure disasters with any document.
Note. The command \sb
is defined by \let\sb=_
in the LaTeX kernel, so its meaning doesn't change when one modifies the category code of the underscore character. So it's always available as a substitute for it.
In this application we are telling TeX that _
in math mode should behave like a command, which expands to \sb
, that is it will just do the right thing. However, macros that rely on the presence of _
will be fooled by this, so some package or macro might fail (not commonly used, but I've seen some cases where a macro tests for a following _
).
_
in a command name@
, the general idea of catcodes and 'letters' applies here too: nothing to do withif
per se.\def
name?