TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
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
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
up vote 9 down vote accepted

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


This will temporarily neuter the effect of \\.

share|improve this answer

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.