The goal of this code is to arrange three pieces of text on a line such that if any of the three parts are too long, then the center text is lowered by \baselineskip:
\documentclass{article}
\usepackage[showframe,papersize={5.5in,8.5in}]{geometry}
\newlength{\testwd}
\newcommand{\entry}[4][]{%
\setbox1=\hbox{\strut\bfseries#2}%
\setbox2=\hbox{\strut\itshape#3}%
\setbox3=\hbox{\strut#4}%
\setlength{\testwd}{\ifdim\wd1>\wd3 \wd1\else\wd3\fi}% Which is longer, L or R? Use it.
\noindent%
\if###1##\else\llap{#1\thinspace}\fi
\hbox to 0pt{\box1\hss}%
\hfill
%% If the longer side (L or R) is longer than the half the remaining area around
%% the center text, drop the center text.
\ifdim\dimexpr \testwd - (\linewidth - \wd2)/2\relax>0pt\lower\baselineskip\fi
\hbox{\box2}%
\hfill
\hbox to 0pt{\hss\box3}%
\par
}
\begin{document}
\entry{Left side text}{Center Text}{Right text}
\entry{Left side text that is rather long}{Center Text}{Right side text}
\entry{Left side text}{Center Text}{Right side text that is rather long}
\end{document}
This produces:
Out of curiosity, I wonder if there is a way to do this without explicitly setting \testwd? In other words, can the calculation of \testwd be incorporated into the decision about whether or not to lower the center text? Or, is there a more efficient way of doing this altogether? (There is How to make text aligned left/center/right in the same line?, but this does not accomplish the same thing in that long lines overwrite each other, particularly the center text. All bets are off, of course, if the left and right texts overwrite each other. In this case that does not happen and so is not an issue.) This is useful in concert programs for example.


\leftskip...\rightskippossibility makes my head ache. About the\dimen0and grouping -- quite right. Thanks. – sgmoye Jan 20 '19 at 19:21