![投影仪中子图中的图形有错误,值缺失,视为零](https://linux22.com/image/345069/%E6%8A%95%E5%BD%B1%E4%BB%AA%E4%B8%AD%E5%AD%90%E5%9B%BE%E4%B8%AD%E7%9A%84%E5%9B%BE%E5%BD%A2%E6%9C%89%E9%94%99%E8%AF%AF%EF%BC%8C%E5%80%BC%E7%BC%BA%E5%A4%B1%EF%BC%8C%E8%A7%86%E4%B8%BA%E9%9B%B6.png)
我正在尝试将类 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}
- 选项
demo
in\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}