0

Good day. I have problem on creating a node and its name. Here is the code number 1 and 2.

\documentclass[a4paper, 12pt]{article}
% Preamble

% Packages used for input and output display.
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

% package used for images and colors.
\usepackage{graphicx}
\usepackage{xcolor}

% Page layout.
\usepackage[a4paper,margin=2cm]{geometry}
% Package used for diagram.
\usepackage{tikz}
\usetikzlibrary{trees,positioning,shapes,shadows,arrows.meta}
% beginning document.
\begin{document}

% Steps 1. 
% 1. create  a node.
% 2. 
%
\begin{tikzpicture}
 
  \node{root}             % code 1.
     child{node{Arrows}}  % This command works.
  
  \node[root]{Data}   %  code 2. does not work
;

\end{tikzpicture}

\end{document}

In the above code 1 works while code 2 does not work.

1 Answer 1

2

Your code as is doesn't work simply because you forgotten to end the first \node instruction with a semicolon.

But even adding that missing semicolon your second node doesn't work because you haven't defined a style named root. You have \node[root]{Data};. Here root is a style for the node, because it's in square brackets, while Data is the content of the node, in curly braces.

\documentclass{article}
\usepackage{tikz} % loads xcolor and graphicx
\begin{document}
\begin{tikzpicture}[root/.style={}] % defined empty root style
 
  \node{groot}             % code 1.
     child{node{Arrows}};  % <-- added semicolon
  
  \node[root]{Data};    % note this is placed in the same place as the first node of the tree, because you didn't specify the position of any of them

\end{tikzpicture}
\end{document}
1
  • Thank you very much Torbjørn . Aug 3 at 3:40

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.