有两个根的树

有两个根的树

我想将根证书放在 CA 根目录下(但不在同一棵树中)。这是我的 mwe

\documentclass{article}
\usepackage{xcolor}
\usepackage{tikz} 
    \setlength{\parindent}{0pt}
    \usetikzlibrary{calc}
    \usetikzlibrary{backgrounds}
    \usetikzlibrary{chains}
    \usetikzlibrary{trees}

\begin{document}
    \tikzstyle{every node}=[draw=black,thick,anchor=west]
    \tikzstyle{selected}=[dashed,fill=red!30]
    \tikzstyle{optional}=[dashed,fill=blue!50]
        \begin{tikzpicture}[%
        grow via three points={one child at (0.5,-0.7) and
        two children at (0.5,-0.7) and (0.5,-1.4)},
           show background rectangle,
        background rectangle/.style={fill=gray!10},
        edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
        \node {ca}
        child { node {root-ca}
            child { node {01.pem}}
            child { node {02.pem}}
            child { node {db}
            child { node {...}}}
            child [missing] {}
            child { node {private}
            child { node {root-ca.key}}}
        }
        child [missing] {}
        child [missing] {}
        child [missing] {}
        child [missing] {}
        child [missing] {}
        child [missing] {}
        child { node {root-ca.crt}}
        child { node {root-ca.csr}}
        child { node  {signing-ca}
            child { node [selected]{01.pem}}
            child { node{02.pem}}
        child { node {db}
        child { node {...}}}
        child [missing] {}
             child { node {private}
                child { node {signing-ca.key}}}
        }
        child [missing] {}    child [missing] {}    child [missing] {}    child [missing] {}  child [missing] {}
        child { node {root-ca.crt}}
        child { node {root-ca.csr}};
        \end{tikzpicture}
        \begin{tikzpicture}[%
        grow via three points={one child at (0.5,-0.7) and
        two children at (0.5,-0.7) and (0.5,-1.4)},
        show background rectangle,
        background rectangle/.style={fill=gray!10},
        edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
        \node {certs}
            child { node {simple.org.crt}}
            child { node {simple.org.csr}}
            child { node [optional]{simple.org.key}};
        \end{tikzpicture}
\end{document} 

这里的输出在此处输入图片描述

答案1

我无法重现您的输出并且不知道如何mycolor定义,但您可以使用该positioning库:

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{trees,backgrounds,positioning}
\begin{document}

\tikzset{every node/.style={draw=black,thick,anchor=west},
  selected/.style={dashed,fill=red!30},
  optional/.style={dashed,fill=gray!50},}
   \begin{tikzpicture}[%
        grow via three points={one child at (0.5,-0.7) and
        two children at (0.5,-0.7) and (0.5,-1.4)},
           show background rectangle,
        background rectangle/.style={fill=gray!10},
        edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.west)}]
        \node (ca) {ca}
        child { node {root-ca}
            child { node {01.pem}}
            child { node {02.pem}}
            child { node {db}
            child { node {...}}}
            child [missing] {}
            child { node {private}
            child { node {root-ca.key}}}
        }
        child [missing] {}
        child [missing] {}
        child [missing] {}
        child [missing] {}
        child [missing] {}
        child [missing] {}
        child { node {root-ca.crt}}
        child { node {root-ca.csr}}
        child { node  {signing-ca}
            child { node [selected]{01.pem}}
            child { node{02.pem}}
        child { node {db}
        child { node {...}}}
        child [missing] {}
             child { node {private}
                child { node {signing-ca.key}}}
        }
        child [missing] {}    child [missing] {}    child [missing] {}    child [missing] {}  child [missing] {}
        child { node {root-ca.crt}}
        child { node {root-ca.csr}};

        \node [below=of ca.center |- current bounding box.south] {certs}
            child { node {simple.org.crt}}
            child { node {simple.org.csr}}
            child { node [optional]{simple.org.key}};
        \end{tikzpicture}
\end{document}

树下有树

相关内容