コード

コード

私は Beamer を使用してプレゼンテーションを行っていますが、かなり長いです。プレゼンテーションはセクションに分かれており、各セクションの最後に休憩を取ります。したがって、現在のスライドのカウンターを 2 つ表示したいと思います。たとえば、現在セクション 2 (20 枚のスライドで構成) の 3 番目のスライドを表示していて、セクション 1 が 50 枚のスライドで構成されているとすると、最初のカウンターは 3/20 になり、2 番目のカウンターは 53/70 になります (セクションが 2 つしかない場合)。

これが私の作業環境です:

\documentclass[t,10pt,xcolor=dvipsnames]{beamer}
 \mode<presentation>
 {
 \usetheme{AnnArbor}
 \setbeamercovered{transparent}
\useinnertheme{rounded}
   \usecolortheme{spruce}
 }

  \setbeamercolor{section in head/foot}{fg=White}
\section{Sec1}
\subsection{Sub 1}
\begin{frame}{Fra 1}
\end{frame}
\begin{frame}{Fra 2}
\end{frame}
\begin{frame}{Fra 3}
\end{frame}
\section{Sec2}
\subsection{Sub 1}
\begin{frame}{Fra 1}
\end{frame}
\begin{frame}{Fra 2}
\end{frame}
\end{document}

何か助けて?

答え1

新しいカウンターは必要ありません。少し計算するだけです。Beamerは、セクションの開始と終了のページ番号をマクロとに保存します\insertsectionstartpage\insertsectionendpageしたがって、セクション内のページ数は次のように計算できます。

\insertsectionendpage-\insertsectionstartpage+1

セクション内のページ番号は

\insertframenumber-\insertsectionstartpage+1

\insertframenumber現在のフレームのページ番号が格納されます。

\patchcmdこれらを、パッケージからetoolbox、フッターラインを挿入する Beamer コマンドにパッチ適用する\beamer@@tmpl@footlineと、フッターラインの左側にセクション ページ カウンター、右側に全体のページ カウンターが表示されます。

コード

\documentclass[t,10pt,xcolor=dvipsnames]{beamer}

\usepackage{etoolbox}

\mode<presentation>
{
  \usetheme{AnnArbor}
  \setbeamercovered{transparent}
  \useinnertheme{rounded}
  \usecolortheme{spruce}
}
\setbeamercolor{section in head/foot}{fg=White}

\makeatletter
% change author box alignment 
\patchcmd{\beamer@@tmpl@footline}% <cmd>
  {center}% <search>
  {left}% <replace>
  {}% <success>
  {}% <failure>

% add page to author box
\patchcmd{\beamer@@tmpl@footline}% <cmd>
  {\usebeamerfont{author in head/foot}\insertshortauthor\expandafter\beamer@ifempty\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)}}% <search>
  {\def\sectotpage{\number\numexpr\insertsectionendpage-\insertsectionstartpage+1}%
   \def\pageinsec{\number\numexpr\insertframenumber-\insertsectionstartpage+1}%
   \rlap{\hspace*{2ex}\pageinsec{} / \sectotpage} \hfill
  \usebeamerfont{author in head/foot}\insertshortauthor\expandafter\beamer@ifempty\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)}}% <replace>
  {}% <success>
  {}% <failure>
\makeatother

\author{Author}

\begin{document}
\newcommand\nf{\frame{Frame in Section~\thesection.}}

\section{Sec 1}
\nf\nf\nf\nf\nf

\section{Sec 2}
\nf\nf\nf\nf\nf\nf

\section{Sec 3}
\nf\nf\nf\nf\nf\nf\nf

\end{document}

出力

ここに画像の説明を入力してください

関連情報