如何在 LaTeX 中绘制图表

如何在 LaTeX 中绘制图表

有人知道如何用 LaTeX 制作这个图表吗?

在此处输入图片描述

答案1

2更改中的值\resizebox{2\textwidth}{!}{...}以自动调整图表大小。

输出

\documentclass[border=3.14mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{automata, arrows.meta, positioning, shapes}
 
\begin{document}
\resizebox{2\textwidth}{!}{
\begin{tikzpicture}[
>={Stealth[round]},
line width=0.8pt, % make all arrow thicker
state/.style={draw,rounded rectangle,line width=0.4pt},%the state style which has the line width as normal
]
    % Top row
    \node [state, initial, initial text = {I}] (q0) at (0, 0) {$\lbrace q_1,q_2,q_3,q_4,q_8,q_{14} \rbrace$};
    \node [state, right=2cm of q0] (q1){$\lbrace q_9,q_{10},q_{15},q_{16} \rbrace$};
    \node [state, right=2cm of q1] (q2){$\lbrace q_{11},q_{12} \rbrace$};
    % Middle row
    \node [state, accepting,xshift=0.5cm, below=2cm of q0] (q3){$\lbrace q_2,q_3,q_4,q_7,q_8,q_{14} \rbrace$};
    \node [state, accepting,right=1cm of q3] (q4){$\lbrace q_2,q_3,q_4,q_8,q_{14},q_{19} \rbrace$};
    \node [state, right=1cm of q4] (q5){$\lbrace q_{17},q_{18} \rbrace$};
    % Bottom row
    \node [state, below=2cm of q3.west] (q6){$\lbrace q_5,q_6 \rbrace$};
    \node [state, yshift=-1.75cm, accepting,below=1cm of q4] (q7){$\lbrace q_2,q_3,q_4,q_8,q_{13},q_{14} \rbrace$};
    \node [state, right=10.5cm of q6] (q8){$\emptyset$};
    %Drawing the simple arrows (straight, self loops and curved)
    \path [->]
    (q0) edge[above] node {$0_a$} (q1)
    (q1) edge[above] node {$0_b$} (q2)
    (q5) edge[above] node {$0_c$} (q4)
    (q1) edge[above,bend left] node {$1_d$} (q5)
    (q4.north) edge[right] node {$0_e$} (q4.north|-q2.south)
    (q3) edge[left,bend right] node {$0_f$} (q1.200)
    (q0.south west) edge[left] node {$1_g$} (q0.south west|-q6.north west)
    (q6) edge[left] node {$0_h$} (q3.200)
    (q3.210) edge[right] node {$1_i$} (q6.35)
    (q4) edge[above] node [rotate=20]{missing} (q6)
    (q6) edge[above] node {$1_j$} (q8)
    (q5) edge[right,bend right] node {$1_k$} (q8)
    (q2.340) edge[left] node {$0_l$} (q2.340|-q8.north)
    (q8) edge [loop below] node {\small $0,1$}()
    ; % This semicolon is needed!
    % Drawing the complex lines that have at least one 90 degree turn
    \draw[->, rounded corners] (q7.west) -| node[above, pos=0.25]{$1_m$} (q6.south);
    \draw[->, rounded corners] (q2.east) -- ++(0.5,0) |- node[left, pos=0.25]{$1_n$} (q7.east);
    \draw[->, rounded corners] (q7.south) |- +(6.5,-0.5) |- node[left, pos=0.25]{$0_o$} ++(1,7) -| (q1.north);
\end{tikzpicture}
}
\end{document}

相关内容