答案1
使用chains
、fit
和positioning
库:
\documentclass[border=2mm]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{chains,
fit,
positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 0mm,
start chain = going right,
M/.style = {minimum size=11mm, on chain},
N/.style = {M, draw, inner sep=0mm, fit=#1},
FIT/.style = {draw, thick, inner sep=0mm, fit=#1},
]
\foreach \i [count=\j]
in {s_t,s_{t-1},s_{t-2},s_{t-3}, ,\dotsm, ,
s_{t-k},s_{t-1},s_{t-2},s_{t-3}, ,\dotsm, ,s_{t-k}}
\node (m\j) [M] {$\i$};
\foreach \i in {1,...,4,8,9,10,11,15}
\node [N=(m\i)] {};
\node [FIT=(m1) (m15)] {};
\end{tikzpicture}
\end{document}