Beamer: 섹션 제목과 함께 진행 표시줄을 추가하는 방법은 무엇입니까?

Beamer: 섹션 제목과 함께 진행 표시줄을 추가하는 방법은 무엇입니까?

많은 프레젠테이션에는 청취자가 프레젠테이션이 얼마나 진행되었는지 쉽게 확인할 수 있는 일종의 시각화 기능이 포함되어 있습니다.

이를 위한 가장 좋은 옵션은 progress bar슬라이드 레이아웃에 를 추가하는 것입니다.


최소 작업 예(MWE):

사용자곤잘로 메디나선 위에 삼각형을 표시하는 방법에 대한 좋은 접근 방식을 게시했습니다.

사용자 Gonzalo Medina의 코드 스크린샷

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

\definecolor{pbgray}{HTML}{575757}% background color for the progress bar

\makeatletter
\def\progressbar@progressbar{} % the progress bar
\newcount\progressbar@tmpcounta% auxiliary counter
\newcount\progressbar@tmpcountb% auxiliary counter
\newdimen\progressbar@pbht %progressbar height
\newdimen\progressbar@pbwd %progressbar width
\newdimen\progressbar@tmpdim % auxiliary dimension

\progressbar@pbwd=\linewidth
\progressbar@pbht=1pt

% the progress bar
\def\progressbar@progressbar{%

    \progressbar@tmpcounta=\insertframenumber
    \progressbar@tmpcountb=\inserttotalframenumber
    \progressbar@tmpdim=\progressbar@pbwd
    \multiply\progressbar@tmpdim by \progressbar@tmpcounta
    \divide\progressbar@tmpdim by \progressbar@tmpcountb

  \begin{tikzpicture}[very thin]
    \draw[pbgray!30,line width=\progressbar@pbht]
      (0pt, 0pt) -- ++ (\progressbar@pbwd,0pt);
    \draw[draw=none]  (\progressbar@pbwd,0pt) -- ++ (2pt,0pt);

    \draw[fill=pbgray!30,draw=pbgray] %
       ( $ (\progressbar@tmpdim, \progressbar@pbht) + (0,1.5pt) $ ) -- ++(60:3pt) -- ++(180:3pt) ;

    \node[draw=pbgray!30,text width=3.5em,align=center,inner sep=1pt,
      text=pbgray!70,anchor=east] at (0,0) {\insertframenumber/\inserttotalframenumber};
  \end{tikzpicture}%
}

\addtobeamertemplate{headline}{}
{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=5ex,center,dp=1ex]{white}%
    \progressbar@progressbar%
  \end{beamercolorbox}%
}
\makeatother

\begin{document}

    \section{Introduction}

        \begin{frame}
            \frametitle{Introduction}
            test
        \end{frame}

    \section{Motivation}

        \begin{frame}
            \frametitle{Motivation}
            test
        \end{frame}

    \section{Methodology}

        \begin{frame}
            \frametitle{Experiments}
            test
        \end{frame}

        \begin{frame}
            \frametitle{Statistics}
            test
        \end{frame}

    \section{Results}

        \begin{frame}
            \frametitle{Results 1}
            test
        \end{frame}

        \begin{frame}
            \frametitle{Results 2}
            test
        \end{frame}

    \section{Conclusion}

        \begin{frame}
            \frametitle{Conclusion}
            test
        \end{frame}

\end{document}

질문:

section titles정말 좋아 보이지만 타임라인에도 추가하고 싶습니다 .

원하는 진행률 표시줄의 스크린샷

이로써 다음을 볼 수 있습니다:

  • 소개그리고동기 부여이미 제시되었습니다
  • 방법론현재 제시되고 있다
  • 결과그리고결론나중에 선보일 예정

섹션 제목이 타임라인에도 표시되도록 코드를 확장할 수 있습니까?

답변1

시간이 꽤 흘렀다는 건 알지만, 나에게 자유 시간을 제공해준 이곳 프랑스의 봉쇄 조치를 비난해도 좋다...

나는 Gonzalo Medina의 제안에서 시작하여 그 주위에 누락된 것들을 구축했습니다. 나는 이것이 LaTeX로 해본 일 중 가장 어려운 일이라고 생각합니다. 귀하의 질문에 감사드립니다. 이 답변을 준비하면서 많은 것을 배웠습니다.

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc,patterns.meta}
% To provide total amount of sections throughout the document
\usepackage{totcount}
% Registers de total amount of sections (see https://tex.stackexchange.com/a/192506/141947)
\regtotcounter{section}
% To be able to refer to sections when needed
\usepackage{nameref}
% Redefinition of the \section command so that each one is labeled \label{sec:n} where n is its index 
\let\oldsection\section
\renewcommand{\section}[2][\relax]{%
    \ifx#1\relax
      \oldsection{#2}%
    \else
      \oldsection[#1]{#2}%
    \fi%
    \label{sec:\thesection}%
}

% Definition of custom colors based on the initial figure of the bar by the OP
\definecolor{myblue}{HTML}{57AED1}
\definecolor{mygreen}{HTML}{8BC53F}
\definecolor{mygray}{HTML}{DDDDDD}

% Definition of custom tikz styles in order to ease readability
\tikzset{
    % Bar style (Argument : color)
    sectionbar/.style={
        % Filling with one color as a preaction, in order to avoid reset by the pattern color
        preaction={fill=#1!70},
        % Application of the line pattern on to of the fill
        pattern={Lines[angle=45,distance={6pt},line width=3pt]},pattern color=#1
    },
    % Node style (Arguments : color, section number)
    sectionnode/.style 2 args={
        fill=#1,
        draw=white,
        thick,
        circle,
        text=white,
        radius=10pt,
        % Display of the section name below the cicle
        label={[text=#1]below:\nameref{sec:#2}},
        }
}


% Actual definition of the colorbar based on Gonzalo Medina's initial proposal
\makeatletter
    \def\pbar@progressbar{} % the progress bar
    \newcount\pbar@tmpcnta% auxiliary counter
    \newcount\pbar@tmpcntb% auxiliary counter
    \newdimen\pbar@pbht %progressbar height
    \newdimen\pbar@pbwd %progressbar width
    \newdimen\pbar@tmpdim % auxiliary dimension
    \pbar@pbwd=\linewidth
    \pbar@pbht=4pt

% The progress bar
\def\pbar@progressbar{%
    \pbar@tmpcnta=\value{section} % tmpcnta stores the section number
    \pbar@tmpcntb=\totvalue{section} % tmbcountb sotres the total amount of sections
    \advance\pbar@tmpcntb by 1 % tmbcountb is advanced by 1 in order to have the last bar segment after the last node

    \begin{tikzpicture}[very thin]
        % Clipping scope to avoid tests for the bar dimensions
        \begin{scope}
        % Clipping path
        \path[rounded corners=2pt,clip] (0pt,{-\pbar@pbht/2}) rectangle (\pbar@pbwd,{\pbar@pbht/2});
        % Gray bar (from 0 to last section)
        \path[sectionbar=mygray] (0pt,{-\pbar@pbht/2}) rectangle (\linewidth,{\pbar@pbht/2});
        % Blue bar (from 0 to the current section)
        \path[sectionbar=myblue] (0pt,{-\pbar@pbht/2}) rectangle ({(\[email protected])*\linewidth/\pbar@tmpcntb},{\pbar@pbht/2});
        % Green bar (from current to next section)
        \path[sectionbar=mygreen] ({(\[email protected])*\linewidth/\pbar@tmpcntb},{-\pbar@pbht/2}) rectangle ({(\pbar@tmpcnta+0.5)*\linewidth/\pbar@tmpcntb},{\pbar@pbht/2});
        \end{scope}
        % Drawing of the nodes on top of the bars, based on the number of the current section
        \foreach \secnumber in {1,...,\totvalue{section}}{
            % Number is lower, section is past, blue color
            \ifnum\secnumber<\pbar@tmpcnta
                \node[sectionnode={myblue}{\secnumber}] at ({(\secnumber-0.5)*\linewidth/\pbar@tmpcntb},0) {\strut\secnumber};
            \fi
            % Number is equal, section is current, green color
            \ifnum\secnumber=\pbar@tmpcnta
                \node[sectionnode={mygreen}{\secnumber}] at ({(\secnumber-0.5)*\linewidth/\pbar@tmpcntb},0) {\strut\secnumber};
            \fi
            % Number is larger, to be done section, gray color
            \ifnum\secnumber>\pbar@tmpcnta
            \node[sectionnode={mygray}{\secnumber}] at ({(\secnumber-0.5)*\linewidth/\pbar@tmpcntb},0) {\strut\secnumber};
            \fi
        }
  \end{tikzpicture}%
}

\addtobeamertemplate{headline}{}
{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=10ex,center,dp=1ex]{white}%
    \pbar@progressbar%
  \end{beamercolorbox}%
}
\makeatother

\begin{document}


\section{Introduction}

\begin{frame}
    \frametitle{Introduction}
    test
\end{frame}

\section{Motivation}

\begin{frame}
    \frametitle{Motivation}
    test
\end{frame}

\section{Methodology}

\begin{frame}
    \frametitle{Experiments}
    test
\end{frame}

\begin{frame}
    \frametitle{Statistics}
    test
\end{frame}

\section{Results}

\begin{frame}
    \frametitle{Results 1}
    test
\end{frame}

\begin{frame}
    \frametitle{Results 2}
    test
\end{frame}

\section{Conclusion}

\begin{frame}
    \frametitle{Conclusion}
    test
\end{frame}
\end{document}

여기에 이미지 설명을 입력하세요 여기에 이미지 설명을 입력하세요 여기에 이미지 설명을 입력하세요

편집하다pgf ifthenelse재미를 위해 약간 더 간결한 정의 또는 구성 및 사전 계산을 사용하는 막대입니다 \linewidth/\pbar@tempcntb.

% The progress bar
\def\pbar@progressbar{%
    \pbar@tmpcnta=\value{section} % tmpcnta stores the section number
    \pbar@tmpcntb=\totvalue{section} % tmbcountb sotres the total amount of sections
    \advance\pbar@tmpcntb by 1 % tmbcountb is advanced by 1 in order to have the last bar segment after the last node
    \pbar@tmpdim=\linewidth
    \divide\pbar@tmpdim by \pbar@tmpcntb

    \begin{tikzpicture}[very thin]
        % Clipping scope to avoid tests for the bar dimensions
        \begin{scope}
        % Clipping path
        \path[rounded corners=2pt,clip] (0pt,{-\pbar@pbht/2}) rectangle (\pbar@pbwd,{\pbar@pbht/2});
        % Gray bar (from 0 to last section)
        \path[sectionbar=mygray] (0pt,{-\pbar@pbht/2}) rectangle (\linewidth,{\pbar@pbht/2});
        % Blue bar (from 0 to the current section)
        \path[sectionbar=myblue] (0pt,{-\pbar@pbht/2}) rectangle ({(\[email protected])*\pbar@tmpdim},{\pbar@pbht/2});
        % Green bar (from current to next section)
        \path[sectionbar=mygreen] ({(\[email protected])*\pbar@tmpdim},{-\pbar@pbht/2}) rectangle ({(\pbar@tmpcnta+0.5)*\pbar@tmpdim},{\pbar@pbht/2});
        \end{scope}
        % Drawing of the nodes on top of the bars, based on the number of the current section
        \foreach \secnumber in {1,...,\totvalue{section}}{
            % Conditional definition of the colors
            \pgfmathsetmacro{\currcolor}{(\secnumber<\pbar@tmpcnta ? "myblue" : (\secnumber==\pbar@tmpcnta ? "mygreen" : "mygray"))}
            \node[sectionnode={\currcolor}{\secnumber}] at ({(\secnumber-0.5)*\pbar@tmpdim},0) {\strut\secnumber};
        }
  \end{tikzpicture}%
}

\addtobeamertemplate{headline}{}
{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=10ex,center,dp=1ex]{white}%
    \pbar@progressbar%
  \end{beamercolorbox}%
}
\makeatother

관련 정보