Beamer 引用部分、章节、节和小节

Beamer 引用部分、章节、节和小节

我尝试在投影仪演示文稿中正确引用part、、chapter和。sectionsubsection

代码如下:

\documentclass[envcountsect,10pt]{beamer}

\usepackage{chngcntr,xcolor,bbm,placeins,float,latexsym,amsxtra,amssymb,amsbsy,amsthm,amscd,amsfonts,amsmath,subcaption}
\usepackage{etoolbox}

\setbeamertemplate{caption}[numbered]

\counterwithin*{equation}{section}
\counterwithin*{figure}{section}

\setbeamertemplate{bibliography item}{\insertbiblabel}

\usetheme{Antibes}
\AtBeginPart{\frame{\partpage}}
\AtBeginSection{\frame{\sectionpage}}
\AtBeginSubsection{\frame{\subsectionpage}}

\setbeamertemplate{part page}
{
  \begin{centering}
    {\usebeamerfont{part name}\usebeamercolor[fg]{part name}\partname~\insertpartnumber}
    \vskip1em\par
    \begin{beamercolorbox}[sep=16pt,center]{part title}
      \usebeamerfont{part title}\insertpart\par
    \end{beamercolorbox}
  \end{centering}
}

\defbeamertemplate{part page}{mine}[1][]{%
  \begin{centering}
    {\usebeamerfont{part name}\usebeamercolor[fg]{part name}#1}
    \vskip1em\par
    \begin{beamercolorbox}[sep=12pt,center]{part title}
      \usebeamerfont{part title}\insertpart\par
    \end{beamercolorbox}
  \end{centering}
}

\defbeamertemplate{section page}{mine}[1][]{%
  \begin{centering}
    {\usebeamerfont{section name}\usebeamercolor[fg]{section name}#1}
    \vskip1em\par
    \begin{beamercolorbox}[sep=12pt,center]{part title}
      \usebeamerfont{section title}\insertsection\par
    \end{beamercolorbox}
  \end{centering}
}

\defbeamertemplate{subsection page}{mine}[1][]{%
  \begin{centering}
    {\usebeamerfont{subsection name}\usebeamercolor[fg]{subsection name}#1}
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center,#1]{part title}
      \usebeamerfont{subsection title}\insertsubsection\par
    \end{beamercolorbox}
  \end{centering}
}

%\usecolortheme{default}
\setbeamertemplate{theorem}[ams style]
\setbeamertemplate{theorems}[numbered]

\renewcommand{\bibname}{References}

\newtheorem{remark}{\newline Remark}
\newtheorem{proposition}{\newline Proposition}

\numberwithin{section}{part}
\numberwithin{theorem}{section}

\renewcommand\thetheorem{\arabic{part}.\arabic{section}.\arabic{theorem}}
\renewcommand\thelemma{\arabic{part}.\arabic{section}.\arabic{lemma}}
\renewcommand\theproposition{\arabic{part}.\arabic{section}.\arabic{proposition}}
\renewcommand\thedefinition{\arabic{part}.\arabic{section}.\arabic{definition}}
\renewcommand\theproposition{\arabic{part}.\arabic{section}.\arabic{proposition}}
\renewcommand\theremark{\arabic{part}.\arabic{section}.\arabic{remark}}
\renewcommand\theexample{\arabic{part}.\arabic{section}.\arabic{example}}

\makeatletter
\@addtoreset{theorem}{section}
\@addtoreset{remark}{section}
\makeatother

\newenvironment{stepenumerate}{\begin{enumerate}[<+->]}{\end{enumerate}}
\newenvironment{stepitemize}{\begin{itemize}[<+->]}{\end{itemize} }
\newenvironment{stepenumeratewithalert}{\begin{enumerate}[<+-| alert@+>]}{\end{enumerate}}
\newenvironment{stepitemizewithalert}{\begin{itemize}[<+-| alert@+>]}{\end{itemize} }

\renewcommand{\theequation}{\arabic{part}.\arabic{section}.\arabic{equation}}
\renewcommand{\thefigure}{\arabic{part}.\arabic{section}.\arabic{figure}}
\def\stackunder#1#2{\mathrel{\mathop{#2}\limits_{#1}}}

\undef{\lemma}
\undef{\example}
\newtheorem{lemma}{\translate{Lemma}}
\theoremstyle{example}
\newtheorem{example}{\translate{Example}}[section]

\begin{document}

\setbeamertemplate{part page}[mine][Part 1]
\part{\bf A beautiful mind}

\begin{frame}[label=Part1]
This is the content of Part \ref{Part1} and should be printed as \textbf{'Part 1'}.
\end{frame}

\setbeamertemplate{part page}[mine][]
\part{Introduction}

\begin{frame}
This is the Introduction and has no reference.
\end{frame}

\setbeamertemplate{part page}[mine][Chapter 1]
\part{THE FIRST CHAPTER IN THE PRESENTATION}\label{Chapter1}

\begin{frame}
This is Chapter \ref{Chapter1} and should be printed as \textbf{'Chapter 1'}.
\end{frame}

\setbeamertemplate{section page}[mine][]
\section{1.1 The first section in Chapter 1}\label{Section1.1}

\begin{frame}
This is Section \ref{Section1.1} and should be printed as \textbf{'Section 1.1'}.
\end{frame}

\setbeamertemplate{section page}[]
\section{1.2 The second section in Chapter 1}\label{Section1.2}

\begin{frame}
This is Section \ref{Section1.2} and should be printed as \textbf{'Section 1.2'}.
\end{frame}

\setbeamertemplate{part page}[mine][Chapter 2]
\part{THE SECOND CHAPTER IN THE PRESENTATION}\label{Chapter2}
\setcounter{part}{2}

\begin{frame}
This is Chapter \ref{Chapter2} and should be printed as \textbf{'Chapter 2'}.
\end{frame}

\section{2.1 The first section in Chapter 2}\label{Section2.1}

\begin{frame}
This is Section \ref{Section2.1} and should be printed as \textbf{'Section 2.1'}.
\end{frame}

\subsection{The first subsection in Section 2.1}\label{Subsection2.1.1}

\begin{frame}
This is Subsection \ref{Subsection2.1.1} and should be printed as \textbf{'Subsection 2.1.1'}.
\end{frame}

\subsection{The second subsection in Section 2.1}\label{Subsection2.1.2}

\begin{frame}
This is Subsection \ref{Subsection2.1.2} and should be printed as \textbf{'Subsection 2.1.2'}.
\end{frame}

\section{2.2 The second section in Chapter 2}\label{Section2.2}

\begin{frame}
This is Section \ref{Section2.2} and should be printed as \textbf{'Section 2.2'}.
\end{frame}

\setbeamertemplate{part page}[mine][Part 2]
\part{\bf Life Is Beautiful}\label{Part2}

\begin{frame}
This is Part \ref{Part2} and should be referenced as \textbf{'Part 2'}.
\end{frame}

\setbeamertemplate{part page}[mine][Part 3]
\part{\bf Pulp Fiction}\label{Part3}

\begin{frame}
This is Part \ref{Part3} and should be referenced as \textbf{'Part 3'}.
\end{frame}

\setbeamertemplate{part page}[mine][Part 4]
\part{\bf Forrest Gump}\label{Part4}

\begin{frame}
This is Part \ref{Part4} and should be referenced as \textbf{'Part 4'}.
\end{frame}

\end{document}

问题是它们打印不正确,例如,第 1 部分打印为第 2 部分,第 1 章打印为第 3 章,第 1.1 节打印为第 3.1 节,第 1.2 节打印为第 3.2 节,第 2 章打印为第 4 章,第 2.1.1 小节打印为第 1 小节,第 2.1.2 小节打印为第 2 小节,第 2 部分打印为第 3 部分,第 3 部分打印为第 4 部分,第 4 部分打印为第 5 部分。只有第 2.1 节和第 2.2 节引用正确(请参阅附加的屏幕截图)。

任何帮助将非常感激。

在此处输入图片描述 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述

答案1

如果使用\begin{frame}[label=Part1]标签将指向框架,而不是部分。

如果要标记该部分,请将其放置在命令\label{Part1}后面\part{...}


对部分和“章节”使用相同的分段级别必然会造成混乱。

从顶层开始,例如部分,然后从那里向下移动。对于“章节”,您应该使用节,对于节,请使用子节等。



其他一些评论:

  • 无需加载 xcolor、amssymb、amsbsy、amsthm、amsfonts、amsmath 和 etoolbox,beamer 会为您加载它们

  • beamer 没有浮动机制,placeins 和 float 包实际上没有意义,latexsym、amsxtra、

  • 您不应该使用像 这样的双字母字体命令\bf。此外,手动更改每个部分标题的格式也是不好的做法。您可以简单地使用\setbeamerfont{part title}{series=\bfseries}

\documentclass[envcountsect,10pt]{beamer}

\usepackage{chngcntr,
%xcolor,
bbm,
%placeins,float,
latexsym,amsxtra,
%amssymb,amsbsy,amsthm,
amscd,
%amsfonts,amsmath,
subcaption}
%\usepackage{etoolbox}

\setbeamertemplate{caption}[numbered]

\counterwithin*{equation}{section}
\counterwithin*{figure}{section}

\setbeamertemplate{bibliography item}{\insertbiblabel}

\usetheme{Antibes}
\AtBeginPart{\frame{\partpage}}
\AtBeginSection{\frame{\sectionpage}}
\AtBeginSubsection{\frame{\subsectionpage}}

\setbeamertemplate{part page}
{
  \begin{centering}
    {\usebeamerfont{part name}\usebeamercolor[fg]{part name}\partname~\insertpartnumber}
    \vskip1em\par
    \begin{beamercolorbox}[sep=16pt,center]{part title}
      \usebeamerfont{part title}\insertpart\par
    \end{beamercolorbox}
  \end{centering}
}

\defbeamertemplate{part page}{mine}[1][]{%
  \begin{centering}
    {\usebeamerfont{part name}\usebeamercolor[fg]{part name}#1}
    \vskip1em\par
    \begin{beamercolorbox}[sep=12pt,center]{part title}
      \usebeamerfont{part title}\insertpart\par
    \end{beamercolorbox}
  \end{centering}
}

\defbeamertemplate{section page}{mine}[1][]{%
  \begin{centering}
    {\usebeamerfont{section name}\usebeamercolor[fg]{section name}#1}
    \vskip1em\par
    \begin{beamercolorbox}[sep=12pt,center]{part title}
      \usebeamerfont{section title}\insertsection\par
    \end{beamercolorbox}
  \end{centering}
}

\defbeamertemplate{subsection page}{mine}[1][]{%
  \begin{centering}
    {\usebeamerfont{subsection name}\usebeamercolor[fg]{subsection name}#1}
    \vskip1em\par
    \begin{beamercolorbox}[sep=8pt,center,#1]{part title}
      \usebeamerfont{subsection title}\insertsubsection\par
    \end{beamercolorbox}
  \end{centering}
}

%\usecolortheme{default}
\setbeamertemplate{theorem}[ams style]
\setbeamertemplate{theorems}[numbered]

\renewcommand{\bibname}{References}

\newtheorem{remark}{\newline Remark}
\newtheorem{proposition}{\newline Proposition}

\numberwithin{section}{part}
\numberwithin{theorem}{section}

\numberwithin{subsection}{section}

\renewcommand\thetheorem{\arabic{part}.\arabic{section}.\arabic{theorem}}
\renewcommand\thelemma{\arabic{part}.\arabic{section}.\arabic{lemma}}
\renewcommand\theproposition{\arabic{part}.\arabic{section}.\arabic{proposition}}
\renewcommand\thedefinition{\arabic{part}.\arabic{section}.\arabic{definition}}
\renewcommand\theproposition{\arabic{part}.\arabic{section}.\arabic{proposition}}
\renewcommand\theremark{\arabic{part}.\arabic{section}.\arabic{remark}}
\renewcommand\theexample{\arabic{part}.\arabic{section}.\arabic{example}}

\makeatletter
\@addtoreset{theorem}{section}
\@addtoreset{remark}{section}
\makeatother

\newenvironment{stepenumerate}{\begin{enumerate}[<+->]}{\end{enumerate}}
\newenvironment{stepitemize}{\begin{itemize}[<+->]}{\end{itemize} }
\newenvironment{stepenumeratewithalert}{\begin{enumerate}[<+-| alert@+>]}{\end{enumerate}}
\newenvironment{stepitemizewithalert}{\begin{itemize}[<+-| alert@+>]}{\end{itemize} }

\renewcommand{\theequation}{\arabic{part}.\arabic{section}.\arabic{equation}}
\renewcommand{\thefigure}{\arabic{part}.\arabic{section}.\arabic{figure}}
\def\stackunder#1#2{\mathrel{\mathop{#2}\limits_{#1}}}

\undef{\lemma}
\undef{\example}
\newtheorem{lemma}{\translate{Lemma}}
\theoremstyle{example}
\newtheorem{example}{\translate{Example}}[section]

\setbeamerfont{part title}{series=\bfseries}

\newcounter{storepart}

\begin{document}

\part{A beautiful mind}
\label{Part1}

\begin{frame}
This is the content of Part \ref{Part1} and should be printed as \textbf{'Part 1'}.
\end{frame}

\part{Introduction}
\addtocounter{part}{-1}

\begin{frame}
This is the Introduction and has no reference.
\end{frame}

\setcounter{storepart}{\thepart}
\setcounter{part}{0}
\setbeamertemplate{part page}[mine][Chapter 1]
\part{THE FIRST CHAPTER IN THE PRESENTATION}\label{Chapter1}

\begin{frame}
This is Chapter \ref{Chapter1} and should be printed as \textbf{'Chapter 1'}.
\end{frame}

\setbeamertemplate{section page}[mine][]
\section{1.1 The first section in Chapter 1}\label{Section1.1}

\begin{frame}
This is Section \ref{Section1.1} and should be printed as \textbf{'Section 1.1'}.
\end{frame}

\setbeamertemplate{section page}[]
\section{1.2 The second section in Chapter 1}\label{Section1.2}

\begin{frame}
This is Section \ref{Section1.2} and should be printed as \textbf{'Section 1.2'}.
\end{frame}

\setbeamertemplate{part page}[mine][Chapter 2]
\part{THE SECOND CHAPTER IN THE PRESENTATION}\label{Chapter2}
\setcounter{part}{2}

\begin{frame}
This is Chapter \ref{Chapter2} and should be printed as \textbf{'Chapter 2'}.
\end{frame}

\section{2.1 The first section in Chapter 2}\label{Section2.1}

\begin{frame}
This is Section \ref{Section2.1} and should be printed as \textbf{'Section 2.1'}.
\end{frame}

\subsection{The first subsection in Section 2.1}\label{Subsection2.1.1}

\begin{frame}
This is Subsection \ref{Subsection2.1.1} and should be printed as \textbf{'Subsection 2.1.1'}.
\end{frame}

\subsection{The second subsection in Section 2.1}\label{Subsection2.1.2}

\begin{frame}
This is Subsection \ref{Subsection2.1.2} and should be printed as \textbf{'Subsection 2.1.2'}.
\end{frame}

\section{2.2 The second section in Chapter 2}\label{Section2.2}

\begin{frame}
This is Section \ref{Section2.2} and should be printed as \textbf{'Section 2.2'}.
\end{frame}

\setcounter{part}{\thestorepart}
\setbeamertemplate{part page}[mine][Part 2]
\part{Life Is Beautiful}\label{Part2}

\begin{frame}
This is Part \ref{Part2} and should be referenced as \textbf{'Part 2'}. 
\end{frame}

\setbeamertemplate{part page}[mine][Part 3]
\part{Pulp Fiction}\label{Part3}

\begin{frame}
This is Part \ref{Part3} and should be referenced as \textbf{'Part 3'}.
\end{frame}

\setbeamertemplate{part page}[mine][Part 4]
\part{Forrest Gump}\label{Part4}

\begin{frame}
This is Part \ref{Part4} and should be referenced as \textbf{'Part 4'}.
\end{frame}

\end{document}

在此处输入图片描述

相关内容