关于连接节点的一些帮助。我希望箭头从节点 B 和 C 直接移动到节点 G,但我得到了一些不同的东西,下面是代码

关于连接节点的一些帮助。我希望箭头从节点 B 和 C 直接移动到节点 G,但我得到了一些不同的东西,下面是代码
\begin{figure}[ht]
            \begin{tikzpicture}[node distance=1cm, text width=4.5 cm, rounded corners]

% nodes
            %   \node (A) [draw, align = center, font = \small] at (0, 12) {\textbf{Potential Viral Load Explainers}};
                \node(B)[draw, align = center, font = \small] at (0,10){\underline{\textbf{\emph{Socio-demographic: (SDF)}}} \\ Gender, Socio support, Age (age category), and Marital status };
                \coordinate (point0) at (-2,8.7);
%               \node(emp1)[draw, align = center, right = of B, style = invis] at (12,10){\phantom{empty};
                %\node (q_5) [right=of q_4] {\phantom{$\cdots$}};
%               \coordinate (point0) at (-2,8.7);
%               \coordinate (point1) at (2.4,10);
%               \coordinate (point3) at (12,10);
                \node(C)[draw, align = center, font = \small] at (1.2, 5.5){\underline{\textbf{Intermediate Variables:}} \\\textbf{ \emph{ART Factors}}\\ Duration on ART, Suppression history, Changing ART, adherence to ART\\ \textbf{\emph{Clinical Factors}} \\ BMI, WHO clinical stages};
                \coordinate (point3) at (1,3.05);
                
                \coordinate (point4) at (8,2);
                
                \node (I) [draw, align = center, right=of C, font = \small] at (3, 1) {\underline{\textbf{Dependent Variable}} \\ \emph{Viral Load Measurements} };
                \coordinate (point4) at (12.2,-1.7);
                \node (G)[draw, align = center, right=of I, font = \small] {\textbf{Multiple \\Imputation}};
                \node (F)[draw, align = center, below=of G, font = \small] {\textbf{SMF}};
                \coordinate (point2) at (12.2,-1.7);
                
            \node (H)[draw, align = center, below=of F, font = \small] {\textbf{RMF}};
% Arrows
            \draw[-] (F) -- coordinate (midDT) (H);
            \draw[->] (G) -- +(3,0) |- (midDT);
            \draw[->] (I) |- (point2);
            \draw[->] (point0) |- (I);
            \draw[->] (point3) |- (I);
            \draw[-] (F) edge (H);
            \draw[->] (I) edge (G);
            \draw[->] (B) |- (G);
            \draw[->] (C) |- (point4);

        \end{tikzpicture}
        \caption{Conceptual Framework} 
        \end{figure}

答案1

  • 抱歉,但坦率地说,您的代码片段很乱……
  • 下面,基于纯粹的猜测,尝试清理您的代码片段,使其变得更清晰,简洁或至少使其摆脱混乱,但在此我可能会错过您的节点的放置。
  • 至少它可以作为您编辑问题的起点(此外,我们需要一个草图,了解您所追求的是什么,到目前为止问题还不清楚)。
  • 在我的 MWE(最小工作示例)中,几乎所有的坐标定义都删除了(我估计它们是多余的)。
  • 节点相对于彼此定位(使用positioning库。
  • 目前还不清楚节点是如何连接的。
  • 我不会在粗体文字下划线。
  • 我向节点文本添加了节点名称(正如我认为应该的那样)。

梅威瑟:

\documentclass{article}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                ext.paths.ortho,    % defined in the tikz-ext package
                positioning}

\begin{document}
\begin{figure}[ht]
    \begin{tikzpicture}[
            > = Straight Barb,
node distance = 6mm and 4mm, 
N/.style = {draw, rounded corners, semithick, font=\small,
            text width=44mm, align=center}, % common style for all nodes
                        ]

% nodes
\node (A) [N]   {"A", 
                \textbf{Potential Viral Load Explainers}};
\node (B) [N, below=of A]   
                {"B", 
                \textbf{\emph{Socio-demographic: (SDF)}} \\ Gender, Socio support, Age (age category), and Marital status};
\node (C) [N, below=of B]   
                {"C", 
                \textbf{Intermediate Variables:} \\
                 \textbf{\emph{ART Factors}}\\ 
                 Duration on ART, Suppression history, Changing ART, adherence to ART\\ \textbf{\emph{Clinical Factors}} \\
                 BMI, WHO clinical stages};
\node (I) [N, below right=of C]   
                {"I",
                \textbf{Dependent Variable} 
                \emph{Viral Load Measurements} };
\node (G) [N, right=of I] {"G",
                \textbf{Multiple Imputation}};
\node (F) [N, below=of G] {"F",
                \textbf{SMF}};
\node (H) [N, below=of F] {"H", 
                \textbf{RMF}};
% Arrows
    \draw[->]   (B) -| ([xshift=+2mm] G.north);
    \draw[->]   (C) -| ([xshift=-2mm] G.north);
    \draw       (F) -- coordinate (midDT) (H);      
    \draw[->]   (G.east) r-rl (midDT);  % as defined in the ext.paths.ortho library
    \end{tikzpicture}
\caption{Conceptual Framework}
        \end{figure}
\end{document}

在此处输入图片描述

相关内容