I used to think that the behavior of underscores ('_') was as follows:
IF ('_') {
BUFFER NEXT ITEM
MAKE THE NEXT ITEM A SUBSCRIPT
SEND SUBSCRIPT TO OUT STREAM
}
ELSE IF ('\_')
SEND UNDERSCORE CHARACTER TO OUT STREAM
I was wrong.
%% Use underscore for subscript while not in math mode
%% ERROR!
%X_5
% Use underscore in math mode to make a subscript
% No error
$ X_{subscript} $
% Escape Sequence (backslash) tells LaTeX we want underscore char
% instead of '_' means 'make a subscript'
% No error
X \_ \_ \_ Oh look! underscore characters.
% underscore in the label name
% No error
\begin{equation}
x = y \label{LAB_BY}
\end{equation}
%% Do not want subscript functionality of '_'
%% Use backslash to put an underscore into the label name
%% put a space after '_' so that after escape reads only '_' and not '_BY'
%% ERROR
%\begin{equation}
% x = y \label{LAB\_ BY}
%\end{equation}
%% Do not want subscript functionality of '_'
%% Use backslash to put an underscore into the label name
%% fail to put a space char after '\_'
%% ERROR
%\begin{equation}
% x = y \label{LAB\_BY}
%\end{equation}
When are underscores allowed and when are they not allowed?
What does '_' signify if you are not in math mode?