我怎样才能用 LaTeX 制作这样的图表?
答案1
答案2
这是一个使用 Tikz 矩阵节点的解决方案
\documentclass[border=1mm,tikz]{standalone}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}[font=\footnotesize,%
boxes/.style={draw, rectangle,%
thick,minimum height=6mm,%
text width=6mm,
align=center}]
\matrix (A) [matrix of nodes, nodes=boxes,
row sep=1cm,column sep=1cm]
{
|(A-3-1)| & |(A-3-2)| & |(A-3-3)| & |(A-3-4)| & |(A-3-5)| \\
|(A-2-1)| & |(A-2-2)| & |(A-2-3)| & |(A-2-4)| & |(A-2-5)| \\
|(A-1-1)| & |(A-1-2)| & |(A-1-3)| & |(A-1-4)| & |(A-1-5)| \\
};
\foreach \i/\j in {3/2,2/1}
{
\draw (A-\i-1)--(A-\j-1); \draw (A-\i-2)--(A-\j-2);
\draw (A-\i-3)--(A-\j-3); \draw (A-\i-5)--(A-\j-5);
}
\draw (A-1-3)--(A-1-4)--(A-1-5);
\draw (A-3-3)--(A-3-4)--(A-3-5);
\draw (A-3-1.south east) -- (A-2-2.north west)
(A-2-2.south east) -- (A-1-3.north west);
\draw (A-3-2.south east) -- (A-2-3.north west)
(A-2-3.south east) -- (A-1-4.north west);
\draw (A-3-3.south east) -- (A-2-4.north west)
(A-2-4.south east) -- (A-1-5.north west);
\node [red] at (A-3-5) {9};
\node [red] at (A-1-3) {4};
\end{tikzpicture}%
\end{document}
答案3
类似图表的示例(使用 TikZ)
答案4
只是为了好玩,我用堆栈做了这件事......
\documentclass{article}
\usepackage[usestackEOL]{stackengine}[2013-10-15]
\usepackage{graphicx, xcolor}
\def\thk{.2pt}
\def\sz{1.3ex}
\def\sqt{1.40}
\def\hgap{.72ex}
\def\hrl{\rule{\ht\strutbox+\dp\strutbox-\thk}{\thk}}
\def\vrl{\rule{\thk}{\ht\strutbox+\dp\strutbox-\thk}}
\newcommand\drl{\rotatebox{135}{\rule{\sqt\ht\strutbox+\sqt\dp\strutbox}{\thk}}}
\def\nhrl{\rule{\ht\strutbox+\dp\strutbox}{0pt}}
\def\nvrl{\rule{0pt}{\ht\strutbox+\dp\strutbox}}
\def\nnrl{\rule{\thk}{\thk}}
\newcommand\ndrl{\rotatebox{45}{\rule{\sqt\ht\strutbox+\sqt\dp\strutbox}{0pt}}}
\newcommand\fsq[1]{\fboxsep=0pt\fboxrule=0.2pt\hspace{\hgap}%
\stackinset{c}{}{c}{}{\tiny #1}{%
\fbox{\colorbox{white}{\rule{\sz}{0ex}\rule{0ex}{\sz}}}}\hspace{\hgap}}
\begin{document}
\setstackgap{S}{-.15pt}
\def\stacktype{L}
\stackon[-2.7pt]{%
\Shortstack[l]{
\nnrl\nhrl\nnrl\nhrl\nnrl\hrl \nnrl\hrl\nnrl\\
\vrl \drl \vrl \drl \vrl \drl \nvrl\nhrl\vrl\\
\nnrl\nhrl\nnrl\nhrl\nnrl\nhrl\nnrl\nhrl\nnrl\\
\vrl \nhrl\vrl \drl \vrl \drl \nvrl\drl\vrl\\
\nnrl\nhrl\nnrl\nhrl\nnrl\hrl \nnrl\hrl\nnrl}
}{\kern-3.3pt\Longstack{%
\fsq{}\fsq{}\fsq{}\fsq{}\fsq{9}\\
\fsq{}\fsq{}\fsq{}\fsq{}\fsq{}\\
\fsq{}\fsq{}\fsq{4}\fsq{}\fsq{}}
}
\end{document}