9

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?

11

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}
  • The 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... – Werner Nov 17 '13 at 14:22
  • 1
    @Werner -- I read the passage. The user guide also mentions that don't use footnote and allowframebreaks etc, etc. My understanding of those are for typographic reason. However, on page 65, the manual does recommend starting from 5,10, gradually to use this option. Its design is meant for marginal case IMHO. – Jesse Nov 17 '13 at 14:39
  • 1
    Finally this is a useful answer: I've seem semilar answers where they recommend using \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. – srs Oct 17 '16 at 9:41
  • @rainmaker Thanks for sharing your case. Feeling great to know it is useful to you. :-) – Jesse Oct 17 '16 at 11:01
5

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}

enter image description here

4

beamer already loads graphicx which you can use to resize content:

enter image description here

\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).

  • Thank you so much @Werner! Both answers are really helpful, and I voted for Jesse's because I am currently dealing with multi-line itemized stuff, so hers happens more applicable. But I really appreciate your answer too and it is exactly as useful! – Shawn Wang Nov 17 '13 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.