获取整个演示文稿中每张幻灯片的编号和幻灯片总数

获取整个演示文稿中每张幻灯片的编号和幻灯片总数

我需要获取每张幻灯片的编号和幻灯片总数,以便计算演示的进度,但我只能对帧执行此操作,如下面的 MWE 所示。

基本上,我需要能够?用实际的表达来替换下面的内容。

附言:我也无法显示 c@ratio 的值。任何帮助都将不胜感激。

\documentclass{beamer}

\makeatletter
\def\c@counter{} 
\newcount\c@counta
\newcount\c@countb
\newdimen\c@ratio

% counter
\def\c@counter{%

    \c@counta=\insertframenumber
    \c@countb=\inserttotalframenumber
    \c@ratio=\c@counta
    \divide\c@ratio by \c@countb

    }
\makeatother

\begin{document}

\begin{frame}{title 1}

\only<1>{

This is the \the\c@ratio \% of frames and the ? \% of slides

This is Frame number \insertframenumber, and Slide number ?}

\only<2>{

This is the \the\c@ratio \% of frames and the ? \% of slides

This is Frame number \insertframenumber, and Slide number ?}

\end{frame}

\begin{frame}{title 2}

\only<1>{

This is the \the\c@ratio \% of frames and the ? \% of slides

This is Frame number \insertframenumber, and Slide number ?}

\only<2>{

This is the \the\c@ratio \% of frames and the ? \% of slides

This is Frame number \insertframenumber, and Slide number ?}

\end{frame}

\end{document}

答案1

这将给出当前页面与总页数的比例:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}

\def\insertframeratio{%
    \pgfmathparse{\insertframenumber*100/\inserttotalframenumber}%
    \pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}\,\% %
}

\def\insertpageratio{%
    \pgfmathparse{\insertpagenumber*100/\insertdocumentendpage}%
    \pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}\,\% %
}

\begin{document}

\begin{frame}{title 1}
    \only<1>{
        Frames: \insertframenumber{} of \inserttotalframenumber: \insertframeratio\\
        Page: \insertpagenumber{} of \insertdocumentendpage: \insertpageratio
    }
    \only<2>{
        Frames: \insertframenumber{} of \inserttotalframenumber: \insertframeratio\\
        Page: \insertpagenumber{} of \insertdocumentendpage: \insertpageratio
    }
\end{frame}

\begin{frame}{title 2}
    \only<1>{
        Frames: \insertframenumber{} of \inserttotalframenumber: \insertframeratio\\
        Page: \insertpagenumber{} of \insertdocumentendpage: \insertpageratio
    }
    \only<2>{
        Frames: \insertframenumber{} of \inserttotalframenumber: \insertframeratio\\
        Page: \insertpagenumber{} of \insertdocumentendpage: \insertpageratio
    }
\end{frame}

\end{document}

以防万一有人想计算框架内幻灯片的比例:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}

\def\insertframeratio{%
    \pgfmathparse{\insertframenumber*100/\inserttotalframenumber}%
    \pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}\,\% %
}

\def\insertpageratio{%
    \pgfmathparse{\insertpagenumber*100/\insertdocumentendpage}%
    \pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}\,\% %
}

\def\insertslideratio{%
    \pgfmathparse{(\insertpagenumber-\insertframestartpage+1)*100/(\insertframeendpage-\insertframestartpage+1)}%
    \pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}\,\% %
}

\def\insertslides{%
    \pgfmathparse{\insertframeendpage-\insertframestartpage+1}%
    \pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}%
}

\def\inserttheslide{%
    \pgfmathparse{\insertpagenumber-\insertframestartpage+1}%
    \pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}%
}


\begin{document}

\begin{frame}{title 1}
    \only<1>{
        Slide in Frame: \inserttheslide{} of \insertslides: \insertslideratio\\
        Frames: \insertframenumber{} of \inserttotalframenumber: \insertframeratio\\
        Page: \insertpagenumber{} of \insertdocumentendpage: \insertpageratio
    }
    \only<2>{
        Slide in Frame: \inserttheslide{} of \insertslides: \insertslideratio\\
        Frames: \insertframenumber{} of \inserttotalframenumber: \insertframeratio\\
        Page: \insertpagenumber{} of \insertdocumentendpage: \insertpageratio
    }
\end{frame}

\begin{frame}{title 2}
    \only<1>{
        Slide in Frame: \inserttheslide{} of \insertslides: \insertslideratio\\
        Frames: \insertframenumber{} of \inserttotalframenumber: \insertframeratio\\
        Page: \insertpagenumber{} of \insertdocumentendpage: \insertpageratio
    }
    \only<2>{
        Slide in Frame: \inserttheslide{} of \insertslides: \insertslideratio\\
        Frames: \insertframenumber{} of \inserttotalframenumber: \insertframeratio\\
        Page: \insertpagenumber{} of \insertdocumentendpage: \insertpageratio
    }
\end{frame}

\end{document}

在此处输入图片描述

相关内容