我正在尝试将多行标题调整为单行。我找到了文本的长度并检查它是否大于\linewidth
或\textwidth
。两个维度都给出了比预期更大的值。经过修改后,我意识到250pt
是神奇的值。我不知道如何以编程方式找到它。
\documentclass{beamer}
\newcommand{\mytitle}{A very very very very very very very very very long title}
\newlength{\mytitlewidth}
\settowidth{\mytitlewidth}{\mytitle}
\ifdim\mytitlewidth > \linewidth % 250pt
\title{\resizebox{\dimexpr\textwidth}{!}{\centering{\mytitle}}}
\else
\title{\mytitle}
\fi
\author{\the\mytitlewidth, \the\linewidth}
\institute{}
\date{January 31st, 2023}
\begin{document}
\frame{\titlepage}
\end{document}