有共同孙子的因果图

有共同孙子的因果图

我想要制作以下图表类型,但采用垂直方向(Common Grandchild Horizo​​ntal):

共同孙水平

具体来说,我希望我的图表中的 3 个孩子最终有一个共同的孙子。到目前为止,我有以下代码,但不知道如何绘制共同的孙子:

\documentclass[12pt]{article}

\usepackage{amssymb,amsmath,amsfonts,eurosym,geometry,ulem,graphicx,caption,subcaption, color,setspace,sectsty,comment,footmisc,caption,natbib,pdflscape,subfigure,array, enumerate, natbib, indentfirst, float, tikz, rotating, lipsum, adjustbox, booktabs, multirow, soul, changepage,threeparttable}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}



\usepackage[unicode, bookmarks, colorlinks, breaklinks]{hyperref}  

\hypersetup{colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=black, plainpages=false, pdfpagelabels=true, urlcolor=blue}


\usepackage[nameinlink, capitalise, noabbrev]{cleveref}
\bibliographystyle{abbrvnat}
\setcitestyle{authoryear,open={(},close={)}} %Citation-related commands

\normalem

\onehalfspacing
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{proposition}{Proposition}
\newtheorem{conj}{Conjecture}

\newenvironment{proof}[1][Proof]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}

\newtheorem{hyp}{Hypothesis}
\newtheorem{subhyp}{Hypothesis}[hyp]
\renewcommand{\thesubhyp}{\thehyp\alph{subhyp}}

\newcommand{\red}[1]{{\color{red} #1}}
\newcommand{\blue}[1]{{\color{blue} #1}}

\newcolumntype{L}[1]{>{\raggedright\let\newline\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\arraybackslash\hspace{0pt}}m{#1}}

\geometry{left=1.0in,right=1.0in,top=1.0in,bottom=1.0in}


\usetikzlibrary{shapes,arrows,intersections,arrows.meta,shadows,positioning}
\newcommand{\FixedLengthArrow}{2,0}

\begin{document}

\begin{figure}[H]
\centering
\begin{tikzpicture}[
  sibling distance=6cm,
  edge from parent/.append style={->},
  growth parent anchor=south,
  >=Latex
]

% root of the the initial tree, level 1
\node [root] (root) {Grandpa}
  % The first level, as children of the initial tree

    child {node {Father}  
      child {node (C1){Child}}
      child {node (C2) {Child}}
      child {node (C3) {Child}}
  }

    
\path (root-1-1-1.south)  -- coordinate (midway)   (root-1-1-1.south) ;


  
;
\end{tikzpicture}
\caption{Common Grandchild} 
\label{fig: Causal}
\end{figure}    

\end{document}

答案1

这边走?

由于你没有指定样式root,我发明了节点样式。

\documentclass[12pt]{article}
\usepackage{geometry}
\geometry{left=1.0in,right=1.0in,top=1.0in,bottom=1.0in}
\usepackage{setspace}
\usepackage{float}
\usepackage{ulem}
\usepackage{caption,subcaption}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,intersections,arrows.meta,shadows,positioning}

\usepackage[unicode, bookmarks, colorlinks, breaklinks]{hyperref}  
\hypersetup{colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=black, plainpages=false, pdfpagelabels=true, urlcolor=blue}

\normalem

\onehalfspacing

\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}[
  sibling distance=6cm,
  edge from parent/.append style={->},
  growth parent anchor=south,
  >=Latex,
  nodes={draw, fill=cyan,
      text width=3cm,
      text centered}
]
% root of the the initial tree, level 1
\node (root) {Grandpa}
  % The first level, as children of the initial tree
    child {node {Father}  
      child {node (C1) {Child}}
      child {node (C2) {Child}
        child {node (C21) {Grand child}}
        }
      child {node (C3) {Child}}
  };
  \draw [->] (C1) -- (C21)
    (C3) -- (C21);
\end{tikzpicture}
\caption{Common Grandchild} 
\label{fig: Causal}
\end{figure}    
\end{document}

在此处输入图片描述

答案2

使用forest包装:

\documentclass[border=3.141592]{standalone}

\usepackage{forest}
\usetikzlibrary{arrows.meta}
\tikzset{arr/.style = {draw=cyan, semithick, -{Triangle[angle=45:1pt 3]} },
  every edge/.style = {arr} }


\begin{document}
    \begin{forest}
for tree = {
% nodes
    draw=cyan, fill=cyan!30,
    minimum size=2.4ex, anchor=center,
% tree
    grow'=south,
    parent anchor=south,
    child anchor=north,
    l sep=7mm,
    s sep=3mm,
    edge = {arr},
    }
[Grandpa
    [Father 
        [Child, name=A]
        [Child,
            [Grand Child, name=C]
        ]
        [Child, name=B]
    ]
]
\path   (A)  edge (C) 
        (B)  edge (C);
    \end{forest}
\end{document}

森林

编辑: 作为对您的评论的回应。

该包forest 专用于树的高级绘制。基于tikz包(它也会加载)并可以使用其中的元素。

为了测试绘制图像的代码,需要使用standalone软件包。使用它开发的代码可以简单地复制到您的文档中,例如在您的案例中:

\documentclass[12pt]{article}

\usepackage{forest}
\usetikzlibrary{arrows.meta}
\tikzset{arr/.style = {draw=cyan, semithick, -{Triangle[angle=45:1pt 3]} },
  every edge/.style = {arr} 
        }
        
\usepackage{lipsum} % for dummy text filler        


\begin{document}
\lipsum[1][1-3]
    \begin{figure}[ht]
\centering
   \begin{forest}
for tree = {
% nodes
    draw=cyan, fill=cyan!30,
    minimum size=2.4ex, anchor=center,
% tree
    grow'=south,
    parent anchor=south,
    child anchor=north,
    l sep=7mm,
    s sep=3mm,
    edge = {arr},
    }
[Grandpa
    [Father
        [Child, name=A]
        [Child,
            [Grand Child, name=C]
        ]
        [Child, name=B]
    ]
]
\path   (A)  edge (C)
        (B)  edge (C);
    \end{forest}
\caption{Common Grandchild}
\label{fig: Causal}
    \end{figure} 

\lipsum[1][4-7]

\end{document}

由此得出

在此处输入图片描述

相关内容