修改 beamer 中的时间线

修改 beamer 中的时间线

我在这个问题的选定答案中找到了代码我如何制定标准时间表?

我对其进行了修改以实现我想要的效果。

\documentclass[svgnames]{beamer}

\usepackage[french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

%\usepackage[margin=3cm]{geometry}
\usepackage{ragged2e}
\usepackage{fourier}
\usepackage{tikz} 
\usetikzlibrary{chains,shapes.arrows,fit}

\definecolor{arrowcolor}{RGB}{201,216,232}% color for the arrow filling
\definecolor{circlecolor}{RGB}{79,129,189}% color for the inner circles filling
\colorlet{textcolor}{white}% color for the text inside the circles
\colorlet{bordercolor}{white}% color for the outer border of circles

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\newcounter{task}

\newlength\taskwidth% width of the box for the task description
\newlength\taskvsep% vertical distance between the task description and arrow

\setlength\taskwidth{2.5cm}
\setlength\taskvsep{17pt}

\def\taskpos{}
\def\taskanchor{}

\newcommand\task[1]{%
  {\parbox[t]{\taskwidth}{\scriptsize\Centering#1}}}

\tikzset{
inner/.style={
  on chain,
  circle,
  inner sep=4pt,
  fill=circlecolor,
  line width=1.5pt,
  draw=bordercolor,
  text width=1.2em,
  align=center,
  text height=1.25ex,
  text depth=0ex
},
on grid
}

\newcommand\Task[2][]{%
\node[inner xsep=0pt] (c1) {\phantom{A}};
\stepcounter{task}
\ifodd\thetask\relax
  \renewcommand\taskpos{\taskvsep}\renewcommand\taskanchor{south}
\else
  \renewcommand\taskpos{-\taskvsep}\renewcommand\taskanchor{north}
\fi
\node[inner,font=\footnotesize\sffamily\color{textcolor}]    
  (c\the\numexpr\value{task}+1\relax) {#1};
\node[anchor=\taskanchor,yshift=\taskpos] 
  at (c\the\numexpr\value{task}+1\relax) {\task{#2}};
}

\newcommand\drawarrow{% the arrow is placed in the background layer 
                                                     % after the node for the tasks have been placed
\ifnum\thetask=0\relax
  \node[on chain] (c1) {}; % if no \Task command is used, the arrow will be drawn
\fi
\node[on chain] (f) {};
\begin{pgfonlayer}{background}
\node[
  inner sep=10pt,
  single arrow,
  single arrow head extend=0.8cm,
  draw=none,
  fill=arrowcolor,
  fit= (c1) (f)
] (arrow) {};
\fill[white] % the decoration at the tail of the arrow
  (arrow.before tail) -- (c1|-arrow.west) -- (arrow.after tail) -- cycle;
\end{pgfonlayer}
}

\newenvironment{timeline}[1][node distance=.75\taskwidth]
  {\par\noindent\begin{tikzpicture}[start chain,#1]}
  {\drawarrow\end{tikzpicture}\par}

\begin{document}

\begin{frame}
\begin{columns}
\column{13cm}
\begin{timeline}
\Task{Maitrise Physique\\Magistère Mécanique\\ 1997-2005}
\Task{Chercheur associé\\ 2005-2007}
\Task{Doctorant\\Enseignant \\ 2007-2009}
\Task{Enseignant\\(M, L, Prépa, Secondaire) \\ 2009-2012}
\Task{Doctorant\\Enseignant \\ 2012-2013}
\Task{Deux stages post-doctoraux\\2014-2016}
\Task{ATER/LRU \\ Depuis 2016}
\end{timeline}

\vspace{1cm}

\definecolor{arrowcolor}{RGB}{144,168,65}
\colorlet{circlecolor}{white}
\definecolor{bordercolor}{RGB}{168,89,65}
\colorlet{textcolor}{bordercolor}
\setlength\taskwidth{1.7cm}

%\begin{timeline}
%\Task[M]{Grilled cheese sandwiches on whole-wheat bread, one peach}
%\Task[Tu]{Penne pasta Caprese salad}
%\Task[W]{Zucchini muffins with cream cheese, grapes, and watermelon}
%\Task[Th]{Peanut butter and banana sandwiches, popcorn, one peach}
%\Task[F]{Cream cheese and cucumber sandwich, grapes, and blueberries}
%\Task[Sa]{Grilled fish with lemon, grilled corn, and whole-wheat biscuits}
%\Task[Su]{Yogurth with honey and blueberries}
%\end{timeline}

\end{columns}
\end{frame}

\end{document}

我得到的带有时间线的幻灯片看起来像

在此处输入图片描述

我们看到内容并不适合一张幻灯片。我应该如何修改上述代码才能做到这一点?

另外,我想在每个圆圈下方或上方添加垂直线,以指向相关文本,其中包含具体隶属关系和主要活动。如何做到这一点?

提前非常感谢您。

答案1

您可以向图片添加选项

\documentclass[svgnames]{beamer}

\usepackage[french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

%\usepackage[margin=3cm]{geometry}
\usepackage{ragged2e}
\usepackage{fourier}
\usepackage{tikz} 
\usetikzlibrary{chains,shapes.arrows,fit}

\definecolor{arrowcolor}{RGB}{201,216,232}% color for the arrow filling
\definecolor{circlecolor}{RGB}{79,129,189}% color for the inner circles filling
\colorlet{textcolor}{white}% color for the text inside the circles
\colorlet{bordercolor}{white}% color for the outer border of circles

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\newcounter{task}

\newlength\taskwidth% width of the box for the task description
\newlength\taskvsep% vertical distance between the task description and arrow

\setlength\taskwidth{2.5cm}
\setlength\taskvsep{17pt}

\def\taskpos{}
\def\taskanchor{}

\newcommand\task[1]{%
  {\parbox[t]{\taskwidth}{\scriptsize\Centering#1}}}

\tikzset{
inner/.style={
  on chain,
  circle,
  inner sep=4pt,
  fill=circlecolor,
  line width=1.5pt,
  draw=bordercolor,
  text width=1.2em,
  align=center,
  text height=1.25ex,
  text depth=0ex
},
on grid
}

\newcommand\Task[2][]{%
\node[inner xsep=0pt] (c1) {\phantom{A}};
\stepcounter{task}
\ifodd\thetask\relax
  \renewcommand\taskpos{\taskvsep}\renewcommand\taskanchor{south}
\else
  \renewcommand\taskpos{-\taskvsep}\renewcommand\taskanchor{north}
\fi
\node[inner,font=\footnotesize\sffamily\color{textcolor}]    
  (c\the\numexpr\value{task}+1\relax) {#1};
\node[anchor=\taskanchor,yshift=\taskpos] 
  at (c\the\numexpr\value{task}+1\relax) {\task{#2}};
}

\newcommand\drawarrow{% the arrow is placed in the background layer 
                                                     % after the node for the tasks have been placed
\ifnum\thetask=0\relax
  \node[on chain] (c1) {}; % if no \Task command is used, the arrow will be drawn
\fi
\node[on chain] (f) {};
\begin{pgfonlayer}{background}
\node[
  inner sep=10pt,
  single arrow,
  single arrow head extend=0.8cm,
  draw=none,
  fill=arrowcolor,
  fit= (c1) (f)
] (arrow) {};
\fill[white] % the decoration at the tail of the arrow
  (arrow.before tail) -- (c1|-arrow.west) -- (arrow.after tail) -- cycle;
\end{pgfonlayer}
}

\newenvironment{timeline}[1][node distance=.75\taskwidth]
  {\par\noindent\begin{tikzpicture}[start chain,#1]}
  {\drawarrow\end{tikzpicture}\par}

\begin{document}

\begin{frame}
\begin{columns}
\column{13cm}
\begin{timeline}[node distance=.57\taskwidth]
\Task{Maitrise Physique\\Magistère Mécanique\\ 1997-2005}
\Task{Chercheur associé\\ 2005-2007}
\Task{Doctorant\\Enseignant \\ 2007-2009}
\Task{Enseignant\\(M, L, Prépa, Secondaire) \\ 2009-2012}
\Task{Doctorant\\Enseignant \\ 2012-2013}
\Task{Deux stages post-doctoraux\\2014-2016}
\Task{ATER/LRU \\ Depuis 2016}
\end{timeline}

\vspace{1cm}

\definecolor{arrowcolor}{RGB}{144,168,65}
\colorlet{circlecolor}{white}
\definecolor{bordercolor}{RGB}{168,89,65}
\colorlet{textcolor}{bordercolor}
\setlength\taskwidth{1.7cm}

%\begin{timeline}
%\Task[M]{Grilled cheese sandwiches on whole-wheat bread, one peach}
%\Task[Tu]{Penne pasta Caprese salad}
%\Task[W]{Zucchini muffins with cream cheese, grapes, and watermelon}
%\Task[Th]{Peanut butter and banana sandwiches, popcorn, one peach}
%\Task[F]{Cream cheese and cucumber sandwich, grapes, and blueberries}
%\Task[Sa]{Grilled fish with lemon, grilled corn, and whole-wheat biscuits}
%\Task[Su]{Yogurth with honey and blueberries}
%\end{timeline}

\end{columns}
\end{frame}

\end{document}

在此处输入图片描述

对于第二个问题:

另外,我想在每个圆圈下方或上方添加垂直线,以指向相关文本,其中包含具体隶属关系和主要活动。如何做到这一点?

可能像这样吗?

\documentclass[svgnames]{beamer}

\usepackage[french]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

%\usepackage[margin=3cm]{geometry}
\usepackage{ragged2e}
\usepackage{fourier}
\usepackage{tikz} 
\usetikzlibrary{chains,shapes.arrows,fit}

\definecolor{arrowcolor}{RGB}{201,216,232}% color for the arrow filling
\definecolor{circlecolor}{RGB}{79,129,189}% color for the inner circles filling
\colorlet{textcolor}{white}% color for the text inside the circles
\colorlet{bordercolor}{white}% color for the outer border of circles

\pgfdeclarelayer{background}
\pgfsetlayers{background,main}

\newcounter{task}

\newlength\taskwidth% width of the box for the task description
\newlength\taskvsep% vertical distance between the task description and arrow

\setlength\taskwidth{2.5cm}
\setlength\taskvsep{17pt}

\def\taskpos{}
\def\taskanchor{}

\newcommand\task[1]{%
  {\parbox[t]{\taskwidth}{\scriptsize\Centering#1}}}

\tikzset{
inner/.style={
  on chain,
  circle,
  inner sep=4pt,
  fill=circlecolor,
  line width=1.5pt,
  draw=bordercolor,
  text width=1.2em,
  align=center,
  text height=1.25ex,
  text depth=0ex
},
on grid
}

\newcommand\Task[2][]{%
\node[inner xsep=0pt] (c1) {\phantom{A}};
\stepcounter{task}
\ifodd\thetask\relax
  \renewcommand\taskpos{\taskvsep}\renewcommand\taskanchor{south}
\else
  \renewcommand\taskpos{-\taskvsep}\renewcommand\taskanchor{north}
\fi
\node[inner,font=\footnotesize\sffamily\color{textcolor}]    
  (c\the\numexpr\value{task}+1\relax) {#1};
\node[anchor=\taskanchor,yshift={\taskpos*2}] 
  at (c\the\numexpr\value{task}+1\relax) (x) {\task{#2}};
\draw[blue] (c\the\numexpr\value{task}+1\relax) -- (x);
}

\newcommand\drawarrow{% the arrow is placed in the background layer 
                                                     % after the node for the tasks have been placed
\ifnum\thetask=0\relax
  \node[on chain] (c1) {}; % if no \Task command is used, the arrow will be drawn
\fi
\node[on chain] (f) {};
\begin{pgfonlayer}{background}
\node[
  inner sep=10pt,
  single arrow,
  single arrow head extend=0.8cm,
  draw=none,
  fill=arrowcolor,
  fit= (c1) (f)
] (arrow) {};
\fill[white] % the decoration at the tail of the arrow
  (arrow.before tail) -- (c1|-arrow.west) -- (arrow.after tail) -- cycle;
\end{pgfonlayer}
}

\newenvironment{timeline}[1][node distance=.75\taskwidth]
  {\par\noindent\begin{tikzpicture}[start chain,#1]}
  {\drawarrow\end{tikzpicture}\par}

\begin{document}

\begin{frame}
\begin{columns}
\column{13cm}
\begin{timeline}[node distance=.57\taskwidth]
\Task{Maitrise Physique\\Magistère Mécanique\\ 1997-2005}
\Task{Chercheur associé\\ 2005-2007}
\Task{Doctorant\\Enseignant \\ 2007-2009}
\Task{Enseignant\\(M, L, Prépa, Secondaire) \\ 2009-2012}
\Task{Doctorant\\Enseignant \\ 2012-2013}
\Task{Deux stages post-doctoraux\\2014-2016}
\Task{ATER/LRU \\ Depuis 2016}
\end{timeline}

\vspace{1cm}

\definecolor{arrowcolor}{RGB}{144,168,65}
\colorlet{circlecolor}{white}
\definecolor{bordercolor}{RGB}{168,89,65}
\colorlet{textcolor}{bordercolor}
\setlength\taskwidth{1.7cm}

%\begin{timeline}
%\Task[M]{Grilled cheese sandwiches on whole-wheat bread, one peach}
%\Task[Tu]{Penne pasta Caprese salad}
%\Task[W]{Zucchini muffins with cream cheese, grapes, and watermelon}
%\Task[Th]{Peanut butter and banana sandwiches, popcorn, one peach}
%\Task[F]{Cream cheese and cucumber sandwich, grapes, and blueberries}
%\Task[Sa]{Grilled fish with lemon, grilled corn, and whole-wheat biscuits}
%\Task[Su]{Yogurth with honey and blueberries}
%\end{timeline}

\end{columns}
\end{frame}

\end{document}

在此处输入图片描述

事实上,我们要修改的只是一些正常的 TiZ 命令。

相关内容