有人能帮助我吗,我尽力了,但还是失败了。
\documentclass[12pt,a4paper]{report}
\usepackage{tikz,graphicx}
\begin{document}
\begin{figure}[!tb]
\begin{center}
\begin{tikzpicture}
%drawing shapes
\draw [fill=white] (1.5,0.3) rectangle (10,1.0);
\draw [thick] (6,1.5)-- (7,2)--(6.6,2)--(6.6,3.5)--(5.4,3.5)--(5.4,2)--(5,2)--(6,1.5);
\draw [fill=white] (5.4,3.56) rectangle (6.6,3.66);
\draw [fill=white] (5.4,3.7) rectangle (6.6,3.75);
\draw [thick] (1.8,3.9) to [out=180,in=270] (1.5,4.1)--(1.5,5.1) to [out=90,in=180] (1.8,5.3);
\draw [thick] (9.8,3.9) -- (10.5,3.9) --(10.5,5.3) -- (9.8,5.3);
\end{tikzpicture}
\end{center}
\end{figure}
\end{document}
答案1
我可能会使用nicematrix
包来创建上部矩阵,然后使用 Ti 添加其余部分钾Z(请注意,您可能需要在上面和下面添加一些间距,因为边界框可能有点偏离;
\documentclass[border=20pt]{standalone}
\usepackage{nicematrix, tikz}
\usetikzlibrary{calc}
\begin{document}
\(
\begin{NiceArray}{ l *{16}{c} }
\textbf{Dimension:}
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 \\
\textbf{Position:}
& 0 & 1 & 1 & 0 & 1 & 0 & 0 & 1 & 1 & 0 & 0 & 1 & 0 & 1 & 1 & 0 \\[2cm]
\CodeAfter
\OverBrace[shorten, yshift=5pt]{1-2}{1-9}{\textbf{First vehicle}}
\OverBrace[shorten, yshift=5pt]{1-10}{1-17}{\textbf{Second vehicle}}
\SubMatrix({1-2}{2-17}]
\begin{tikzpicture}
\coordinate (anchor) at ([shift={(-0.6,-0.35)}]$(2-9)!0.5!(2-10)$);
\draw (anchor) rectangle ++(1.2,-0.05);
\draw ([shift={(0,-0.125)}]anchor) rectangle ++(1.2,-0.1);
\draw ([shift={(0,-0.3)}]anchor) -| ++(1.2,-0.5)
-- ++(0.5,0) -- ++(-1.1,-0.75) coordinate (tip)
-- ++(-1.1,0.75) -- ++(0.5,0) -- cycle;
\node[draw] at ([shift={(0,-0.5)}]tip) {
(1,2), (2,1), (3,1), (4,2), (5,1), (6,2), (7,2), (8,1)
};
\end{tikzpicture}
\end{NiceArray}
\)
\end{document}
或者你可以纯粹用 Ti 创建它钾Z 并使用\matrix
:
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc, matrix, decorations.pathreplacing, calligraphy}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes, every node/.style={anchor=base, minimum width={1.5em}}] (m) {
|[text width={6em}, align=left]| \textbf{Dimension:}
& 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8
& 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 \\
|[text width={6em}, align=left]|\textbf{Position:}
& 0 & 1 & 1 & 0 & 1 & 0 & 0 & 1
& 1 & 0 & 0 & 1 & 0 & 1 & 1 & 0 \\
};
\draw[decorate, decoration={calligraphic curved parenthesis, mirror}]
(m-1-2.north west) -- (m-2-2.south west);
\draw (m-1-17.north east) -- ++(1.5pt,0) |-
(m-2-17.south east -| m-1-17.north east);
\draw[decorate, decoration={calligraphic brace}]
([xshift=2pt]m-1-2.north west) -- ([xshift=-2pt]m-1-9.north east)
node[midway, above=2pt] {\textbf{First vehicle}};
\draw[decorate, decoration={calligraphic brace}]
([xshift=2pt]m-1-10.north west) -- ([xshift=-2pt]m-1-17.north east)
node[midway, above=2pt] {\textbf{Secoond vehicle}};
\coordinate (anchor) at ([yshift=-2pt]$(m-2-8.south)!0.5!(m-2-9.south)$);
\draw (anchor) rectangle ++(1.2,-0.05);
\draw ([shift={(0,-0.125)}]anchor) rectangle ++(1.2,-0.1);
\draw ([shift={(0,-0.3)}]anchor) -| ++(1.2,-0.5)
-- ++(0.5,0) -- ++(-1.1,-0.75) coordinate (tip)
-- ++(-1.1,0.75) -- ++(0.5,0) -- cycle;
\node[draw] at ([shift={(0,-0.5)}]tip) {
(1,2), (2,1), (3,1), (4,2), (5,1), (6,2), (7,2), (8,1)
};
\end{tikzpicture}
\end{document}