ビーマー内のページ総数をカウンターとして使用する

ビーマー内のページ総数をカウンターとして使用する

私はLaTeXでページの総数をカウントしようとしています:

\newcount\mypagecount
\mypagecount=\insertpresentationendpage

しかし、これを実行すると、ページ数をカウントとして入力するのではなく、合計ページ数が自動的に「印刷」されます。カウントとして設定する方法はありますか?

私がやろうとしていることをより正確に言えば、次のようになります。

\newcount\mypagenum
\newcount\mypagecount
\newdimen\barwidth

\mypagenum=\insertpagenumber
\mypagecount=\insertpresentationendpage
\barwidth=\paperwidth

\multiply\barwidth by \mypagenum                                       
\divide\barwidth by \mypagecount

カウンターを試してみましたが、やはりエラーが発生しました:

\newcounter{mypagecount}
\setcounter{mypagecount}{\insertpresentationendpage}

これらの数字を使用できない場合、最後にどのように割り算を行えばよいか、また、実際にこれらの数字をどのように使用すればよいかについて、何かアイデアはありますか?

答え1

以下は、\insertpresentationendpageの現在のバージョンと基本的に同じことを行いますbeamerが、結果が印刷されるのではなく、カウンターが設定されるという点が異なります。概念実証の進行状況バー出力も含めました。

\documentclass[]{beamer}

\newlength\barwidth
\newlength\tmpbarwidth
\newcount\mypagecount

\makeatletter
\newcommand*\progressbar
  {%
    \ifnum\mypagecount=0
      \ifx\beamer@startpageofappendix\@empty
        \mypagecount=\beamer@endpageofdocument\relax
      \else
        \mypagecount=\beamer@startpageofappendix\relax
        \advance\mypagecount\m@ne
      \fi
      \ifnum\mypagecount=0
        \global\mypagecount=1
      \else
        \global\mypagecount=\mypagecount
      \fi
    \fi
    \begingroup
      \tmpbarwidth\insertpagenumber\barwidth
      \divide\tmpbarwidth\mypagecount
      \rule{\tmpbarwidth}{5pt}%
      \advance\barwidth-\tmpbarwidth
      \textcolor{gray}{\rule{\barwidth}{5pt}}%
    \endgroup
  }
\makeatother

\setlength\barwidth{5cm}

\begin{document}
\begin{frame}
  \progressbar
\end{frame}
\begin{frame}
  \progressbar
\end{frame}
\begin{frame}
  \progressbar
\end{frame}
\begin{frame}
  \progressbar
\end{frame}

\end{document}

関連情報