语境

语境

我想自动生成我的内容幻灯片投影机,我使用 TikZ 对其进行了自定义。我目前手动进行。

语境

我的目标是创造自己的beamer风格。这就是为什么我为我的框架定义了布局内容见下方左侧

在此处输入图片描述

该框架结构如下:见上文,对

  • 我定义一条斜线(A) -- (B)——看到红点
  • 在这条线上,我定义了两点:(top)(down)——看到蓝点
  • 然后,章节编号和标题均匀分布在这条线上,在(top)(down)边界之间——参见黄点,以及下方的一节和两节的情况。
    在此处输入图片描述

问题

然而,整个结构都是手动定义的。我怎样才能自动生成这样的框架?

我看到了两个子问题:

  • 生成点(one)(two)等。
    计算它们的位置相当容易,因为它们的定义如下\node [yellow] (Number) at ($(top)!X!(down)$) {};x = <section number> / (<total number of sections> +1)

  • \thesection使用和生成标签的节点\secname(后者发现得益于这个问题) 为每个部分。


平均能量损失

\documentclass{beamer}
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
    \usepackage{tikz}
        \usetikzlibrary{calc}
        \usetikzlibrary{positioning}

\begin{document}
    \begin{frame}{Basic structure}
        \begin{tikzpicture}
        [
            overlay, 
            remember picture, 
            inner sep=0pt,  
        ]
        %% Defining points A and B
            \node [red] (A) at ($(current page.north west)+(3, 0)$) {$\bullet$};
            \node [red] (B) at ($(current page.south west)+(5, 0)$) {$\bullet$};
            \draw [dashed, thin, gray] (A) -- (B);

        %% Defining the top and the bottom point    
            \node [blue] (top) at ($(A)!0.3!(B)$) {$\bullet$};
            \node [blue] (down) at ($(A)!0.9!(B)$) {$\bullet$};

        %% Defining intermediary points

        %% Creating labels  

        %% Adding explanations
            %Points A & B
                \node[text = green, below right = .025 and .1 of A] {\itshape A};
                \node[text = green, above right = .025 and .1 of B] {\itshape B};
                \draw [dashed, thin, gray] (A) -- (B);

            %Top and Bottom points
                \node[text = green, right = .1 of top] {\itshape top};
                \node[text = green, right = .1 of down] {\itshape down};

        \end{tikzpicture}
    \end{frame}

    \begin{frame}{With one section}
        \begin{tikzpicture}
        [
            overlay, 
            remember picture, 
            inner sep=0pt,  
        ]
        %% Defining points A and B
            \node [red] (A) at ($(current page.north west)+(3, 0)$) {$\bullet$};        
            \node [red] (B) at ($(current page.south west)+(5, 0)$) {$\bullet$};

        %% Defining the top and the bottom point    
            \node [blue] (top) at ($(A)!0.3!(B)$) {$\bullet$};
            \node [blue] (down) at ($(A)!0.9!(B)$) {$\bullet$};


        %% Defining intermediary points
            \node [yellow] (one) at ($(top)!0.5!(down)$) {$\bullet$};

        %% Creating labels  
            \node [font=\Huge\bfseries, text = gray, left =1em of one, anchor= east] {1};
            \node [font=\Large, text = black, right =1em of one, anchor= west] {title of section 1};

        %% Adding explanations
            %Points A & B
            \node[text = green, below right = .025 and .1 of A] {\itshape A};
            \node[text = green, above right = .025 and .1 of B] {\itshape B};
            \draw [dashed, thin, gray] (A) -- (B);

            %Top and Bottom points
            \node[text = green, right = .1 of top] {\itshape top};
            \node[text = green, right = .1 of down] {\itshape down};
        \end{tikzpicture}
    \end{frame}

    \begin{frame}{With two sections}
        \begin{tikzpicture}
        [
            overlay, 
            remember picture, 
            inner sep=0pt,  
        ]
        %% Defining points A and B
            \node [red] (A) at ($(current page.north west)+(3, 0)$) {$\bullet$};        
            \node [red] (B) at ($(current page.south west)+(5, 0)$) {$\bullet$};

        %% Defining the top and the bottom point    
            \node [blue] (top) at ($(A)!0.3!(B)$) {$\bullet$};
            \node [blue] (down) at ($(A)!0.9!(B)$) {$\bullet$};


        %% Defining intermediary points
            \node [yellow] (one) at ($(top)!0.33!(down)$) {$\bullet$};
            \node [yellow] (two) at ($(top)!0.66!(down)$) {$\bullet$};

        %% Creating labels  
            \node [font=\Huge\bfseries, text = gray, left =1em of one, anchor= east] {1};
            \node [font=\Large, text = black, right =1em of one, anchor= west] {title of section 1};

            \node [font=\Huge\bfseries, text = gray, left =1em of two, anchor= east] {2};
            \node [font=\Large, text = black, right =1em of two, anchor= west] {title of section 2};

        %% Adding explanations
            %Points A & B
                \node[text = green, below right = .025 and .1 of A] {\itshape A};
                \node[text = green, above right = .025 and .1 of B] {\itshape B};
                \draw [dashed, thin, gray] (A) -- (B);

            %Top and Bottom points
                \node[text = green, right = .1 of top] {\itshape top};
                \node[text = green, right = .1 of down] {\itshape down};

        \end{tikzpicture}
    \end{frame}

    \begin{frame}{With three sections}
        \begin{tikzpicture}
        [
            overlay, 
            remember picture, 
            inner sep=0pt,  
        ]
        %% Defining points A and B
            \node [red] (A) at ($(current page.north west)+(3, 0)$) {$\bullet$};        
            \node [red] (B) at ($(current page.south west)+(5, 0)$) {$\bullet$};

        %% Defining the top and the bottom point    
            \node [blue] (top) at ($(A)!0.3!(B)$) {$\bullet$};
            \node [blue] (down) at ($(A)!0.9!(B)$) {$\bullet$};


        %% Defining intermediary points
            \node [yellow] (one) at ($(top)!0.25!(down)$) {$\bullet$};
            \node [yellow] (two) at ($(top)!0.50!(down)$) {$\bullet$};
            \node [yellow] (three) at ($(top)!0.75!(down)$) {$\bullet$};

        %% Creating labels  
            \node [font=\Huge\bfseries, text = gray, left =1em of one, anchor= east] {1};
            \node [font=\Large, text = black, right =1em of one, anchor= west] {title of section 1};

            \node [font=\Huge\bfseries, text = gray, left =1em of two, anchor= east] {2};
            \node [font=\Large, text = black, right =1em of two, anchor= west] {title of section 2};

            \node [font=\Huge\bfseries, text = gray, left =1em of three, anchor= east] {3};
            \node [font=\Large, text = black, right =1em of three, anchor= west] {title of section 3};

        %% Adding explanations
            %Points A & B
                \node[text = green, below right = .025 and .1 of A] {\itshape A};
                \node[text = green, above right = .025 and .1 of B] {\itshape B};
                \draw [dashed, thin, gray] (A) -- (B);

            %Top and Bottom points
                \node[text = green, right = .1 of top] {\itshape top};
                \node[text = green, right = .1 of down] {\itshape down};

            %Between 1, 2, 3...
                \path (top) -- node [gray, midway] {x} (one);
                \path (one) -- node [gray, midway] {x} (two);
                \path (two) -- node [gray, midway] {x} (three);
                \path (three) -- node [gray, midway] {x} (down);
        \end{tikzpicture}
    \end{frame}

    \begin{frame}{Intended result with three sections}
        \begin{tikzpicture}
        [
            overlay, 
            remember picture, 
            inner sep=0pt,  
        ]
        %% Defining points A and B
            \node [red] (A) at ($(current page.north west)+(3, 0)$) {};     
            \node [red] (B) at ($(current page.south west)+(5, 0)$) {};

        %% Defining the top and the bottom point    
            \node [blue] (top) at ($(A)!0.3!(B)$) {};
            \node [blue] (down) at ($(A)!0.9!(B)$) {};


        %% Defining intermediary points
            \node [yellow] (one) at ($(top)!0.25!(down)$) {};
            \node [yellow] (two) at ($(top)!0.50!(down)$) {};
            \node [yellow] (three) at ($(top)!0.75!(down)$) {};

        %% Creating labels  
            \node [font=\Huge\bfseries, text = gray, left =1em of one, anchor= east] {1};
            \node [font=\Large, text = black, right =1em of one, anchor= west] {title of section 1};

            \node [font=\Huge\bfseries, text = gray, left =1em of two, anchor= east] {2};
            \node [font=\Large, text = black, right =1em of two, anchor= west] {title of section 2};

            \node [font=\Huge\bfseries, text = gray, left =1em of three, anchor= east] {3};
            \node [font=\Large, text = black, right =1em of three, anchor= west] {title of section 3};

        \end{tikzpicture}
    \end{frame}
\end{document}

答案1

我的理解是您正在创建目录。因此,合理的方法是设置 toc 样式并包含该.toc文件。

@samcarter 建议采用一种更好的方法来捕获节的总数。但我选择了一种更粗暴的方法来演示可以包含.toc多次并实现各种目标。

https://tex.stackexchange.com/a/260647/51022我曾演示过类似的方法。

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

\begin{document}

\section{title of section 1}
\section{title of section 2}
\section{title of section 3}
\section{title of section 4}
\section{title of section 5}
\subsection{title of subsection 4-1}

\makeatletter
\def\beamer@endinputifotherversion#1{}
\def\beamer@sectionintoc#1#2#3#4#5{\def\thelastsection{#1}}
\def\beamer@subsectionintoc#1#2#3#4#5#6{}
\def\beamer@subsubsectionintoc#1#2#3#4#5#6#7{}
\def\thelastsection{0}
\@input{\jobname.toc}
\pgfmathsetmacro\n{\thelastsection+1}
\def\beamer@sectionintoc#1#2#3#4#5{
    \path($(top)!#1/\n!(bot)$)
        +(-1,0)node[left,gray,font=\Huge\bfseries]{#1}
        +( 1,0)node[right,   ,font=\Large        ]{#2};
}

\frame{{table of contents}
    \tikz[remember picture,overlay,inner sep=0]{
        \path($(current page.north west)+(3, 0)$)coordinate(A)
             ($(current page.south west)+(5, 0)$)coordinate(B)
             ($(A)!0.3!(B)$)coordinate(top)
             ($(A)!0.9!(B)$)coordinate(bot);
        \@input{\jobname.toc}
    }
}

\makeatother

\end{document}

相关内容