Last active
February 24, 2021 16:20
-
-
Save malloc47/5298181 to your computer and use it in GitHub Desktop.
Example of LaTeX snippet that keeps text on a single line, but resizes it to fit the width, if it would otherwise wrap.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{xifthen} | |
\usepackage{graphicx} | |
\newcommand{\oneline}[1]{% | |
\newdimen{\namewidth}% | |
\setlength{\namewidth}{\widthof{#1}}% | |
\ifthenelse{\lengthtest{\namewidth < \textwidth}}% | |
{#1}% do nothing if shorter than text width | |
{\resizebox{\textwidth}{!}{#1}}% scale down | |
} | |
\begin{document} | |
\oneline{\Huge{The no-wrap text to scale}} | |
\oneline{\Huge{The quick brown fox jumped over the lazy dog, over and over and over and over again.}} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment