Graphics, Figures & TablesMultiple Lines in Node of Tree

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mayankmi
Posts: 45
Joined: Sat Apr 20, 2013 7:52 pm

Multiple Lines in Node of Tree

Post by mayankmi »

I want to add the content in () in next line I tried \\ after but it does not work. For example, instead of this.

Code: Select all

Schmidt Hammer (0.1003)
I want something like this

Code: Select all

Schmidt Hammer
   (0.1003)

Code: Select all

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{trees}  % this is to allow the fork right path

\begin{document}
  \begin{center}
    \begin{tikzpicture}[-,thick]
      \node {Total Rating (1.0)} [sibling distance=6cm]
        child {node {Literature Knowledge \newline   (0.1147)}
      }
        child {node {Schmidt Hammer (0.1003)}
      }
        child {node {Direct compression test (0.7672)}
      };
    \end{tikzpicture}
  \end{center}
\end{document}
Thanks

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

tom
Posts: 73
Joined: Thu Apr 18, 2013 4:02 am

Multiple Lines in Node of Tree

Post by tom »

When using the align property of node, \\ works.

Code: Select all

\node {Total Rating (1.0)} [sibling distance=6cm, align=center]
    child {node {Literature Knowledge\\(0.1147)}
  }
    child {node {Schmidt Hammer\\(0.1003)}
  }
    child {node {Direct compression test\\(0.7672)}
  };
mayankmi
Posts: 45
Joined: Sat Apr 20, 2013 7:52 pm

Re: Multiple Lines in Node of Tree

Post by mayankmi »

Thank you! It works.
Post Reply