# Make all single line paragraphs \noindent

I want to make all multi-line paragraphs with indentation and all single line paragraphs without. Similar to what is described in Turn off paragraph indention for a single line.

But!

I need to auto-generate the LaTeX code, so I don't know in advance if the paragraph will be single or multi-line.

Is there any way to ask for that kind of style formatting?

• This is not sensible: in some cases the only effet will be tthe previous will look one line longer. How do you make the difference then? – Bernard Oct 2 '15 at 8:09
• If one were to place EVERY paragraph in a macro, it could test the vertical size of the resulting \parbox{\textwidth}. Is that acceptable? – John Kormylo Oct 2 '15 at 14:04
• @John Kormylo: yes, that's an intermediate representation anyways – horsh Oct 2 '15 at 19:40

In my opinion what you want to do makes for very bad typography.

Here's a very rudimentary method, that however only allows for normal paragraphs; lists or anything like that will break it.

\documentclass{article}

\def\testpar#1\par{%
\sbox0{#1}%
\ifdim\wd0<\columnwidth
{\setbox0=\lastbox}#1\par
\else
#1\par
\fi
}

\newenvironment{astounding}
{\everypar={\testpar}}
{}

\begin{document}

\begin{astounding}
This is a single line.

This line will be two lines long if I just add a few words
and more words until it is long enough.

\end{astounding}

\end{document}