# Center single lines between other commands, don't center multiple lines

I am writing a latex-class for our theatre club for collaborative writing of theatre-scripts. So the class can be as complex as needed, as long as the usage is as easy as possible.

We have a "says" command within the class, that is outputting the name of the actor to the left and the text the actor says.

Then we have longer text block which are usually introductions and the settings of a scene. however, we sometimes have single lines that are no usual text, but director orders. these should be centered.

I want to setup the class in a way, that single paragraphs without any formatting/ command that are between two \says commands are always centered. however, when there are more than one paragraph, it should be justified.

is that possible with latex? if so, how can I do it?

% ...
The stage is empty. On the front of the stage, there is a typewriter on a
table. The table is lit. In the typewriter there is a page with LaTeX code
on it. it is a stage play. pages upon pages of latex code are clutterd
around that table. commented by hand with percent-signs.

At the back of the stage, there is a black curtain. The floor of the stage
is a black carpet. The rest of the stage is dark and empty.

\says{Editor}{It is called La Tech, not latex like you fetishists think}

% this line would be centered, as it is only one paragraph between two "says"
he sinks to the ground

\says{Random Guy}{Why don't you write it like that if it is called like that?}

%these lines won't be centered as there are two paragraphs.
The light is getting brighter. The stage is still empty.

Now lightly latex-dressed women enter the stage

\says{Editor}{What the heck is that?}



Perhaps it would otherwise be possible to define a control caracter that defines a director input, like > he sinks to the ground

• that is the default formatting for \caption so it is certainly possible. It's a bit easier/more robust if you use a command \something{....} that centers or not its argument, is that OK or are you committed to the version that you asked for with unmarked up paragraphs acting this way? – David Carlisle Jun 8 at 15:12
• actually I am confused, your title distinguishes single line from multiple line (the formatting caption uses) but I just noticed that the text of the question distinguishes single paragraph from multiple paragraphs which is completely different. Please clarify the question. – David Carlisle Jun 8 at 15:15
• as always a small complete test document would be useful to help people test answers and to clarify the intended output. – David Carlisle Jun 8 at 15:16

You can try using a new command like the following:

\documentclass[12pt]{article}

\newcommand{\dirsays}[1]{\sbox{0}{#1}%
\ifdim\wd0>\linewidth
#1
\else
\noindent\makebox[\linewidth]{#1}%
\fi}

\begin{document}

\dirsays{I am writing a latex-class for our theatre club.}

\bigskip
\dirsays{I am writing a latex-class for our theatre club for collaborative writing of theatre-scripts. So the class can be as complex as needed, as long as the usage is as easy as possible.}

\end{document}