Sign up ×
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 have defined the following shortcut for some text


Now I would like to use this in some other place but with the linebreaks removed. So is there an easy way to do it (e.g. something like "\remove_linebreaks{\sometext}")?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

This will change \\ into a space:

  \begingroup\def\\{ }#1\endgroup}

share|improve this answer
\\ has an optional star and an optional argument. Something like \def\\{\@ifstar {\@gobbleopt}{\@gobbleopt}}\providecommand*\@gobbleopt[1][]{} would handle these too. – Schweinebacke Nov 23 '11 at 13:56

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.