[Tex/LaTex] Ignore newline in LaTeX variable

tex-core

I have some string in variable \somevar, eg. foo\\bar. How can I force LaTeX to ignore newline in \somevar. When I write content of the variable there should be

foo bar

and not

foo
bar

Best Answer

Within the group that you are expanding the macro you can do

\let\\=\relax

This will temporarily neuter the effect of \\.

Related Question