投影仪中子图中的图形有错误,值缺失,视为零

投影仪中子图中的图形有错误,值缺失,视为零

我正在尝试将类 article 文档中已有的图表放入 overleaf 上的 beamer 演示文稿中。但是,它不起作用。它显示缺少值,视为行 \end{frame} 的 0。可能是缺少包,但缺少哪一个?谢谢!

\documentclass{beamer}
\usetheme{Madrid} % new 
\usepackage{hyperref}
\setbeamercovered{transparent}
\usepackage{subfigure}
\usepackage{graphicx}
\usepackage{amsmath}

\begin{document}

\begin{frame}
\frametitle{Distribution of $W$}

\begin{figure}
\caption{Distribution of the $W$ statistic} \label{w_c}
  \begin{subfigure}{\textwidth}
  \caption{Singh-Madalla with $c=1.7$} \label{w_c_1.7}
  \includegraphics[width=0.23\textwidth]{gini_fim2.pdf}\hfill
  \includegraphics[width=0.23\textwidth]{ge_0_fim2.pdf}\hfill
  \includegraphics[width=0.23\textwidth]{ge_1_fim2.pdf}\hfill
  \includegraphics[width=0.23\textwidth]{ge_2_fim2.pdf}
  \end{subfigure}
  \bigskip
  \begin{subfigure}{\textwidth}
  \caption{Singh-Madalla with $c=1.2$} \label{w_c_1.2}
  \includegraphics[width=0.23\textwidth]{gini_fim12.pdf}\hfill
  \includegraphics[width=0.23\textwidth]{ge0_fim12.pdf}\hfill
  \includegraphics[width=0.23\textwidth]{ge1_fim12.pdf}\hfill
  \includegraphics[width=0.23\textwidth]{ge2_fim_12.pdf}
  \end{subfigure} 
\end{figure}
\end{frame}
\end{document}

答案1

  • 不要使用subfigure,它是过时的包。相反,使用它subcaption包。
  • 一般来说,该包hypperref必须在序言中最后加载,但是,beamer 文档类已经加载了它(参见萨姆卡特在下面的评论中),所以不需要再次加载。
  • 该包也是通过文档类graphicx加载的。beamer

在此处输入图片描述

\documentclass[demo]{beamer}
\usetheme{Madrid} % new
\setbeamercovered{transparent}
\usepackage{subcaption}

\begin{document}

\begin{frame}
\frametitle{Distribution of $W$}

\begin{figure}
\caption{Distribution of the $W$ statistic} \label{w_c}
  \begin{subfigure}{\textwidth}
  \caption{Singh-Madalla with $c=1.7$} \label{w_c_1.7}
  \includegraphics[width=0.23\textwidth, height=22mm]{gini_fim2.pdf}\hfill
  \includegraphics[width=0.23\textwidth, height=22mm]{ge_0_fim2.pdf}\hfill
  \includegraphics[width=0.23\textwidth, height=22mm]{ge_1_fim2.pdf}\hfill
  \includegraphics[width=0.23\textwidth, height=22mm]{ge_2_fim2.pdf}
  \end{subfigure}

  \bigskip
  \begin{subfigure}{\textwidth}
  \caption{Singh-Madalla with $c=1.2$} \label{w_c_1.2}
  \includegraphics[width=0.23\textwidth, height=22mm]{gini_fim12.pdf}\hfill
  \includegraphics[width=0.23\textwidth, height=22mm]{ge0_fim12.pdf}\hfill
  \includegraphics[width=0.23\textwidth, height=22mm]{ge1_fim12.pdf}\hfill
  \includegraphics[width=0.23\textwidth, height=22mm]{ge2_fim_12.pdf}
  \end{subfigure}
\end{figure}
\end{frame}
\end{document}
  • 选项demoin \documentclass[demo]{beamer}被传递给graphics包,在实际文档中必须被删除。这里使用它是因为我们没有实际的图像(它会生成黑色方块来代替它们)。

附录:

  • 由于所有图像都是相同的尺寸,因此可以使用宏大大缩短图形代码\setkeys{Gin}{...}
\begin{figure}
\caption{Distribution of the $W$ statistic} \label{w_c}
\setkeys{Gin}{width=0.23\textwidth, height=22mm}    % <---
  \begin{subfigure}{\textwidth}
  \caption{Singh-Madalla with $c=1.7$} \label{w_c_1.7}
  \includegraphics{gini_fim2.pdf}\hfill
  \includegraphics{ge_0_fim2.pdf}\hfill
  \includegraphics{ge_1_fim2.pdf}\hfill
  \includegraphics{ge_2_fim2.pdf}
  \end{subfigure}

\bigskip
  \begin{subfigure}{\textwidth}
  \caption{Singh-Madalla with $c=1.2$} \label{w_c_1.2}
  \includegraphics{gini_fim12.pdf}\hfill
  \includegraphics{ge0_fim12.pdf}\hfill
  \includegraphics{ge1_fim12.pdf}\hfill
  \includegraphics{ge2_fim_12.pdf}
  \end{subfigure}
\end{figure}

相关内容