我刚刚学习 LaTeX 并绘制了 2 个矩阵并想在 TikZ 中连接它们的节点,但我无法绘制完全与操作员接触的路径\oplus
。
顺便问一下,为什么\boxplus
在 Tikz 中可以使用而不能使用\oplus
?谢谢。
\documentclass[tikz,border=2mm]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{amsmath}
\usetikzlibrary{matrix,positioning,shapes,arrows}
\begin{document}
\newcommand{\size}{\linewidth}
\begin{tikzpicture}[
every path/.style={draw, font=\small},
labelfield/.style={outer sep=0pt, minimum height=5mm,font=\small, anchor=center},
field/.style={outer sep=0pt, draw, minimum height=8mm,
minimum width=#1\size,font=\small,anchor=center}]
\matrix (A) [matrix of nodes, column sep=-\pgflinewidth,
row 1/.style={nodes={field=.1}}] {
|[field=.1]|$R_1^{(t)}$ & |[field=.1]|$R_2^{(t)}$ & |[field=.1]|$R_3^{(t)}$ & |[field=.1]|$R_4^{(t)}$ & |[field=.1]|$R_5^{(t)}$ & |[field=.1]|$R_6^{(t)}$ & |[field=.1]|$R_7^{(t)}$ & |[field=.1]|$R_8^{(t)}$ \\
};
\matrix(B) [matrix of nodes, below=5mm of A-1-2.south east, column sep=0.75cm] { $\oplus$ & $\oplus$ & $\oplus$ & $\oplus$\\ };
\draw[->] (A-1-1) edge node {}(B-1-1);
\draw node at (7,1)[field=.1] (i) {$<i>$};
\end{tikzpicture}
\end{document}
答案1
像这样?
矩阵 B 只需添加选项nodes={inner ysep=0pt},
:
\documentclass[tikz,border=2mm]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{amsmath}
\usetikzlibrary{matrix,positioning,shapes,arrows}
\begin{document}
\newcommand{\size}{\linewidth}
\begin{tikzpicture}[
every path/.style={draw, font=\small},
labelfield/.style={outer sep=0pt, minimum height=5mm,font=\small, anchor=center},
field/.style={outer sep=0pt, draw, minimum height=8mm,
minimum width=#1\size,font=\small,anchor=center}]
\matrix (A) [matrix of nodes, column sep=-\pgflinewidth,
row 1/.style={nodes={field=.1}}] {
|[field=.1]|$R_1^{(t)}$ & |[field=.1]|$R_2^{(t)}$ & |[field=.1]|$R_3^{(t)}$ & |[field=.1]|$R_4^{(t)}$ & |[field=.1]|$R_5^{(t)}$ & |[field=.1]|$R_6^{(t)}$ & |[field=.1]|$R_7^{(t)}$ & |[field=.1]|$R_8^{(t)}$ \\
};
\matrix(B) [matrix of nodes,
nodes={inner ysep=0pt}, % <---- added
column sep=0.75cm,
below=5mm of A-1-2.south east]
{ $\oplus$ & $\oplus$ & $\oplus$ & $\oplus$\\ };
\draw[->] (A-1-1) edge node {}(B-1-1);
\draw node at (7,1)[field=.1] (i) {$<i>$};
\end{tikzpicture}
\end{document}