2

While @cfr provided an excellent solution to my post here, I have a problem when I insert the code in my main document, though it works fine as a standalone document. It gives me the error: ! Illegal parameter number in definition of \pgfmath@expression, suggesting the error is at \end{forest}. While forest seems to be more convenient for tree-diagrams, I find it very difficult. It will take me time to be able sort out my problem of the forest package. I am therefore reproducing my mwe in tikz, with only the tree-diagram and where I want the labels (as commented out in my code).

\documentclass[12pt]{report}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[inner sep=1.5pt]
\node (10) {z}
child { node {x}
child { node {s}}
   child { node {t}}}
child { node {y}
child { node {s}}
child { node {t}}}
;
%    \node      (from z to x) {$\frac{\partial z}{\partial x}$};
%    \node      (from z to y) {$\frac{\partial z}{\partial y}$};
%    \node      (from x to s) {$\frac{\partial x}{\partial s}$};
%    \node      (from x to t) {$\frac{\partial x}{\partial t}$};
%    \node      (from y to s) {$\frac{\partial y}{\partial s}$};
%    \node      (from y to t) {$\frac{\partial y}{\partial t}$};

\end{tikzpicture}
\end{document}
3

Suggestion only with TikZ:

\documentclass[12pt]{report}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[inner sep=1.5pt]
\node (10) {z}
  [ auto,
    sibling distance=2.4cm,
    level distance=2cm,
    level 2/.append style={
      sibling distance=1.8cm,
      level distance=1.5cm
    },
    edge from parent/.append style={nodes={pos=.6}}
  ]
  child { node {x}
    child { node {s}
      edge from parent node[swap]{$\frac{\partial x}{\partial s}$}
    }
    child { node {t}
      edge from parent node{$\frac{\partial x}{\partial t}$}
    }
    edge from parent node[swap]{$\frac{\partial z}{\partial x}$}
  }
  child { node {y}
    child { node {s}
      edge from parent node[swap]{$\frac{\partial y}{\partial s}$}
    }
    child { node {t}
      edge from parent node{$\frac{\partial y}{\partial t}$}
    }
    edge from parent node{$\frac{\partial z}{\partial y}$}
}
;
\end{tikzpicture}
\end{document}

enter image description here

  • Thank you very much @esdd. This works perfectly for me. This, together with forest code from cfr provides me very good learning material. I am very grateful to both of you. Hoping this be your best year ever. – Zilore Mumba May 23 '17 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.