Is it possible to define a macro that changes font based on width that a box "would be"?
I'd like to define a LaTeX macro that does something like:
\newcommand{\mylabel}[1] {
\if\latexMagicWidthOf{\labelfont #1}>2em
{\labelfont #1}
\else
{\condensedlabelfont #1}
\fi
}
In other words, if #1 would be wider than 2em in labelfont, use condensedlabelfont instead.
I think I could implement \latexMagicWidthOf with a \newbox and \wd\labelbox, but I'm stuck on comparing dimensions for anything but equality.
\ifdimfor comparing sizes – daleif Sep 22 '21 at 09:00%at ends of lines. why not{\labelfont\resizebox{2em}{!}{#1}}which will set the text to 2em width. – David Carlisle Sep 22 '21 at 09:10