"BigText" formating: how to adapt the fontsize to make all lines have the same width?
Here is a solution using adjustbox
The vertical spacing between lines could be altered a bit, and the syntax could probably need some approvements.
Output
Code
\documentclass[11pt, margin=5pt]{standalone}
\usepackage{adjustbox}
\usepackage{xcolor}
\usepackage{pgffor}
\usepackage{helvet}
\definecolor{Pink}{HTML}{E22E3B}
\definecolor{Blue}{HTML}{0C2153}
\definecolor{DarkBlue}{HTML}{0C1C3B}
\definecolor{Red}{HTML}{C51E1F}
\setlength{\fboxrule}{4pt}
\setlength{\fboxsep}{10pt}
\newcommand{\BigWords}[1]{%
\adjustboxset{min width=\linewidth, margin*=0.2em 1ex 0ex 0ex}%
\foreach \i [count=\ni] in {#1}{%
\ifnum\ni=1
\adjustbox{}{\i}%
\else
\\\adjustbox{}{\i}%
\fi
}\vspace{-1ex}%
}
\begin{document}
\fbox{%
\begin{minipage}{15cm}
\bfseries\sffamily
\BigWords{SOME,TOTALLY,HIPSTER,QUOTE,ABOUT,LIFE}%
\end{minipage}%
}%
\hspace{2em}%
\setlength{\fboxrule}{0.5pt}%
\fbox{%
\begin{minipage}{20cm}
\bfseries\sffamily
\BigWords{
\textcolor{Pink}{RUN},
\textcolor{Blue}{LIKE},
\textcolor{DarkBlue}{RYAN},
\textcolor{Red}{GOSLING},
\textcolor{Pink}{IS WAITING},
\textcolor{Blue}{FOR YOU},
\textcolor{DarkBlue}{AT THE},
\textcolor{Red}{FINISH LINE},
\textcolor{Pink}{(WITH A PUPPY)}%
}%
\end{minipage}%
}
\end{document}
An implementation with expl3
for a cleaner syntax:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand{\bigtext}{mm}
{ % #1 = width, #2 = text, with \\ to separate lines
\ebo_bigtext:nn { #1 } { #2 }
}
\seq_new:N \l_ebo_bigtext_text_seq
\box_new:N \l_ebo_bigtext_line_box
\cs_new_protected:Nn \ebo_bigtext:nn
{
\begin{minipage}{#1}
\baselineskip=-\maxdimen \lineskip=4pt
\seq_set_split:Nnn \l_ebo_bigtext_text_seq { \\ } { #2 }
\seq_map_inline:Nn \l_ebo_bigtext_text_seq
{
\hbox_set:Nn \l_ebo_bigtext_line_box { ##1 }
\box_resize_to_wd:Nn \l_ebo_bigtext_line_box { \textwidth }
\box_use:N \l_ebo_bigtext_line_box
}
\end{minipage}
}
\ExplSyntaxOff
\begin{document}
\noindent
\bigtext{15em}{SOME \\ TOTALLY \\ HIPSTER \\ QUOTE \\ ABOUT \\ LIFE}
\quad
\sffamily
\bigtext{15em}{SOME \\ TOTALLY \\ HIPSTER \\ QUOTE \\ ABOUT \\ LIFE}
\end{document}
Spaces around \\
are ignored.
One might add an optional argument to set the vertical space between lines, in the macros above set to 3pt.
With XeLaTeX, but it needs a further refinement for the case when the line has a single letter:
\documentclass{article}
\usepackage{xparse,l3regex}
\usepackage{fontspec}
\ExplSyntaxOn
\NewDocumentCommand{\bigtext}{mm}
{ % #1 = width, #2 = text, with \\ to separate lines
\ebo_bigtext:nn { #1 } { #2 }
}
\seq_new:N \l_ebo_bigtext_text_seq
\box_new:N \l_ebo_bigtext_line_box
\tl_new:N \l_ebo_bigtext_line_tl
\cs_new_protected:Nn \ebo_bigtext:nn
{
\begin{minipage}{#1}
\baselineskip=-\maxdimen \lineskip=4pt
\seq_set_split:Nnn \l_ebo_bigtext_text_seq { \\ } { #2 }
\seq_map_inline:Nn \l_ebo_bigtext_text_seq
{
\hbox_set:Nn \l_ebo_bigtext_line_box { \ebo_bigtext_remsb:n { ##1 } }
\box_resize_to_wd:Nn \l_ebo_bigtext_line_box { \textwidth }
\box_use:N \l_ebo_bigtext_line_box
}
\end{minipage}
}
\cs_new_protected:Nn \ebo_bigtext_remsb:n
{
\tl_set:Nn \l_ebo_bigtext_line_tl { #1 }
\regex_replace_once:nnN { \A(.) } { \c{ebo_kleft:n}\cB\{\1\cE\} } \l_ebo_bigtext_line_tl
\regex_replace_once:nnN { (.)\Z } { \c{ebo_kright:n}\cB\{\1\cE\} } \l_ebo_bigtext_line_tl
\tl_use:N \l_ebo_bigtext_line_tl
}
\cs_new_protected:Nn \ebo_kleft:n
{
\kern-\XeTeXglyphbounds1~\the\XeTeXcharglyph`#1 #1
}
\cs_new_protected:Nn \ebo_kright:n
{
#1\kern-\XeTeXglyphbounds3~\the\XeTeXcharglyph`#1
}
\ExplSyntaxOff
\begin{document}
\noindent
\bigtext{15em}{SOME \\ TOTALLY \\ HIPSTER \\ QUOTE \\ ABOUT \\ LIFE}
\quad
\sffamily
\bigtext{15em}{SOME \\ TOTALLY \\ HIPSTER \\ QUOTE \\ ABOUT \\ LIFE}
\end{document}
Here's one option, just using resizebox
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\newlength\foo
\setlength\foo{15em}
\noindent
\resizebox{\foo}{!}{SOME}\\
\resizebox{\foo}{!}{TOTALLY}\\
\resizebox{\foo}{!}{HIPSTER}\\
\resizebox{\foo}{!}{QUOTE}\\
\resizebox{\foo}{!}{ABOUT}\\
\resizebox{\foo}{!}{LIFE}\\
\end{document}
It's inelegant and cumbersome. But it's a proof of concept. This could be combined with the answers to this question for a more automatic solution.