For my beamer slides, I like to have a command that centers a block of text and surrounds it by parentheses whose vertical size grows as the number of lines in the text grows.
I currently have the following:
\NewEnviron{remarkblock}[1][]{%
\scalebox{1}{%
$\scaleleftright{(}{\parbox{0.95\linewidth}{\centering \small\BODY}}{)}$
}
}
(don't ask me for explanations, I put this together from stackexchange bits)
This works almost fine. The only thing I'd like to improve is that when there is less than one line of text I would like the parentheses to not actually be 0.95 linewidths apart but just behave as normal parentheses (maybe a tad bigger) around centered text.
On https://en.wikibooks.org/wiki/LaTeX/Boxes I read that replacing \parbox by \pbox should do exactly what I want. However, I have two problems:
If the text contains a manual line break, I get an error:
Somthings's broken -- Perhaps a missing \itemIf I don't have a manual line break, it kind of works, but the pbox becomes left aligned even if I put
\centeringbefore\scaleleftrightas well as before\pbox
EDIT: Upon request, here is a Minimal Working Example. In this version, I get the error; if I remove the \\ I get the left alignmnt, if I put a long text where the test is and remove the \\ everything is as desired.
\documentclass{article}
\usepackage{pbox}
\usepackage{scalerel}
\begin{document}
\scalebox{1}{$\centering\scaleleftright{(}{\centering\pbox{0.95\linewidth}{\centering \small test \\ test}}{)}$}
\end{document}

