5

I want to make figures bigger in subfigures, but scale does not work when I use width. Code

\documentclass{beamer}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{frame}[allowframebreaks]
% http://tex.stackexchange.com/a/37597/13173
% http://tex.stackexchange.com/a/164778/13173
\begin{figure}
\centering
\begin{subfigure}{.5\textwidth}
\includegraphics[page=1,width=.4\textwidth]{Rplots_male.pdf}
\caption{Cor males.}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\includegraphics[page=2,width=0.4\textwidth]{Rplots_male.pdf}
\caption{Cor new ECG males.}
\end{subfigure}
\end{figure}
\end{frame}

\end{document}

Output

enter image description here

Unsuccessful attempt to control the size of the figure

\includegraphics[page=1,width=.4\textwidth,scale=1.2]{Rplots_male.pdf}

OS: Debian 8.5
TeXLive: 2016

Andrew Swann
  • 95,762

2 Answers2

9

\textwidth or \linewidth refers to the width of the subfigure, not to the absolute text width. Therefore, .4\textwidth inside .2\textwidth becomes 20 % of the text width.

The maximum width is \textwidth:

\documentclass{beamer}

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{frame}[allowframebreaks]
% http://tex.stackexchange.com/a/37597/13173
% http://tex.stackexchange.com/a/164778/13173
\begin{figure}
\centering
\begin{subfigure}{.5\textwidth}
\includegraphics[page=1,width=\textwidth]{example-image-a}
\caption{Cor males.}
\end{subfigure}%
\begin{subfigure}{0.5\textwidth}
\includegraphics[page=2,width=\textwidth]{example-image-a}
\caption{Cor new ECG males.}
\end{subfigure}
\end{figure}
\end{frame}

\end{document}

Result

Heiko Oberdiek
  • 271,626
  • Very nice idea! I have always used scale manually for such basic thing, saves so much time now on. - - Is there anything similar for height=\pageheight? - - I would like to have four such figures in one page. – Léo Léopold Hertz 준영 Nov 07 '16 at 19:38
  • 1
    @Masi The height is usually more complicate because the height of other elements need to be taken into account, such as the caption text, text/title before the figure. – Heiko Oberdiek Nov 07 '16 at 19:41
5

Some comments, in no particular order:

  • Inside a subfigure environment of a given width -- say, 0.5\textwidth -- the widths of \textwidth and \linewidth are relative to the width of the entire subfigure.

  • No need to load the graphicx package explicitly if you use the beamer document class.

  • The subcaption package loads the caption package automatically.

  • I suggest that you set the widths of the subfigure environments to something like 0.45\textwidth and that you maximize the horizontal distance between them via an \hfill directive. Inside each subfigure, set the width of the image file to \linewidth.

enter image description here

\documentclass[demo]{beamer} % remove 'demo' option in real document
%\usepackage{graphicx} % is loaded automatically by beamer class
\usepackage{subcaption} % loads 'caption' automatically

\begin{document}
\begin{frame}[allowframebreaks]

\begin{figure}
\begin{subfigure}{0.45\textwidth}
\includegraphics[page=1,width=\linewidth]{Rplots_male}
\caption{Cor males.}
\end{subfigure}
\hfill % maximize the separation between the two graphs
\begin{subfigure}{0.45\textwidth}
\includegraphics[page=2,width=\linewidth]{Rplots_male}
\caption{Cor new ECG males.}
\end{subfigure}
\end{figure}

\end{frame}
\end{document}
Mico
  • 506,678