# tikz - flatten/flush line with rectangle

I drew the following picture below.

To extend squares, I attached lines at the corner angles, i.ex node.45. It can hardly be seen, but they are are not exacly in one line. How is it possible to flush/flatten the rectangle with the lines? Is there an easy way? The squared rectangles are custom made nodes, where I copied the code.

I used the following operations:

\node[square, draw, anchor = west, minimum width=2em, minimum height=2.6em] (w) at (v.east) {$s_{t-3}$};
\draw (w.45) -- ++  (2.6em,0em);


Thanks for tips

• Welcome to Tex.SE :) // Unfortunately we can only help you, if you add your preamble etc., which is relevant to your problem. S.th. we can copy and run. Thanks Commented Apr 26, 2022 at 15:40
• Unrelated but you use square (which is not defined natively) for your nodes and then use different minimum width and height. If you absolutely want squares, you may use regular polygon from the shapes.geometric library. Then, please show us what you have already done if you want to get some real help on that matter. Commented Apr 26, 2022 at 16:46

With use of chains, fit and positioning libraries:

\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}