I'd like to construct a macro like \parbox, but with a style of spread align, as the option [s] in \makebox.
That is to say, when the width of text is less than the defined width(only one line of text), the text will typeset spread align. If the width of text is longer than defined width, it behaves just as \parbox.
Example:
\documentclass{article}
%\usepackage{...}
\begin{document}
\newcommand\newparbox[3][]{...}
|\newparbox{8em}{AB AB}|\par
|\newparbox[t]{8em}{AB AB AB AB AB AB AB}|
\end{document}

\widthofin the argument of\lengthtest. – egreg Feb 16 '19 at 14:48\widthofis used is, I don't want introduce a new length variable. Can I get this? And why\widthofcan not be used in\lengthtest? – lyl Feb 16 '19 at 14:54\\in #3, how to handle it to get exactly the same effect above. I mean, not just the first line, every line(delimited by\\), if the length of a certain line is shorter than #2, then spread align it, otherwise, typeset like\parbox– lyl Feb 17 '19 at 01:48