我有一条标有年份的时间线和一组标志,我想将其设置为 5,但无法做到,因为我是从使用 Tikz 绘制旗帜
我想要什么
我希望每面旗帜都包含一个引文,并分别放置在 1949、1979、1986、1989 和 1992 年。
这是我尝试过的
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
% begin bib
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{greenwade49,
author = "George D. Greenwade",
title = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year = "1949",
journal = "TUGBoat",
volume = "14",
number = "3",
pages = "342--351"
}
@article{greenwade79,
author = "George D. Greenwade",
title = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year = "1979",
journal = "TUGBoat",
volume = "14",
number = "3",
pages = "342--351"
}
@book{goossens86,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1986",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
\end{filecontents}
%end bib
\usepackage{natbib}
% flag preamble
\usepackage{tikz}
\pgfmathsetmacro{\flagscalefactor}{0.2}
\pgfmathsetmacro{\flagrotationdegree}{0}
\newcommand{\flagpolecolor}{brown!60!black}
\newcommand{\flagcolor}{yellow!67!red}
\newcommand{\flagsymbol}{\cite{greenwade79}}
\newcommand{\flagsymbolcolor}{black}
\newcommand{\tikzflag}{%
\begin{scope}[scale=\flagscalefactor,rotate=\flagrotationdegree]
\draw[fill=\flagpolecolor,thick] (0,0) -- ++ (0,8) arc (180:0:0.4 and 0.1) -- ++ (0,-8) arc (360:180:0.4 and 0.1);
\draw[thick] (0,8) arc (180:360:0.4 and 0.1);
\draw[fill=\flagcolor,thick] (0.8,7.5) to[out=-30,in=210] ++(3,0) to[out=30,in=150] ++ (3,0) -- ++ (0,-3) to [out=150,in=30] ++(-3,0) to[out=210,in=-30] ++(-3,0) -- cycle;
\node[\flagsymbolcolor] at (3.8,6) {\textbf{\flagsymbol}};
\end{scope}
}
\newcommand{\questionflag}{%
\pgfmathsetmacro{\flagscalefactor}{0.2}
\pgfmathsetmacro{\flagrotationdegree}{0}
\renewcommand{\flagpolecolor}{brown!60!black}
\renewcommand{\flagcolor}{yellow}
\renewcommand{\flagsymbol}{\cite{greenwade79}}
\renewcommand{\flagsymbolcolor}{red}
\tikzflag
}
\newcommand{\importantflag}{%
\pgfmathsetmacro{\flagscalefactor}{0.2}
\pgfmathsetmacro{\flagrotationdegree}{0}
\renewcommand{\flagpolecolor}{brown!60!black}
\renewcommand{\flagcolor}{green!50!blue}
\renewcommand{\flagsymbol}{\cite{goossens86}}
\renewcommand{\flagsymbolcolor}{white}
\tikzflag
}
%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{frame}
\begin{tikzpicture}[%
every node/.style={
font=\scriptsize,
text height=1ex,
text depth=.25ex,
},
]
% draw horizontal line
\draw[->] (0,0) -- (12.5,0);
% draw vertical lines
\foreach \x in {0,1,...,12.5}{
\draw (\x cm,3pt) -- (\x cm,0pt);
}
% place axis labels
\node[anchor=north] at (1,0) {$1950$};
\node[anchor=north] at (3,0) {$1960$};
\node[anchor=north] at (5,0) {$1970$};
\node[anchor=north] at (7,0) {$1980$};
\node[anchor=north] at (9,0) {1990};
\node[anchor=north] at (11,0) {$2000$};
%begin to draw flags
\end{tikzpicture}
\begin{tikzpicture}
\tikzflag
\end{tikzpicture}
\begin{tikzpicture}
\questionflag
\end{tikzpicture}
\begin{tikzpicture}
\importantflag
\end{tikzpicture}
\end{frame}
%bib config
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}
答案1
这绘制了这样的时间线。标志是pic
使用tape
形状节点的 s,并根据内容调整其宽度。目前的惯例是该节点的西北锚点位于日期指示的位置,但这可以更改。坐标系是这样的,水平位置是年份。这使得放置标志更加直观。
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tikz}
\usetikzlibrary{shapes.symbols}
% begin bib
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{greenwade49,
author = "George D. Greenwade",
title = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year = "1949",
journal = "TUGBoat",
volume = "14",
number = "3",
pages = "342--351"
}
@article{greenwade79,
author = "George D. Greenwade",
title = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year = "1979",
journal = "TUGBoat",
volume = "14",
number = "3",
pages = "342--351"
}
@book{goossens86,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1986",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@article{witten89,
author = "Witten, Edward",
title = "{Quantum Field Theory and the Jones Polynomial}",
journal = "Commun. Math. Phys.",
volume = "121",
year = "1989",
pages = "351-399",
doi = "10.1007/BF01217730",
note = "[,233(1988)]",
reportNumber = "IASSNS-HEP-88-33",
SLACcitation = "%%CITATION = CMPHA,121,351;%%"
}
@article{witten92,
author = "Witten, Edward",
title = "{The N matrix model and gauged WZW models}",
journal = "Nucl. Phys.",
volume = "B371",
year = "1992",
pages = "191-245",
doi = "10.1016/0550-3213(92)90235-4",
reportNumber = "IASSNS-HEP-91-26",
SLACcitation = "%%CITATION = NUPHA,B371,191;%%"
}
\end{filecontents*}
%end bib
\usepackage{natbib}
% flag preamble
\tikzset{pics/flag/.style={code={
\def\pv##1{\pgfkeysvalueof{/tikz/flags/##1}}
\path (0,0) node[tape,draw,pic actions,anchor=south west](tmp){#1};
\draw[thin,fill=\pv{pole color}] (tmp.north west)
rectangle ++ (-0.8ex,-3em); }},
flags/.cd,pole color/.initial=brown!60!black}
%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{frame}[t]
\begin{tikzpicture}[x=0.18cm,
nodes={font=\scriptsize,
text height=1ex,
text depth=.25ex,
}
]
% draw horizontal line
\draw[-stealth] (1945,0) -- (2005,0);
% draw ticks
\draw foreach \X in {1950,1960,...,2000}
{(\X,0) -- ++ (0,3pt) node[above]{\X} };
% draw flags
\path foreach \X/\Citation/\FillC [count=\Y]in
{1949/greenwade49/yellow,1979/greenwade79/blue!20,1986/goossens86/red!20,%
1989/witten89/cyan, 1992/witten92/orange}
{(\X,-1.4*\Y) pic[fill=\FillC]{flag={\cite{\Citation}}}};
\end{tikzpicture}
\end{frame}
\begin{frame}[t]
\frametitle{References}
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{frame}
\end{document}
或者将时间线置于底部,并将旗杆与其接触。
\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tikz}
\usetikzlibrary{shapes.symbols}
% begin bib
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{greenwade49,
author = "George D. Greenwade",
title = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year = "1949",
journal = "TUGBoat",
volume = "14",
number = "3",
pages = "342--351"
}
@article{greenwade79,
author = "George D. Greenwade",
title = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year = "1979",
journal = "TUGBoat",
volume = "14",
number = "3",
pages = "342--351"
}
@book{goossens86,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1986",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@article{witten89,
author = "Witten, Edward",
title = "{Quantum Field Theory and the Jones Polynomial}",
journal = "Commun. Math. Phys.",
volume = "121",
year = "1989",
pages = "351-399",
doi = "10.1007/BF01217730",
note = "[,233(1988)]",
reportNumber = "IASSNS-HEP-88-33",
SLACcitation = "%%CITATION = CMPHA,121,351;%%"
}
@article{witten92,
author = "Witten, Edward",
title = "{The N matrix model and gauged WZW models}",
journal = "Nucl. Phys.",
volume = "B371",
year = "1992",
pages = "191-245",
doi = "10.1016/0550-3213(92)90235-4",
reportNumber = "IASSNS-HEP-91-26",
SLACcitation = "%%CITATION = NUPHA,B371,191;%%"
}
\end{filecontents*}
%end bib
\usepackage{natbib}
% flag preamble
\tikzset{pics/flag/.style={code={
\def\pv##1{\pgfkeysvalueof{/tikz/flags/##1}}
\path (0,0) node[tape,draw,pic actions,anchor=south west](tmp){#1};
\draw[thin,fill=\pv{pole color}] (tmp.north west)
rectangle ([xshift=-0.8ex]tmp.north west|-Base); }},
flags/.cd,pole color/.initial=brown!60!black}
%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{frame}[t]
\frametitle{A timeline}
\begin{tikzpicture}[x=0.18cm,
nodes={font=\scriptsize,
text height=1ex,
text depth=.25ex,
}
]
% draw horizontal line
\draw[-stealth] (1945,0) coordinate(Base) -- (2005,0);
% draw ticks
\draw foreach \X in {1950,1960,...,2000}
{(\X,0) -- ++ (0,-3pt) node[below]{\X} };
% draw flags
\path foreach \X/\Citation/\FillC [count=\Y]in
{1949/greenwade49/yellow,1979/greenwade79/blue!20,1986/goossens86/red!20,%
1989/witten89/cyan, 1992/witten92/orange}
{(\X,7-1.2*\Y) pic[fill=\FillC]{flag={\cite{\Citation}}}};
\end{tikzpicture}
\end{frame}
\begin{frame}[t]
\frametitle{References}
\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{frame}
\end{document}