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

\newcommand{\sometext}{text\\text\\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
add comment

1 Answer

up vote 8 down vote accepted

This will change \\ into a space:

\newcommand{\removelinebreaks}[1]{%
  \begingroup\def\\{ }#1\endgroup}

\removelinebreaks{\sometext}
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
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.