I'm trying to highlight arbitrary text fragments, in a beamer presentation, in order to explain SQL injection attacks. Using underlining, or a different text color works fine, because only the specified text is affected, but when try to use bold instead, both the specified text and any adjoining punctuation character is affected. I understand it is for typographic reasons, but here I'm trying to put emphasis on characters, not on words, and the result is not what I expect.
Here is an exemple:
\documentclass{beamer}
\usepackage{times}
\newcommand{\highlight}[1]{\textbf{#1}}
\begin{document}
\begin{frame}
\frametitle{Presentation}
\texttt{WHERE user\_id = '\highlight{' OR 1=1 \#}';}
\end{frame}
\end{document}
The outer quote caracters should not be hightlighted, nor the final semi-colon, only the internal string part.
I tried the following command definitions, without success:
\newcommand{\highlight}[1]{\textbf{#1}}
\newcommand{\highlight}[1]{\bfseries #1}
\newcommand{\highlight}[1]{\bfseries #1 \mdseries}
From this discussion, I understand \bfseries is the lower-level font change primitive, whereas \textbf is the higher-level primitive, and I should probably rely on the second one instead. I also tried to get inspiration from the \textbf macro definition given in comment #52, using the part corresponding to the math environment, as it is seems more strict, but without success, probably because it seems to use plain tex syntax, not latex.
Of course, as other hightlighting strategies works fine, I should probably stop trying to use bold fonts, but that just sound more natural for me than fancy colours. Am I a desesperate case ?
\newcommand{\highlight}[1]{\bfseries #1}
will certainly make all following text bold, the other two will not.