TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?



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

This is just some text \mystring{here}.

share|improve this question
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
up vote 4 down vote accepted

I'd suggest

  \ifthenelse{\boolean{showString}}{\text{\bfseries #1}}{\ifhmode\unskip\fi}}
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.