2

I have a doubt on the following request: I would like to obtain something like the picture attached. enter image description here

I tried a sort of "for" loop strategy, but it did not work. here is the code:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usetikzlibrary{shapes,arrows,chains}

\begin{document}
\begin{frame}
  \begin{tikzpicture}
    \draw[->] (-3.5,0) -- (3.5,0) node [below] {};
    \foreach \x in {-1,...,2}
    \draw (\x, 0.1) -- (\x, -0.1) node [below] {\x};
  \end{tikzpicture}
\end{frame}
\end{document}

However, I do not understand how integers might be replaced by dates/years, possibly highlighted by some text below the node (and above some math).. What's your suggestions?

Thanks in advance for everything

Best

1dre

flav
  • 4,714
1dre
  • 419

2 Answers2

2

A first solution :

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\usetikzlibrary{shapes,arrows,chains}

\begin{document}
\begin{frame}
  \begin{tikzpicture}
    \draw[->] (-3.5,0) -- (3.5,0) node [below] {};
    \foreach \x/\d in {-1/1965,0/1980,1/2003,2/2005}
    \draw (\x, 0.1) -- (\x, -0.1) node [below] {\shortstack{\d\\Text}};
  \end{tikzpicture}
\end{frame}
\end{document}

enter image description here

flav
  • 4,714
1

I would name the nodes and then explicitly add the information — especially if the information is not automatically generated. For example, in the following example you have the nodes on your line named point1 to point5 and you can do a lot of things with them:

\documentclass{beamer}
\usepackage{tikz}
\usepackage[T1]{fontenc} % These are to avoid the problem with 
\usepackage{lmodern}     % missing font shapes
\usetikzlibrary{positioning,calc}
\usetikzlibrary{shapes,arrows,chains}

\begin{document}
\begin{frame}
  \begin{tikzpicture}
    \draw[thick, ->] (0,0) -- (6,0) node [below] {};
    \foreach \x in {1,...,5}
    \draw (\x, 0.1) -- node[pos=0.5] (point\x) {} (\x, -0.1);
    % node's content --- access them as point1...point5
    \path (point1) node [below] {Below of 1};
    \path (point1) node [above] {$A=1$};
    \path (point4) node [red, above] {Above 4};
    \draw [blue, ->] (point3) -- ++(0,2) node [above] {and this!};
    \path (point2) edge[green, bend right, <->] (point4);
    % you got the idea... 
  \end{tikzpicture}
\end{frame}
\end{document}

Result

Rmano
  • 40,848
  • 3
  • 64
  • 125