I'm looking for a way to write a macro that will add a line break after the text from the argument, but prevent that line break to add to another line break, if there is one following.

If I use \newcommand*\ask[1]{{\bf Q:} #1 \\} and then use \ask{How?} \\ I will have used two \\ and thus get two vertical spaces. But I just want one line break, no further vertical space. The same holds for \newline, \\* and \hfill\break.

Sorry, if my description sounds confusing, I may not have used the proper LaTeX terms. I hope you understand my question anyway.

  • 1
    \\ should almost never be used outside of tables. use \par (or equivalently a blank line) also \textbf{G} (\bf is just for compatibility with the 1908's version of latex and is not defined by default in the latex format) – David Carlisle Sep 12 '14 at 9:46
  • this is related (possibly duplicate) tex.stackexchange.com/questions/82664/when-to-use-par-and-when – David Carlisle Sep 12 '14 at 9:48
  • 1
    @DavidCarlisle Sometimes misprints are so nice... 1908's version of latex ;-) – Przemysław Scherwentke Sep 12 '14 at 9:54
  • 1
    @PrzemysławScherwentke it seems a long time ago:-) – David Carlisle Sep 12 '14 at 9:56
  • The Q is presumably a heading of sorts in which case you should probably use a heading or list item command (which would automatically have the effect you want of ignoring any following blank lines) \section*{Q}xxx and \section*{Q} <blank line> xxx are typeset the same way – David Carlisle Sep 12 '14 at 10:04

Don't use \\ in documents outside of tabular and math environments.

\newcommand*\ask[1]{\section*{Q: #1}}

Probably does the right thing (or you may want a different level or a custom heading command using the same \@startsection base layout as the sectioning commands).


\ask{something}blah blah



blah blah

Will have the same layout, with the linebreak after the \ask not having any affect on the output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.