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 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
share|improve this question
1  
Why do you store a newline in your variable if you don't want to display it? Maybe you need to make a wrapper around your macro to split the usage? –  ℝaphink May 10 '11 at 12:23
1  
The variable is in document class. Content of the variable comes from user's document and user can put newlines there. One time I can print the variable with newline and another time the newlines are not acceptable but this is still the same text. –  jesper May 10 '11 at 12:28
    
How about providing an option like \chapter does? You can write \chapter[alternative title]{title} where one can have newlines and the other can't. –  ℝaphink May 10 '11 at 12:30
add comment

1 Answer

up vote 9 down vote accepted

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

\let\\=\relax

This will temporarily neuter the effect of \\.

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.