Beamer:如何更改迷你框架的颜色

Beamer:如何更改迷你框架的颜色

我想对迷你帧的颜色做以下更改:所有之前的帧几乎都与背景颜色相同,因此方块几乎不可见。当前帧和所有未来帧都采用前景颜色。

    \documentclass{beamer}
    \usetheme{Frankfurt}
    \usecolortheme{dove}
    \setbeamercolor{section in head/foot}{fg=white, bg=black}
\definecolor{dark-gray}{gray}{0.10} %color for the navigation squares


    \makeatletter
\setbeamertemplate{mini frame}
{%
  \begin{pgfpicture}{0pt}{0pt}{.1cm}{.1cm}
    \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\the\beamer@boxsize}{\the\beamer@boxsize}}
    \pgfusepath{fill,stroke}
  \end{pgfpicture}%
}
\setbeamertemplate{mini frame in current subsection}
{%
  \begin{pgfpicture}{0pt}{0pt}{.1cm}{.1cm}
    \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\the\beamer@boxsize}{\the\beamer@boxsize}}
    \pgfsetfillcolor{dark-gray}
    \pgfusepath{fill}
  \end{pgfpicture}%
}

\def\slideentry#1#2#3#4#5#6{%
  %section number, subsection number, slide number, first/last frame, page number, part number
  \ifnum#6=\c@part\ifnum#2>0\ifnum#3>0%
    \ifbeamer@compress%
      \advance\beamer@xpos by1\relax%
    \else%
      \beamer@xpos=#3\relax%
      \beamer@ypos=#2\relax%
    \fi%
  \hbox to 2pt{%
    \beamer@tempdim=-\beamer@vboxoffset%
    \advance\beamer@tempdim by-\beamer@boxsize%
    \multiply\beamer@tempdim by\beamer@ypos%
    \advance\beamer@tempdim by -.05cm%
    \raise\beamer@tempdim\hbox{%
      \beamer@tempdim=\beamer@boxsize%
      \multiply\beamer@tempdim by\beamer@xpos%
      \advance\beamer@tempdim by -\beamer@boxsize%
      \advance\beamer@tempdim by 1pt%
      \kern\beamer@tempdim
      \global\beamer@section@min@dim\beamer@tempdim
      \hbox{\beamer@link(#4){%
          \usebeamerfont{mini frame}%
          \ifnum\c@section=#1%
            \ifnum\c@subsection<#2%
              \usebeamercolor[fg]{mini frame}%
              \ifnum\c@subsectionslide=#3%
                \usebeamertemplate{mini frame}%\beamer@minislidehilight%
              \else%
                \usebeamertemplate{mini frame in current subsection}%\beamer@minisliderowhilight%
              \fi%
            \else%
              \usebeamercolor{mini frame}%
              \color{fg!50!bg}%
              \usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
            \fi%
          \else%
            \usebeamercolor{mini frame}%
            \color{fg!50!bg}%
            \usebeamertemplate{mini frame in other subsection}%\beamer@minislide%
          \fi%
        }}}\hskip-10cm plus 1fil%
  }\fi\fi%
  \else%
  \fakeslideentry{#1}{#2}{#3}{#4}{#5}{#6}%
  \fi\ignorespaces
  }


\setbeamertemplate{footline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{section in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor~~\beamer@ifempty{\insertshortinstitute}{}{(\insertshortinstitute)}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{section in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{section in head/foot}%
    \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
    \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} 
  \end{beamercolorbox}}%
  \vskip0pt%
}
\makeatother

    \begin{document}

        \section{Introduction}
            \subsection{Introduction}   
                \begin{frame}{Frame}
                    1
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    2
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    3
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    4
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    5
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    6
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    7
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    8
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    9
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    10
                \end{frame}                 

        \section{Introduction}
            \subsection{Introduction}   
                \begin{frame}{Frame}
                    11
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    12
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    13
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    14
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    15
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    16
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    17
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    18
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    19
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    20
                \end{frame}

    \end{document}

这是我之前发布的问题的更新:Beamer:如何将迷你镜框从圆形改为矩形,但由于它已经得到回答,而且我怀疑更新后的问题的答案将与原始问题不同,所以我将其作为新问题发布。

答案1

为了将已显示的幻灯片的迷你帧着色为灰色,并将当前和所有未来的帧着色为白色,可以对现有解决方案进行如下修改:

\documentclass{beamer}
\usetheme{Frankfurt}
\usecolortheme{dove}
\setbeamercolor{section in head/foot}{fg=white, bg=black}
\definecolor{dark-gray}{gray}{0.10} %color for the navigation squares

\makeatletter
\setbeamertemplate{mini frame}
{%
  \begin{pgfpicture}{0pt}{0pt}{.1cm}{.1cm}
    \pgfpathrectangle{\pgfpointorigin}{\pgfpoint{\the\beamer@boxsize}{\the\beamer@boxsize}}
    \pgfusepath{fill,stroke}
  \end{pgfpicture}%
}

\def\slideentry#1#2#3#4#5#6{%
  %section number, subsection number, slide number, first/last frame, page number, part number
  \ifnum#6=\c@part\ifnum#2>0\ifnum#3>0%
    \ifbeamer@compress%
      \advance\beamer@xpos by1\relax%
    \else%
      \beamer@xpos=#3\relax%
      \beamer@ypos=#2\relax%
    \fi%
  \hbox to 2pt{%
    \beamer@tempdim=-\beamer@vboxoffset%
    \advance\beamer@tempdim by-\beamer@boxsize%
    \multiply\beamer@tempdim by\beamer@ypos%
    \advance\beamer@tempdim by -.05cm%
    \raise\beamer@tempdim\hbox{%
      \beamer@tempdim=\beamer@boxsize%
      \multiply\beamer@tempdim by\beamer@xpos%
      \advance\beamer@tempdim by -\beamer@boxsize%
      \advance\beamer@tempdim by 1pt%
      \kern\beamer@tempdim
      \global\beamer@section@min@dim\beamer@tempdim
      \hbox{\beamer@link(#4){%
          \usebeamerfont{mini frame}%
          \ifnum\c@section>#1%
            \color{dark-gray}%
          \else%
            \ifnum\c@section=#1%
              \ifnum\c@subsection>#2%
                \color{dark-gray}%
              \else%
                \ifnum\c@subsection=#2%
                  \ifnum\c@subsectionslide>#3%
                    \color{dark-gray}%
                  \else%
                    \color{white}%
                  \fi%
                \else%
                  \color{white}%
                \fi%
              \fi%
            \else%
              \color{white}%
            \fi%
          \fi%
          \usebeamertemplate{mini frame}%
        }}}\hskip-10cm plus 1fil%
  }\fi\fi%
  \else%
  \fakeslideentry{#1}{#2}{#3}{#4}{#5}{#6}%
  \fi\ignorespaces
  }

\setbeamertemplate{footline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{section in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor~~\beamer@ifempty{\insertshortinstitute}{}{(\insertshortinstitute)}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{section in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{section in head/foot}%
    \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
    \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} 
  \end{beamercolorbox}}%
  \vskip0pt%
}
\makeatother

\begin{document}

        \section{Introduction}
            \subsection{Introduction}   
                \begin{frame}{Frame}
                    1
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    2
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    3
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    4
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    5
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    6
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    7
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    8
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    9
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    10
                \end{frame}                 

        \section{Introduction}
            \subsection{Introduction}   
                \begin{frame}{Frame}
                    11
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    12
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    13
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    14
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    15
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    16
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    17
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    18
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    19
                \end{frame}

            \subsection{Introduction}   
                \begin{frame}{Frame}
                    20
                \end{frame}

    \end{document}

第 7 张幻灯片的标题,前几帧显示为灰色,当前和未来的帧显示为白色

解释

在第 39-59 行中决定小帧应为灰色还是白色,其中当前处理的小帧的节、子节和“子节中的帧”编号随后与演示文稿中的实际位置进行比较。这是必要的,因为当前小帧的“绝对”帧编号不可用。

相关内容