I am looking for a way to tell TeX:

Please break that line if and only if you are not on new line already.

I need this for a new environment which should always start in a new line. But I don't (how could I?) know, whether the author has typed a linebreak in front of that manually. I tried \linebreak, \\, and \newline, all of them caused the

LaTeX Error: There's no line here to end.

error, which I expected to show up, when trying

\newenvironment{mynewenvironment}{\\ \emph{Header:} }{}
random text \\
text again

One can observe the same behavior with predefined environments, for instance

random text 
\\ \item text

is causing the error but not

random text

\item text

random text\begin{itemize}
\item text

Both are doing exactly how I want my environment to react, therefore I expect my problem to be solvable fairly easy, but I don't know how.

  • Welcome to TeX.SE! There should be no reason to use a manual line break at all. Maybe if you put \par or an empty line there? – yo' Mar 4 '13 at 17:03

You should almost never use \\ in a document other than ending tabular rows. Just use \par with an appropriate setting of \parskip and \parindent. Or for more general display environments copy the definition of the latex environments such as center or quote which are all defined in terms of list or trivlist which enables them to detect whether the following text needs to start a new paragraph or not. quote for example is simply defined as:

  • Thank you very much! \par does the trick I was looking for, and with the hints from the quote environment I am very happy now =) – Dominikus K. Mar 4 '13 at 17:17

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.