在 LaTeX 中绘制图表

在 LaTeX 中绘制图表

在此处输入图片描述

我怎样才能用 LaTeX 绘制这个图表?

答案1

我正在使用tikz-cdsmallmatrix显然,您可以更改数字并设置宏来每次替换小矩阵。

在此处输入图片描述

\documentclass[a4paper,12pt]{article}

\usepackage{tikz-cd}
\usepackage{mathtools}

\begin{document}

\begin{tikzcd}
 & \begin{smallmatrix}     0 & 0 & 0 \\      & 0 &            \end{smallmatrix}  \arrow[rd] &  & \begin{smallmatrix}     1 & 0 & 0 \\      & 0 &            \end{smallmatrix}  \arrow[rd] &  &  \\
 &  & \begin{smallmatrix}     1 & 1 & 0 \\      & 1 &            \end{smallmatrix}  \arrow[rd] \arrow[ru] &  & \begin{smallmatrix}     0 & 0 & 0 \\      & 1 &            \end{smallmatrix}  \arrow[rd] &  \\
 & \begin{smallmatrix}     0 & 0 & 0 \\      & 1 &            \end{smallmatrix}  \arrow[ru] \arrow[rd] &  & \begin{smallmatrix}     0 & 0 & 0 \\      & 1 &            \end{smallmatrix}  \arrow[ru] \arrow[rd] &  & \begin{smallmatrix}     1 & 0 & 0 \\      & 1 &            \end{smallmatrix}  \\
\begin{smallmatrix}     1 & 1 & 1 \\      & 1 &            \end{smallmatrix}  \arrow[ru] &  & \begin{smallmatrix}     0 & 0 & 0 \\      & 1 &            \end{smallmatrix}  \arrow[ru] &  & \begin{smallmatrix}     0 & 0 & 0 \\      & 0 &            \end{smallmatrix}  \arrow[ru] & 
\end{tikzcd}

\end{document}

答案2

欢迎来到 TeX.SX!这是使用简单 Ti 的尝试Z。

\documentclass{article}
\usepackage{tikz}
\tikzset{every node/.style={align=center}} 
% To align all nodes as centered (Thank you, CarLaTeX, for showing me this)
\begin{document}
\begin{tikzpicture}[x=1cm,y=0.8cm]
    \node at (0,0) (a) {1};
    \node at (1,-1) (b) {2};
    \node at (0,-2) (c) {3};
    \node at (-1,-3) (d) {4};
    \node at (1,-3) (e) {5};
    \node at (2,-2) (f) {6};
    \node at (2,0) (g) {7};
    \node at (3,-1) (h) {8};
    \node at (3,-3) (i) {9};
    \node at (4,-2) (j) {10};
    \draw [->] (a)--(b);
    \draw [->] (c)--(b);
    \draw [->] (d)--(c);
    \draw [->] (c)--(e);
    \draw [->] (e)--(f);
    \draw [->] (b)--(f);
    \draw [->] (b)--(g);
    \draw [->] (f)--(h);
    \draw [->] (g)--(h);
    \draw [->] (f)--(i);
    \draw [->] (i)--(j);
    \draw [->] (h)--(j);
\end{tikzpicture}
\end{document}

在此处输入图片描述

现在您只需用适当的内容替换数字即可。

答案3

这是一份工作tikz-cd

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{array}
\newcommand{\mycell}[1]{\begin{array}{c}
     #1 
\end{array}}
\begin{document}
\[
\begin{tikzcd}
&\mycell{000 \\ 1}\ar[dr] & & \mycell{111 \\ 0}\ar[dr]\\
&&\mycell{111 \\ 1}\ar[dr]\ar[ur] & &  \mycell{110 \\ 0}\ar[dr]\\
&\mycell{011 \\ 0}\ar[dr]\ar[ur] & & \mycell{110 \\ 1}\ar[dr]\ar[ur] & & \mycell{100\\0}\\
\mycell{001 \\ 0}\ar[ur] & &\mycell{101 \\ 1}\ar[ur] & &  \mycell{110 \\ 0}\ar[ur]\\
\end{tikzcd}
\]
\end{document}

在此处输入图片描述

相关内容