Tell me more ×
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.

2013-03-06: Update:

It seems that there was a recent update to xstring which resolved this problem. Just updated all packages and the MWE below now correctly produces:

enter image description here


It seems as if I am having a problem understanding \StrGobbleRight. The intent of the the \RemoveTrailingSpace is to do what it says, that is remove trailing space on the right. But the MWE seems to be inserting space on the left:

enter image description here

This is part of a much bigger macro so I use \SearchTarget later on, but don't want this spacing???

Code:

\documentclass{article}
\usepackage{showframe}
\usepackage{xstring}

\newcommand*{\RemoveTrailingSpace}[1]{%
    \IfEndWith{#1}{\space}{%
        \StrGobbleRight{#1}{1}[\SearchTarget]%
    }{%
        \def\SearchTarget{#1}%
    }%
    \SearchTarget%
}

\begin{document}\noindent
X\RemoveTrailingSpace{YYY}Z

\noindent
X\RemoveTrailingSpace{ YYY}Z

\noindent
X\RemoveTrailingSpace{YYY }Z

\noindent
X\RemoveTrailingSpace{YYY     }Z
\end{document}
share|improve this question
The problem was in the definition of \@cs@removefirstsyntaxunit, line 209f.: An opening brace at the end of the line. – Qrrbrbirlbel Mar 7 at 2:55

closed as too localized by Peter Grill, Speravir, Kurt, Qrrbrbirlbel, lockstep Mar 7 at 3:22

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

Browse other questions tagged or ask your own question.