我正在使用文档类“beamer”在 LaTeX 中创建演示文稿。我的演示文稿包含大量图片(超过 26 张)。LaTeX 文档编译正确,直到图片数量少于 26 张。后来,我开始收到错误“计数器太大”。我正在使用包“graphixc”和“subfig”。我可以获得该包的信息阿尔法可以使用。但是,我无法正确使用它?我该如何修复此错误,以便我可以将我的所有图表都包含在演示文稿中?随函附上最小工作示例 (MWE)。提前感谢您。
\documentclass{beamer}
\mode<presentation> {
\usetheme{Madrid}
}
\usepackage{graphicx} % Allows including images
\usepackage{subfig}
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{natbib}
\usepackage{hyperref}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{gensymb}
\usepackage{alphalph}
\usepackage{etoolbox}
\newcommand{\alphalphval}[1]{\alphalph{\value{#1}}}
\AtBeginDocument{%
\AtBeginEnvironment{subfloat}{%
\let\alph\alphalphval%
}
}
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
\title[SAR-MS Fusion]{Pre-synopsis Seminar} % The short title appears at the bottom of every slide, the full title is only on the title page
\author{\small Samadhan C. Kulkarni} % Your name
\institute[College of Engineering, Pune]
{
College of Engineering, Pune \\ % Your institution for the title page
\medskip
}
\begin{document}
\begin{frame}
\titlepage % Print the title page as the first slide
\end{frame}
\begin{frame}[allowframebreaks=0.7]
\frametitle{Overview}
\vspace{-6 mm} % Table of contents slide, comment this block out to remove it
\tableofcontents % Throughout your presentation, if you choose to use \section{} and \subsection{} commands, these will automatically be printed on this slide as an overview of your presentation
\end{frame}
\section{Introduction}
\subsection{Definition}
\begin{frame}
\graphicspath{{D:/Figures/}}
\begin{figure}
\subfloat[Noisy Image]{
%\includegraphics[width=28mm, height=28mm]{H_HV_clip9Nov_noisy.png}
\includegraphics[scale=0.1]{coep_logo.jpg}
}\hspace{4mm}
\subfloat[Subset]{
\includegraphics[scale=0.1]{coep_logo.jpg}
}\hspace{4mm}
\end{figure}
\end{frame}
\begin{frame}
\Huge{\centerline{The End}}
\end{frame}
\end{document}
答案1
看来您喜欢用字母对图片进行编号,为此您使用了subfig
标题。要将编号扩展到 26 个(子)图片,您只需进行\thesubfig
相应定义:
\renewcommand\thesubfigure{\alphalph{\value{subfigure}}}
无关:文档类beamer
加载包graphics
和hyperref
,所以您不需要再次加载它们。
完成 MWE:
\documentclass[demo]{beamer}
\mode<presentation> {
\usetheme{Madrid}
}
\graphicspath{{D:/Figures/}}
\usepackage{alphalph}
\usepackage{subfig}
\renewcommand\thesubfigure{\alphalph{\value{subfigure}}}
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{natbib}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{gensymb}
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
\title[SAR-MS Fusion]{Pre-synopsis Seminar} % The short title appears at the bottom of every slide, the full title is only on the title page
\author{\small Samadhan C. Kulkarni} % Your name
\institute[College of Engineering, Pune]
{
College of Engineering, Pune \\ % Your institution for the title page
\medskip
}
\begin{document}
\begin{frame}
\titlepage % Print the title page as the first slide
\end{frame}
\begin{frame}[allowframebreaks]
\frametitle{Overview}
\tableofcontents % Throughout your presentation, if you choose to use \section{} and \subsection{} commands, these will automatically be printed on this slide as an overview of your presentation
\end{frame}
\section{Introduction}
\subsection{Definition}
\setcounter{subfigure}{25} % <--- remove in real document
\begin{frame}
\begin{figure}
\subfloat[Noisy Image]{
\includegraphics[scale=0.1]{coep_logo.jpg}
}\hfil
\subfloat[Subset]{
\includegraphics[scale=0.1]{coep_logo.jpg}
}
\end{figure}
\end{frame}
\begin{frame}
\Huge{\centerline{The End}}
\end{frame}
\end{document}
附录:
在您的评论之后,您不再完全清楚您喜欢如何对标题进行编号。现在我看到两种可能性:
- 标题已编号,但没有标题标签(例如“图”)
\documentclass[demo]{beamer}
\mode<presentation>
{
\usetheme{Madrid}
%----------------------------------------------------------------------------------------
% FIGURE STYLE
%----------------------------------------------------------------------------------------
\setbeamertemplate{caption}{(\insertcaptionnumber)\ \insertcaption} % <---
\setbeamerfont{caption}{size=\footnotesize} % <---
}
\graphicspath{{D:/Figures/}}
\usepackage{booktabs,
tabularx} % new
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage{natbib}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{gensymb}
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
\title[SAR-MS Fusion]{Pre-synopsis Seminar}
\author{\small Samadhan C. Kulkarni} % Your name
\institute[College of Engineering, Pune]
{
College of Engineering, Pune \\
\medskip
}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}[allowframebreaks]
\frametitle{Overview}
\tableofcontents
\end{frame}
\section{Introduction}
\subsection{Definition}
\begin{frame}
\begin{figure}
\begin{tabularx}{\linewidth}{CC}
\includegraphics[scale=0.1]{coep_logo.jpg}
\caption{Noisy Image}
&
\includegraphics[scale=0.1]{coep_logo.jpg}
\caption{Subset}
\end{tabularx}
\end{figure}
\end{frame}
\begin{frame}
\begin{figure}
\begin{tabularx}{\linewidth}{CC}
\includegraphics[scale=0.1]{coep_logo.jpg}
\caption{Whatever}
&
\includegraphics[scale=0.1]{coep_logo.jpg}
\caption{Figure 4}
\end{tabularx}
\end{figure}
\end{frame}
\end{document}
结果是:
-
- 带有编号标签的标题。在这种情况下,您需要将上面的 MWE 替换
\setbeamertemplate{caption}{(\insertcaptionnumber)\ \insertcaption}
为:
- 带有编号标签的标题。在这种情况下,您需要将上面的 MWE 替换
\setbeamertemplate{caption}[numbered]
它的编译结果是:
笔记:
- 正如您所看到的,两种情况下的图像都被插入到
tabularx
表格环境中。 - 如果您仍然希望在某些图中使用子图,那么您需要在上面的 MWE 中在序言中加载包
subfig
,然后使用它,例如:
\begin{frame}
\begin{figure}
\subfloat[Noisy Image]{\includegraphics[scale=0.1]{coep_logo.jpg}}
\hfil
\subfloat[Subset]{\includegraphics[scale=0.1]{coep_logo.jpg}}
%
\caption{Figure with two sub figures}
\end{figure}
\end{frame}