在 beamer 中将 \insertappendixendpage 转换为 Roman

在 beamer 中将 \insertappendixendpage 转换为 Roman

我希望在附录部分中为当前页数和总页数(即在幻灯片的页脚中)添加罗马页码(而不是框架码),我想要:

1/4, 2/4, 3/4, 4/4
% appendix starts here
I/III, II/III, III/III

类似的问题也曾在问题,但附录中缺少总页数,即仅给出了I II III

这是我的代码:

% !TeX program = lualatex
\documentclass[aspectratio=169,t]{beamer}
\usetheme{Malmoe}
\usecolortheme{beaver}

\setbeamertemplate{navigation symbols}{}

% select page indicator style
\newcommand{\pagetracker}{%
    \insertpagenumber{} / \insertpresentationendpage%
}

\setbeamertemplate{footline}{
    \hfill\pagetracker\hspace*{1ex}
}

\usepackage{appendixnumberbeamer}

% switch to Roman numbering in appendix
\makeatletter
\g@addto@macro\appendix{
    \pagenumbering{Roman}
    \renewcommand*{\pagetracker}{%
        \insertpagenumber{} / \insertappendixendpage%
    }%
}%
\makeatother

\begin{document}
    
    \begin{frame}
        \only<1>{A1}
        \only<2>{A2}
    \end{frame}

    \begin{frame}
        \only<1>{B1}
        \only<2>{B2}
    \end{frame}

    \appendix
    
    \begin{frame}
        \only<1>{Appendix C1}
        \only<2>{Appendix C2}
    \end{frame}

    \begin{frame}
        \only<1>{Appendix D1}
        \only<2>{Appendix D2}
    \end{frame} 

    \begin{frame}
        \only<1>{Appendix E1}
        \only<2>{Appendix E2}
    \end{frame}
        
\end{document}
    

我怎样才能将输出转换为\insertappendixendpage罗马数字以使其正常工作?

答案1

% !TeX program = lualatex
\documentclass[aspectratio=169,t]{beamer}
\usetheme{Malmoe}
\usecolortheme{beaver}

\setbeamertemplate{navigation symbols}{}

% select page indicator style
\newcommand{\pagetracker}{%
    \insertpagenumber{} / \insertpresentationendpage%
}

\setbeamertemplate{footline}{
    \hfill\pagetracker\hspace*{1ex}
}

\usepackage{appendixnumberbeamer}

% switch to Roman numbering in appendix
\makeatletter
\g@addto@macro\appendix{
    \setcounter{page}{1}
    \renewcommand*{\pagetracker}{%
        \@Roman{\value{page}} / \@Roman{\beamer@endpageofdocument}%
    }%
}%
\makeatother

\begin{document}
    
    \begin{frame}
        \only<1>{A1}
        \only<2>{A2}
    \end{frame}

    \begin{frame}
        \only<1>{B1}
        \only<2>{B2}
    \end{frame}

    \appendix
    
    \begin{frame}
        \only<1>{Appendix C1}
        \only<2>{Appendix C2}
    \end{frame}

    \begin{frame}
        \only<1>{Appendix D1}
        \only<2>{Appendix D2}
    \end{frame} 

    \begin{frame}
        \only<1>{Appendix E1}
        \only<2>{Appendix E2}
    \end{frame}
        
\end{document}
    

相关内容