垂直时间线,每行有特定的图片

垂直时间线,每行有特定的图片

我正在准备一些幻灯片,其中我使用这个帖子。 这里是:

  \documentclass{beamer}
  \usepackage{charter}
  \usepackage{environ}
  \usepackage{tikz}
  \usetikzlibrary{calc,matrix}
  \usepackage{chronology}
  \usetheme{metropolis}   
  \usecolortheme{dolphin}
  \makeatletter
  \let\matamp=&
  \catcode`\&=13
  \def&{%
      \iftikz@is@matrix%
      \pgfmatrixnextcell%
      \else%
      \matamp%
      \fi%
  }
  \makeatother

  \newcounter{lines}
  \def\endlr{\stepcounter{lines}\\}

  \newcounter{vtml}
  \setcounter{vtml}{0}

  \newif\ifvtimelinetitle
  \newif\ifvtimebottomline

  \tikzset{
 description/.style={column 2/.append style={#1}},
 timeline color/.store in=\vtmlcolor,
 timeline color=red!80!black,
 timeline color st/.style={fill=\vtmlcolor,draw=\vtmlcolor},
 use timeline header/.is if=vtimelinetitle,
 use timeline header=false,
 add bottom line/.is if=vtimebottomline,
 add bottom line=false,
 timeline title/.store in=\vtimelinetitle,
 timeline title={},
 line offset/.store in=\lineoffset,
 line offset=4pt,
 }

\NewEnviron{vtimeline}[1][]{%
\setcounter{lines}{1}%
\stepcounter{vtml}%
\begin{tikzpicture}[column 1/.style={anchor=east},
    column 2/.style={anchor=west},
    text depth=0pt,text height=1ex,
    row sep=1ex,
    column sep=1em,
    #1
    ]
    \matrix(vtimeline\thevtml)[matrix of nodes]{\BODY};
    \pgfmathtruncatemacro\endmtx{\thelines-1}
    
    \path[timeline color st]
    ($(vtimeline\thevtml-1-1.north east)!0.5!(vtimeline\thevtml-1-2.north west)$)--
    ($(vtimeline\thevtml-\endmtx-1.south east)!0.5!(vtimeline\thevtml-\endmtx-2.south west)$);
    
    \foreach \x in {1,...,\endmtx}{
        \node[circle,timeline color st, inner sep=0.15pt, draw=white, thick]
        (vtimeline\thevtml-c-\x) at
        ($(vtimeline\thevtml-\x-1.east)!0.5!(vtimeline\thevtml-\x-2.west)$){};
        \draw[timeline color st](vtimeline\thevtml-c-\x.west)--++(-3pt,0);
    }
    
    \ifvtimelinetitle%
    \draw[timeline color st]([yshift=\lineoffset]vtimeline\thevtml.north west)--
    ([yshift=\lineoffset]vtimeline\thevtml.north east);
    
    \node[anchor=west,yshift=16pt,font=\large]
    at (vtimeline\thevtml-1-1.north west)
    {\textsc{Timeline \thevtml}: \textit{\vtimelinetitle}};
    \else%
    \relax%
    \fi%
    
    \ifvtimebottomline%
    \draw[timeline color st]([yshift=-\lineoffset]vtimeline\thevtml.south west)--
    ([yshift=-\lineoffset]vtimeline\thevtml.south east);
    \else%
    \relax%
    \fi%
    \end{tikzpicture}
    }
   \begin{document}
   \begin{frame}
   \begin{vtimeline}[description={text width=8cm},
        row sep=5ex,
        use timeline header,
        timeline title={Historical views}]
        1691 & G. W. Leibniz (1646-1716) imagines a universal and formal language.\endlr
        1879  & G. Frege (1848-1925) publishes a notational system for logic. \endlr
        1893/1903 & Frege publishes a formal language for arithmetic\endlr
        1906-1914 & A. Thue (1863-1922) publishes papers on words and language, introducing       Thue systems.\endlr
        1947 & E. L. Post (897-1954) proves the word problem for semigroups is undecidable, using Thue systems.\endlr
        1956 & N. Chomsky (1928- ) introduces the Chomsky hierarchy of formal languages and grammars.
        \endlr
      \end{vtimeline}   
      \end{frame}
      \end{document}   

我想,如果我能在每个名字旁边或每个活动结束时粘贴一张该人的适当比例的照片,以便观众可以看到这些人,那就太好了。

我想到的是类似下面的幻灯片,其中某些图片被放在相应的位置。所以,我有 5 张不相似的图片:

在此处输入图片描述

谢谢你的时间!

答案1

您的时间线本质上是一个节点矩阵。这意味着每个单元格都已有一个名称,您之后可以使用该名称添加图像等。这种方法的优点是它不会扰乱您的时间线的布局:

\documentclass{beamer}
\usepackage{charter}
\usepackage{environ}
\usepackage{tikz}
\usetikzlibrary{calc,matrix}
\usepackage{chronology}
\usetheme{moloch}% modern fork of the metropolis theme   
\usecolortheme{dolphin}
\usepackage[export]{adjustbox}
\makeatletter
\let\matamp=&
\catcode`\&=13
\def&{%
    \iftikz@is@matrix%
    \pgfmatrixnextcell%
    \else%
    \matamp%
    \fi%
}
\makeatother

\newcounter{lines}
\def\endlr{\stepcounter{lines}\\}

\newcounter{vtml}
\setcounter{vtml}{0}

\newif\ifvtimelinetitle
\newif\ifvtimebottomline

\tikzset{
 description/.style={column 2/.append style={#1}},
 timeline color/.store in=\vtmlcolor,
 timeline color=red!80!black,
 timeline color st/.style={fill=\vtmlcolor,draw=\vtmlcolor},
 use timeline header/.is if=vtimelinetitle,
 use timeline header=false,
 add bottom line/.is if=vtimebottomline,
 add bottom line=false,
 timeline title/.store in=\vtimelinetitle,
 timeline title={},
 line offset/.store in=\lineoffset,
 line offset=4pt,
 }

\NewEnviron{vtimeline}[1][]{%
\setcounter{lines}{1}%
\stepcounter{vtml}%
\begin{tikzpicture}[
    remember picture,
    column 1/.style={anchor=east},
    column 2/.style={anchor=west},
    text depth=0pt,text height=1ex,
    row sep=1ex,
    column sep=1em,
    #1
    ]
    \matrix(vtimeline\thevtml)[matrix of nodes]{\BODY};
    \pgfmathtruncatemacro\endmtx{\thelines-1}
    
    \path[timeline color st]
    ($(vtimeline\thevtml-1-1.north east)!0.5!(vtimeline\thevtml-1-2.north west)$)--
    ($(vtimeline\thevtml-\endmtx-1.south east)!0.5!(vtimeline\thevtml-\endmtx-2.south west)$);
    
    \foreach \x in {1,...,\endmtx}{
        \node[circle,timeline color st, inner sep=0.15pt, draw=white, thick]
        (vtimeline\thevtml-c-\x) at
        ($(vtimeline\thevtml-\x-1.east)!0.5!(vtimeline\thevtml-\x-2.west)$){};
        \draw[timeline color st](vtimeline\thevtml-c-\x.west)--++(-3pt,0);
    }
    
    \ifvtimelinetitle%
    \draw[timeline color st]([yshift=\lineoffset]vtimeline\thevtml.north west)--
    ([yshift=\lineoffset]vtimeline\thevtml.north east);
    
    \node[anchor=west,yshift=16pt,font=\large]
    at (vtimeline\thevtml-1-1.north west)
    {\textsc{Timeline \thevtml}: \textit{\vtimelinetitle}};
    \else%
    \relax%
    \fi%
    
    \ifvtimebottomline%
    \draw[timeline color st]([yshift=-\lineoffset]vtimeline\thevtml.south west)--
    ([yshift=-\lineoffset]vtimeline\thevtml.south east);
    \else%
    \relax%
    \fi%
    \end{tikzpicture}
    }
   \begin{document}
   \begin{frame}
   \begin{vtimeline}[description={text width=8.5cm},
        row sep=5ex,
        use timeline header,
        timeline title={Historical views}]
        1691 & G. W. Leibniz (1646-1716) imagines a universal and formal language.\endlr
         1879  & G. Frege (1848-1925) publishes a notational system for logic. \endlr
        1893/1903 & Frege publishes a formal language for arithmetic\endlr
        1906-1914 & A. Thue (1863-1922) publishes papers on words and language, introducing       Thue systems.\endlr
        1947 & E. L. Post (897-1954) proves the word problem for semigroups is undecidable, using Thue systems.\endlr
        1956 & N. Chomsky (1928- ) introduces the Chomsky hierarchy of formal languages and grammars.
        \endlr
      \end{vtimeline}   
      \begin{tikzpicture}[remember picture,overlay]
        \node[left] at (vtimeline\thevtml-1-1.west) {\includegraphics[height=0.5cm]{example-image-duck}};
        \node[left] at (vtimeline\thevtml-3-1.west) {\includegraphics[height=0.5cm]{example-grid-100x100bp}};
      \end{tikzpicture}
      \end{frame}
      \end{document}   

在此处输入图片描述

答案2

像这样吗?

在此处输入图片描述

基本代码可以是:

\documentclass{beamer}
\usepackage[export]{adjustbox}    % <--- added
\usepackage{charter}
\usepackage{environ}
\usepackage{tikz}
\usetikzlibrary{calc,matrix}
\usepackage{chronology}
\usetheme{metropolis}
\usecolortheme{dolphin}
\makeatletter
\let\matamp=&
\catcode`\&=13
\def&{%
\iftikz@is@matrix%
\pgfmatrixnextcell%
\else%
\matamp%
\fi%
}
\makeatother

\newcounter{lines}
\def\endlr{\stepcounter{lines}\\}

\newcounter{vtml}
\setcounter{vtml}{0}

\newif\ifvtimelinetitle
\newif\ifvtimebottomline

\tikzset{
description/.style={column 2/.append style={#1}},
timeline color/.store in=\vtmlcolor,
timeline color=red!80!black,
timeline color st/.style={fill=\vtmlcolor,draw=\vtmlcolor},
use timeline header/.is if=vtimelinetitle,
use timeline header=false,
add bottom line/.is if=vtimebottomline,
add bottom line=false,
timeline title/.store in=\vtimelinetitle,
timeline title={},
line offset/.store in=\lineoffset,
line offset=4pt,
}

\NewEnviron{vtimeline}[1][]{%
\setcounter{lines}{1}%
\stepcounter{vtml}%
\begin{tikzpicture}[column 1/.style={anchor=east},
column 2/.style={anchor=west, font=\linespread{0.92}\selectfont},
text depth=0pt,text height=1ex,
row sep=1ex,
column sep=1em,
#1
]
\matrix(vtimeline\thevtml)[matrix of nodes]{\BODY};
\pgfmathtruncatemacro\endmtx{\thelines-1}

\path[timeline color st]
($(vtimeline\thevtml-1-1.north east)!0.5!(vtimeline\thevtml-1-2.north west)$)--
($(vtimeline\thevtml-\endmtx-1.south east)!0.5!(vtimeline\thevtml-\endmtx-2.south west)$);

\foreach \x in {1,...,\endmtx}{
\node[circle,timeline color st, inner sep=0.15pt, draw=white, thick]
(vtimeline\thevtml-c-\x) at
($(vtimeline\thevtml-\x-1.east)!0.5!(vtimeline\thevtml-\x-2.west)$){};
\draw[timeline color st](vtimeline\thevtml-c-\x.west)--++(-3pt,0);
}

\ifvtimelinetitle%
\draw[timeline color st]([yshift=\lineoffset]vtimeline\thevtml.north west)--
([yshift=\lineoffset]vtimeline\thevtml.north east);

\node[anchor=west,yshift=16pt,font=\large]
at (vtimeline\thevtml-1-1.north west)
{\textsc{Timeline \thevtml}: \textit{\vtimelinetitle}};
\else%
\relax%
\fi%

\ifvtimebottomline%
\draw[timeline color st]([yshift=-\lineoffset]vtimeline\thevtml.south west)--
([yshift=-\lineoffset]vtimeline\thevtml.south east);
\else%
\relax%
\fi%
\end{tikzpicture}
}
\newcommand{\image}[1]{\includegraphics[valign=t]{#1}\ }        % <---

\begin{document}
\begin{frame}
\setkeys{Gin}{width=7.5mm, height=10mm}
\hspace*{-2em}\begin{vtimeline}[description={text width=85mm},   % <---
                                row sep=5ex,
                                use timeline header,
                                timeline title={Historical views}
                                ]
\image{example-image-duck}                                          % <---
    1691 & G. W. Leibniz (1646-1716) imagines a universal and formal language.\endlr
\image{example-image-duck}
    1879  & G. Frege (1848-1925) publishes a notational system for logic. \endlr
    1893/1903 & Frege publishes a formal language for arithmetic\endlr
\image{example-image-duck}
    1906-1914 & A. Thue (1863-1922) publishes papers on words and language, introducing       Thue systems.\endlr
\image{example-image-duck}
    1947 & E. L. Post (897-1954) proves the word problem for semigroups is undecidable, using Thue systems.\endlr
\image{example-image-duck}
    1956 & N. Chomsky (1928- ) introduces the Chomsky hierarchy of formal languages and grammars.
\endlr
    \end{vtimeline}
\end{frame}
\end{document}

上面的 MWE 中的变化以 标记% <---。对于您的真实图像,您需要在\image命令中使用人物图像文件的名称。

相关内容