Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
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
add comment

1 Answer

up vote 4 down vote accepted

I'd suggest

\newcommand*{\mystring}[1]{%
  \ifthenelse{\boolean{showString}}{\text{\bfseries #1}}{\ifhmode\unskip\fi}}
share|improve this answer
add comment

Your Answer

 
discard

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.