wie man ein diskretes Zeitdiagramm in Tikz zeichnet

wie man ein diskretes Zeitdiagramm in Tikz zeichnet

Kann mir jemand helfen, Folgendes in Tikz zu zeichnen?

  1. Eine gerade Linie.
  2. \dotsAuf dem Liniensegment muss ich 0,1,2, , hervorheben .k,k+1 bei gleicher Entfernung.
  3. Zwischen 0 und 1 und im Allgemeinen im k-, k+1-Segment muss ich 1,2,3, \dots, t hervorheben.

Antwort1

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}
 \pgfmathtruncatemacro{\L}{10} %<- length of the line
 \pgfmathtruncatemacro{\kmax}{6} 
 \pgfmathtruncatemacro{\tmax}{7}
 \draw (0,0) -- (\L,0);
 \foreach \k in {0,...,\kmax}
  {\draw (\L*\k/\kmax,0.2) -- (\L*\k/\kmax,-0.2) \ifnum\k<2 node[below,text
  height=1.5ex]{$\k$}\fi
  \ifnum\k=\numexpr\kmax-1 node[below,text
  height=1.5ex]{$k$}\fi
  \ifnum\k=\kmax node[below,text
  height=1.5ex]{$k+1$}\fi;
  \ifnum\k<\kmax
  \foreach \t in {1,2,\tmax}
  {\draw ({\L*\k/\kmax+\L*(\t/(\tmax+1))/\kmax},0.1) 
  -- ({\L*\k/\kmax+\L*(\t/(\tmax+1))/\kmax},-0.1);}
  \fi}
\end{tikzpicture}
\end{document}

Bildbeschreibung hier eingeben

Oder

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}
 \pgfmathtruncatemacro{\L}{10} %<- length of the line
 \pgfmathtruncatemacro{\kmax}{6} 
 \pgfmathtruncatemacro{\tmax}{7}
 \draw (0,0) -- (\L,0);
 \foreach \k in {0,...,\kmax}
  {\draw (\L*\k/\kmax,0.2) -- (\L*\k/\kmax,-0.2) \ifnum\k<2 node[below,text
  height=1.5ex]{$\k$}\fi
  \ifnum\k=\numexpr\kmax-1 node[below,text
  height=1.5ex]{$k$}\fi
  \ifnum\k=\kmax node[below,text
  height=1.5ex]{$k+1$}\fi;
  \ifnum\k<\kmax
  \foreach \t in {1,2,...,\tmax}
  {\draw ({\L*\k/\kmax+\L*(\t/(\tmax+1))/\kmax},-0.1) 
  -- ({\L*\k/\kmax+\L*(\t/(\tmax+1))/\kmax},0.1)
  node[above] {$\ifnum\t=\tmax
  t\else\ifnum\t<4
  \t\else .\fi\fi$} ;}
  \fi}
\end{tikzpicture}
\end{document}

Bildbeschreibung hier eingeben

verwandte Informationen