# How to create a command to insert a string, but possibly ignore white space before the command?

I would like to define a switch that shows additional comments in some text (containing formulas). As you can see below by setting showString to true, this works well. However, when I set it to false, there is some leftover space before the full stop. I tried to "ignore" it by using \ignorespaces, but that's still contains the one blank from after the word "text". How can this be avoided?

One solution would be to insert a space before #1 in \mystring and use "This is just some text\mystring{here}" in the example (so removing the space before the command). Is there a more elegant solution?

\documentclass{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[american,ngerman]{babel}
\usepackage{ifthen}
\usepackage{amsmath}

\newboolean{showString}
\setboolean{showString}{false}% use true/false
\newcommand*{\mystring}[1]{\ifthenelse{\boolean{showString}}{\text{\bfseries #1}}{\ignorespaces}}

\begin{document}
This is just some text \mystring{here}.

\begin{align*}
a=b\tag*{\mystring{here}}
\end{align*}
\end{document}

-
try putting \unskip at the beginning of the "false" condition to get rid of a space already input. – barbara beeton Jun 20 '12 at 13:01

\newcommand*{\mystring}[1]{%