Graphics, Figures & TablesCreating a Diagram

Information and discussion about graphics, figures & tables in LaTeX documents.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Creating a Diagram

Post by localghost »

If you aim to produce PDF as final output format, PDFLaTeX is the way to go.

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

steFON
Posts: 9
Joined: Wed Mar 13, 2013 5:23 pm

Creating a Diagram

Post by steFON »

Can I ask one more advice? :) I need to create something like in picture below. I tried to do it with this:

Code: Select all

\Tree [.first second1}
                    [.second2 third1}
                              third2 ]]
but I do not know how to put labels above lines
Attachments
diagram2.JPG
diagram2.JPG (14.15 KiB) Viewed 4511 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Creating a Diagram

Post by localghost »

Please show exactly what you are doing to produce the presented output.
steFON
Posts: 9
Joined: Wed Mar 13, 2013 5:23 pm

Creating a Diagram

Post by steFON »

I wrote above, that I use package: qtree, and code looks similar to:

Code: Select all

\Tree [.first second1}
                    [.second2 third1}
                              third2 ]]
Of course, that items names are different. I am trying, but I dont know how to do horizontal lines in tree :(
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Creating a Diagram

Post by localghost »

steFON wrote:I wrote above, that I use package: qtree […]
No, you did not. Regardless of that please follow the link in my last reply and provide a self-contained and minimal example. Otherwise this discussion is academic. And reading the qtree manual can't do any harm.

By the way, there is an equivalent tikz-qtree package, now that you are doing the other diagram with PGF/TikZ.
steFON
Posts: 9
Joined: Wed Mar 13, 2013 5:23 pm

Re: Creating a Diagram

Post by steFON »

Please take my apologies! I see that package TikZ is really the best for drawing diagrams. I will try to make other ones by myself. Thanks again!
steFON
Posts: 9
Joined: Wed Mar 13, 2013 5:23 pm

Creating a Diagram

Post by steFON »

Ok, I create something like this:

Packages:

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage{tikz-qtree}

\usetikzlibrary{positioning}
\usetikzlibrary{trees}

\begin{document}

\begin{center}
\begin{tikzpicture}[sibling distance=40pt]
\tikzset{edge from parent/.style=
{draw,
edge from parent path={(\tikzparentnode.south)
-- +(0,-8pt)
-| (\tikzchildnode)}}}
\Tree [.\textrm{} [.$x_2=1$  ]
                  [.$x_2\neq1$ [.$x_2=2$ ]
                               [.$x_2\neq2$ [.$x_2=3$ ]
                                            [.$x_2=4$ ] ] ] ]
\end{tikzpicture}
\end{center}

\end{document}
But I still dont know how to put numbers 3, 4, 5 to diagram next to lines as seen on picture above.
Post Reply