I am really new to LaTeX/beamer, and now I am coming into this question:
In MS powerpoint, when a textbox is filled it can automatically shrink the font size, instead of going over the page.
Is there a way that in beamer we can also do this?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI am really new to LaTeX/beamer, and now I am coming into this question:
In MS powerpoint, when a textbox is filled it can automatically shrink the font size, instead of going over the page.
Is there a way that in beamer we can also do this?
Use shrink=0 ... 100
in the frame option to shrink everything by n percent of a frame, as displayed below.
\documentclass{beamer}
\usepackage{lipsum}
\begin{document}
\begin{frame}[shrink=50] % shrink 50 percent
\lipsum[2]
\end{frame}
\end{document}
beamer
documentation mentions (p 35, 62) "Never use a smaller font size to “fit more on a frame.” Never ever use the evil option shrink
". One can't just choose any number up to 100...
\small
or \fontsize{...}{...}\selectfont
, but that doesn't preserve the layout, i.e., doesn't scale distances accordingly. This one does. I understand that shrink
is considered "evil", but for "evil" use cases (e.g., my bibliography), I find it very useful.
If you don't need to shrink the whole frame but just a box in it, you can use fitting
library from tcolorbox
package:
Next example is taken from tcolorbox
manual adapted to beamer
:
\documentclass{beamer}
\usepackage{tcolorbox}
\tcbuselibrary{fitting}
\usepackage{lipsum}
\tcbset{colframe=blue!50!black,colback=red!10!white,
boxsep=0pt,top=1mm,bottom=1mm,left=1mm,right=1mm,
nobeforeafter,width=\linewidth}
\begin{document}
\begin{frame}{Shrinking with \texttt{tcolorbox}}
\begin{columns}[totalwidth=\textwidth]
\begin{column}{.45\textwidth}
\tcboxfit[height=8cm]{\lipsum[1]}
\end{column}
\begin{column}{.45\textwidth}
\tcboxfit[height=4cm]{\lipsum[1]}\\
\tcboxfit[height=3cm]{\lipsum[1]}
\end{column}
\end{columns}
\end{frame}
\end{document}
beamer
already loads graphicx
which you can use to resize content:
\documentclass{beamer}% http://ctan.org/pkg/beamer
\let\Tiny\tiny% http://tex.stackexchange.com/q/58087/5764
\begin{document}
\begin{frame}
This is some very long text that should span at least two lines on this frame.
\resizebox{\linewidth}{!}{This is some very long text that should span at least two lines on this frame.}
\resizebox{\linewidth}{!}{%
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur at aliquam massa. Pellentesque
habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut non elit a neque
ullamcorper vulputate. Cras faucibus porta tellus, nec vulputate nibh. Morbi ut orci et augue euismod
ornare non quis diam. Maecenas ac diam eget neque porttitor tempor et at tortor. Sed sit amet varius
tortor. Suspendisse potenti. Proin lacus odio, porta id nunc non, feugiat sagittis lorem. Vestibulum
non nibh purus. Duis leo magna, posuere sed viverra vel, scelerisque a ligula. Sed ullamcorper orci
eu justo ullamcorper tristique.%
}
\resizebox{\linewidth}{!}{Here is some text.}
\end{frame}
\end{document}
\resizebox{<width>}{<height>}{<stuff>}
is used to fit <stuff>
inside a box of width <width>
(and/or height <height>
). If either of these lengths are !
, <stuff>
is sized in a way that maintains the aspect ratio.
Note that this approach will always make <stuff>
fit within \linewidth
(either shrinking or enlarging).