调整此图形的边缘以适合边距吗?

调整此图形的边缘以适合边距吗?

考虑:

\documentclass[12pt,a4paper,oneside]{book}
\usepackage[nottoc]{tocbibind}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage{bm}
\usepackage{nccmath}
\usepackage{amsfonts, graphicx, verbatim, mathtools,amssymb, amsthm, mathrsfs,amsmath}
\usepackage{color}
\usepackage{array}
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{rsfso}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{babel, arrows.meta, positioning, quotes}
\usepackage{parskip}
\usepackage{lipsum}
\usepackage{floatrow}
\usepackage{epstopdf}
\usepackage[capitalise]{cleveref}
\usepackage{siunitx}
\usepackage{tocloft}
\usepackage{listings}
\usepackage{booktabs}
\usepackage{nicematrix}
\usepackage{subcaption}
\usepackage{geometry}
\usepackage{tabularray} 
\UseTblrLibrary{booktabs}
\usepackage[thinc]{esdiff}
\usepackage [english]{babel}
\usepackage [autostyle, english = american]{csquotes}
\usepackage[style=numeric,maxbibnames=99,sortcites=true,backend=bibtex]{biblatex}
\allowdisplaybreaks

\begin{document}
\begin{figure} \centering
  \begin{tikzpicture}[
node distance = 11mm and 33mm,
     N/.style = {draw, minimum size=12mm, inner sep=0pt},
            > = {Stealth[scale=0.6]},
 every edge/.append style = {draw, ->},
every edge quotes/.append style = {font=\small\linespread{0.75}\selectfont,
                                   inner sep=5pt, sloped}
                        ]
\node [N] (A) {$S$};
\node [N,above right=of A] (B) {$I_1$};
\node [N,below right=of A] (C) {$I_2$};
\node [N,above right=of C] (D) {$J$};
\node [N,right=of D] (E)  {$A$};
%
\draw [<-] (A) -- ++(-1,0) node[left] {$\mu$};
\draw [->] (A) -- ++(0,-1) node[below] {$\nu S$};
\draw [->] ([xshift=3.75mm] B.south) -- ++(0,-0.4) node[below] {$\nu I_1$};
\draw [->] (C) -- ++(0,-1) node[below] {$\nu I_2$};
\draw [->] (D) -- ++(0,-1) node[below] {$\nu J$};
\draw [->] ([xshift=-3.5mm] E.south) -- ++(0,-0.4) node[below] {$\alpha A$};
\draw [->] ([xshift=+3.5mm] E.south) -- ++(0,-0.4) node[below] {$\nu A$};
%
\draw   ([yshift=+1mm] A.east)
            edge [ultra thick, draw=gray,"\slash\slash\slash" anchor=center,
                  "$\begin{gathered}
                        p\beta_1 S I_2\\
                        q\beta_2 S J\\
                        r\beta_3 S A
                    \end{gathered}$" ] (B.west)
        ([yshift=-1mm] A.east)
            edge [ultra thick, draw=gray,"\slash\slash\slash" anchor=center,
                  "$\begin{gathered}
                        (1-p)\beta_2 S I_2\\
                        (1-q)\beta_2 S J\\
                        (1-r)\beta_3 S A
                    \end{gathered}$" '] (C.west)
       (B) edge [rotate=90,"$\epsilon I_1$"] (C)
        (D.west) edge ["$\xi_1 J$"  ] ( B.east)
        ( C.east) edge ["$p_1 I_2$"  ] (D.west)
        ([yshift=-2mm] D.west) edge ["$\xi_2 J$" '] ([yshift=-2mm] C.east)
    (D) edge ["$p_2 J$"] (E);
\end{tikzpicture}
\setlength{\textfloatsep}{10pt plus 1.0pt minus 2.0pt}
\caption{Flow diagram for the HIV/AIDS model.}
\end{figure}

\end{document}

我怎样才能让这个数字适合边距?我们可以缩放它,也可以将线边从“J”缩小到“A”。我认为后者更好,但我等待您的回复。

答案1

这个解决方案是通用的(我在“必须”使用单位的情况下使用它):

\documentclass[12pt,a4paper,oneside,showframe]{book}
\usepackage[nottoc]{tocbibind}
\usepackage[utf8]{inputenc} 
\usepackage[T1]{fontenc} 
\usepackage{bm}
\usepackage{nccmath}
\usepackage{amsfonts, graphicx, verbatim, mathtools,amssymb, amsthm, mathrsfs,amsmath}
\usepackage{color}
\usepackage{array}
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{rsfso}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{babel, arrows.meta, positioning, quotes, calc}
\usepackage{parskip}
\usepackage{lipsum}
\usepackage{floatrow}
\usepackage{epstopdf}
\usepackage[capitalise]{cleveref}
\usepackage{siunitx}
\usepackage{tocloft}
\usepackage{listings}
\usepackage{booktabs}
\usepackage{nicematrix}
\usepackage{subcaption}
\usepackage{geometry}
\usepackage{tabularray} 
\UseTblrLibrary{booktabs}
\usepackage[thinc]{esdiff}
\usepackage [english]{babel}
\usepackage [autostyle, english = american]{csquotes}
\usepackage[style=numeric,maxbibnames=99,sortcites=true,backend=bibtex]{biblatex}
\allowdisplaybreaks

\begin{document}

\begin{figure} \centering
\def\mscale{0.93}%
  \begin{tikzpicture}[
  scale=0.9,
node distance = {11*\mscale mm} and {33*\mscale mm},
     N/.style = {draw, minimum size={12*\mscale mm}, inner sep=0pt},
            > = {Stealth[scale={0.6*\mscale}]},
 every edge/.append style = {draw, ->},
every edge quotes/.append style = {font=\small\linespread{0.75}\selectfont,
                                   inner sep={5*\mscale pt}, sloped}
                        ]
\node [N] (A) {$S$};
\node [N,above right=of A] (B) {$I_1$};
\node [N,below right=of A] (C) {$I_2$};
\node [N,above right=of C] (D) {$J$};
\node [N,right=of D] (E)  {$A$};
%
\draw [<-] (A) -- ++(-1,0) node[left] {$\mu$};
\draw [->] (A) -- ++(0,-1) node[below] {$\nu S$};
\draw [->] ([xshift={3.75*\mscale mm}] B.south) -- ++(0,-0.4) node[below] {$\nu I_1$};
\draw [->] (C) -- ++(0,-1) node[below] {$\nu I_2$};
\draw [->] (D) -- ++(0,-1) node[below] {$\nu J$};
\draw [->] ([xshift={-3.5*\mscale mm}] E.south) -- ++(0,-0.4) node[below] {$\alpha A$};
\draw [->] ([xshift={3.5*\mscale mm}] E.south) -- ++(0,-0.4) node[below] {$\nu A$};
%
\draw   ([yshift={1*\mscale mm}] A.east)
            edge [ultra thick, draw=gray,"\slash\slash\slash" anchor=center,
                  "$\begin{gathered}
                        p\beta_1 S I_2\\
                        q\beta_2 S J\\
                        r\beta_3 S A
                    \end{gathered}$" ] (B.west)
        ([yshift={-1*\mscale mm}] A.east)
            edge [ultra thick, draw=gray,"\slash\slash\slash" anchor=center,
                  "$\begin{gathered}
                        (1-p)\beta_2 S I_2\\
                        (1-q)\beta_2 S J\\
                        (1-r)\beta_3 S A
                    \end{gathered}$" '] (C.west)
       (B) edge [rotate=90,"$\epsilon I_1$"] (C)
        (D.west) edge ["$\xi_1 J$"  ] ( B.east)
        ( C.east) edge ["$p_1 I_2$"  ] (D.west)
        ([yshift={-2*\mscale mm}] D.west) edge ["$\xi_2 J$" '] ([yshift={-2*\mscale mm}] C.east)
    (D) edge ["$p_2 J$"] (E);
\end{tikzpicture}
\setlength{\textfloatsep}{10pt plus 1.0pt minus 2.0pt}
\caption{Flow diagram for the HIV/AIDS model.}
\end{figure}

\end{document}

作为补充(我使用了tikzlibrary calc

我的方式...将每个维度与定义的\mscale(我的比例)相乘,并将选项添加到的可选参数scale=\mscale中。tikzpicture

在其他情况下,你不必使用单位...不要使用它们...在这种情况下,秤会起作用

额外(font=\mfont为每个节点添加额外命令,以便能够根据需要降低或增加字体大小)

在此处输入图片描述

相关内容