具有「目前位置」的時間箭頭隨著疊加編號的變化而變化

具有「目前位置」的時間箭頭隨著疊加編號的變化而變化

我正在展示幻燈片,透過快照展示時間演變。每個快照對應一個特定的時間。

我想顯示一個時間箭頭(垂直在側面),其中的項目符號對應於每個時間點(不等距)。在每個覆蓋上,其中一個項目符號是實心填充的,並且指定了當前時間,而其他項目符號是空心的(空心圓圈)。

我認為我可以使用 輕鬆完成未命名版本tikz,但我不確定如何根據覆蓋數量調整元素的樣式和節點文字的存在。

這是靜態時間箭頭的 MWE:

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
  \def\axscale{-0.02}
  \def\thex{0}
  \def\they{0}
  \def\prevy{0}
  \def\times{{-5,2, 12, 22, 32, 44, 76, 116, 182, 300,307}}
  \def\maxt{9}
  \foreach \it in {1,...,\maxt} {
        \pgfmathparse{\axscale*\times[\it-1]}
        \pgfmathsetmacro{\prevy}{\pgfmathresult}
        \pgfmathparse{\axscale*\times[\it]}
        \pgfmathsetmacro{\they}{\pgfmathresult}
        \draw[-{Circle[open]}] (\thex,\prevy) -- (\thex,\they);
        \node[right,anchor=west] at (\thex,\they) {
            $t=\pgfmathparse{\times[\it]}
            \pgfmathprintnumber[    % Print the result
                fixed,
                fixed zerofill,
                precision=0,
                assume math mode=true
            ]{\pgfmathresult}
            $};
  }
  \pgfmathparse{\axscale*\times[\maxt]}
  \pgfmathsetmacro{\prevy}{\pgfmathresult}
  \pgfmathparse{\axscale*\times[\maxt+1]}
  \pgfmathsetmacro{\they}{\pgfmathresult}
  \draw[->] (\thex,\prevy) -- (\thex,\they);
  %\draw(\thex,\prevy) -- (\thex+5,\they);
\end{tikzpicture}
\end{document}

因此,要設定動畫的元素是Circle[open]以及是否顯示t=...標籤。

答案1

我相信你已經得到答案了,就是使用圖層TikZ,兩個答案都展示瞭如何做到這一點。

我想透過使用 TikZ 提供的一些好東西來展示一種不同的方式來繪製這個時間線,主要是/tikz/y鑰匙您可以在其中更改長度和方向y的軸XYZ座標系(沒有單位的座標系)。

\axscale您可以設定y-0.02cm(預設為 1cm)而不是使用,TikZ 會乘以您的值將其轉換為帆布座標系(單位為y仍然指向上方)。

然後,還有chains圖書館 我實際上只是用它來加入沒有它的節點去任何地方。為此,我設定了1mm上面的起點t= 0 並添加最後一個點,該點始終比最後一個點低 1.4mmt。 (如果您需要線的上部起點位於第一個線上方固定距離t這裡需要進行調整->

說到箭頭提示,而Circle提示看起來是件好事,它們只接觸指定的座標,而不是以它們為中心。這可以是固定的,儘管我在這裡只使用圓形節點。

為了讓圖表投影機意識到,我竊取了<.>語法薩姆·卡特的回答擁有label與節點填充同時出現。由於我使用圓形節點而不是箭頭提示作為參考,因此我認為節點會排列得更好。

我們也可以將 the 添加labelfill,即

alt=<+>{fill, label={$t = \t$}}{}

儘管這將使圖片跳躍,除非標籤不再對邊界框有貢獻。
由於visible on解決方案overlay-beamer-styles將在框架上留下隱藏文字(可以選擇和複製),因此我使用Beamer自己的\uncover來隱藏文字。

程式碼

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, chains, overlay-beamer-styles}
\begin{document}
\begin{frame}
\begin{itemize}[<+->]
\item First.
\item Second.
\end{itemize}

\begin{tikzpicture}[
  y=-.02cm, thick, label position=right, start chain = going {},
  dot/.style={circle, draw, inner sep=+0pt, minimum size=+1.3mm}]
\coordinate[on chain]() at (0, 1mm); % a start (for the line)
\foreach \t in {2, 12, 22, 32, 44, 76, 116, 182, 300}
  \node[dot, on chain, join, alt=<+>{fill},
    label/.expanded={$\uncover<.>{t = \t}$}, % no hidden text in output
%    label={[visible on=<.>]$t = \t$},       % hidden text in output
  ] at (0, \t) {};
% and an end that is below the last dot
\coordinate[on chain, join=by ->]() at ([yshift=-1.4mm] chain-end.south);
\end{tikzpicture}
\end{frame}
\end{document}

輸出(點擊查看完整版本)

完整文件的縮圖

答案2

您可以利用 tikz 指令(例如\draw)具有覆蓋感知能力:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{frame}
\begin{tikzpicture}
  \def\axscale{-0.02}
  \def\thex{0}
  \def\they{0}
  \def\prevy{0}
  \def\times{{-5,2, 12, 22, 32, 44, 76, 116, 182, 300,307}}
  \def\maxt{9}
  \foreach \it in {1,...,\maxt} {
        \pgfmathparse{\axscale*\times[\it-1]}
        \pgfmathsetmacro{\prevy}{\pgfmathresult}
        \pgfmathparse{\axscale*\times[\it]}
        \pgfmathsetmacro{\they}{\pgfmathresult}
        \draw[-{Circle[open]}] (\thex,\prevy) -- (\thex,\they);
        \draw<+(2)>[-{Circle}] (\thex,\prevy) -- (\thex,\they);
        \node<.(2)>[right,anchor=west] at (\thex,\they) {
            $t=\pgfmathparse{\times[\it]}
            \pgfmathprintnumber[    % Print the result
                fixed,
                fixed zerofill,
                precision=0,
                assume math mode=true
            ]{\pgfmathresult}
            $};
  }
  \pgfmathparse{\axscale*\times[\maxt]}
  \pgfmathsetmacro{\prevy}{\pgfmathresult}
  \pgfmathparse{\axscale*\times[\maxt+1]}
  \pgfmathsetmacro{\they}{\pgfmathresult}
  \draw[->] (\thex,\prevy) -- (\thex,\they);
  %\draw(\thex,\prevy) -- (\thex+5,\they);
\end{tikzpicture}
\end{frame}
\end{document}

在此輸入影像描述

答案3

使用強大的overlay-beamer-styles庫,您可以執行以下操作:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{overlay-beamer-styles}

\begin{document}
\begin{frame}

\begin{tikzpicture}
  \def\axscale{-0.02}
  \def\thex{0}
  \def\they{0}
  \def\prevy{0}
  \def\times{{-5, 2, 12, 22, 32, 44, 76, 116, 182, 300, 307}}
  \def\maxt{9}
  \foreach \it in {1,...,\maxt} {
        \pgfmathparse{\axscale*\times[\it-1]}
        \pgfmathsetmacro{\prevy}{\pgfmathresult}
        \pgfmathparse{\axscale*\times[\it]}
        \pgfmathsetmacro{\they}{\pgfmathresult}
        \draw[alt={<\it>{-{Circle[]}}{-{Circle[open]}}}] (\thex,\prevy) -- (\thex,\they);
        \node[right,anchor=west] at (\thex,\they) {
            $t=\pgfmathparse{\times[\it]}
            \pgfmathprintnumber[    % Print the result
                fixed,
                fixed zerofill,
                precision=0,
                assume math mode=true
            ]{\pgfmathresult}
            $};
  \pgfmathparse{\axscale*\times[\maxt]}
  \pgfmathsetmacro{\prevy}{\pgfmathresult}
  \pgfmathparse{\axscale*\times[\maxt+1]}
  \pgfmathsetmacro{\they}{\pgfmathresult}
  \draw[->] (\thex,\prevy) -- (\thex,\they);
  }
  %\draw(\thex,\prevy) -- (\thex+5,\they);
\end{tikzpicture}

\end{frame}
\end{document}

在此輸入影像描述

或者,如果您想保留前面的點,您可以替換alt={<\it>{-{Circle[]}}{-{Circle[open]}}}alt={<\it->{-{Circle[]}}{-{Circle[open]}}}(即新增-後)。\it

相關內容