4

I am trying to make a little logo with latex. I draw the picture (a decision tree) and I'd like to add a text next to it. Moreover, I need the drawing to be small, in size of the text next to it.

Just a random picture to show what kind of shape I'd like to have:

enter image description here

source

So far I made the drawing where I tried to add some text next to it. No results unfortunately.

\documentclass{scrartcl}
\usepackage[a4paper,margin=1cm,landscape]{geometry}
\usepackage{tikz}

%%%<
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>

\usetikzlibrary{positioning,shadows,arrows}

\begin{document}

\begin{figure}
   \begin{minipage}[c]{7cm}
\begin{tikzpicture}[
    state/.style={circle, draw=none, fill=orange, circular drop shadow,
        text centered, anchor=north, text=white},
    leaf/.style={circle, draw=none, fill=red, circular drop shadow,
        text centered, anchor=north, text=white},
    level distance=0.5cm, growth parent anchor=south
]
\node (State00) [state] {$X$}
   child{ [sibling distance=3cm]
            node (State01) [state] {$f(x)_{1}$}
            child{
                child{ [sibling distance=2cm]
                    node (State02) [state] {$f(x)_{11}$}
                    child{
                        child{
                            node (State03) [leaf] {$\hat{y}_{1}$}
                        }
                    }
                    child{
                        child{ [sibling distance=2.0cm]
                            node (State04) [state] {$\hat{y}_{2}$}
                        }
                    }
                }
            }
            child{ [sibling distance=2cm]
                child{
                    node (State10) [state] {$f(x)_{12}$}
                    child{
                        child{
                            node (State11) [leaf] {$\hat{y}_{3}$}
                        }
                    }
                    child{
                        child{
                            node (State12) [state] {$\hat{y}_{4}$}
                        }
                    }
                }
            }
        }
;    
\end{tikzpicture}]
\end{minipage}%

\begin{minipage}[c]{\textwidth-7cm}
      Some text describing the image.
      Some text describing the image.
      Some text describing the image.
\end{minipage}

\end{figure}

\end{document}

The output looks as follows: enter image description here

And the text should have this form:

\documentclass{article}
\pagestyle{empty}
\usepackage{xcolor}
\usepackage{bm}
\usepackage{setspace}

\begin{document}

\setstretch{0.5}

\begin{center}
Nam$\textcolor{orange}{\bm{{\hat{e}}}}$ of New \\
~\\
 Team
\end{center}

Could you please point me towards the solution?

EDIT

With help of @Guilherme Zanotelli, I made it work and set the proper proportions. But the logo is very small when I save it into pdf.

How can I make it bigger while keeping the proportion unchanged?

solved with bigger font

  • I don't get it. What are you trying to accomplish? What does the "Principal" logo has to do with it? Your two chunks of code are (to me) nonsensical... Could you please clarify what you want to achieve? – Guilherme Zanotelli Jan 19 '17 at 21:08
  • shape you mean draw and text on the right? – Sigur Jan 19 '17 at 21:29
  • Yes, correct. Sorry for misunderstanding. – HonzaB Jan 19 '17 at 21:35
3

I do not understand what the question actually is, but I suppose one of the issues is to get the Nam*ê* of New Team to appear on the right side of the decision tree.

So below is a way to do it within the tikzpicture (no need for minipages).

\documentclass{article}
\usepackage[a4paper,margin=1cm,landscape]{geometry}
\usepackage{tikz,pbox}
\usepackage{xcolor}
\usepackage{bm}
\usepackage{setspace}

%%%<
\usepackage{verbatim}
\usepackage[active,tightpage,floats]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>

\usetikzlibrary{positioning,shadows,arrows}

\begin{document}
    \begin{figure}[h]
            \begin{tikzpicture}[
            state/.style={circle, draw=none, fill=orange, circular drop shadow,
                text centered, anchor=north, text=white},
            leaf/.style={circle, draw=none, fill=red, circular drop shadow,
                text centered, anchor=north, text=white},
            level distance=0.5cm, growth parent anchor=south
            ]
            \node (State00) [state] {$X$}
            child{ [sibling distance=3cm]
                node (State01) [state] {$f(x)_{1}$}
                child{
                    child{ [sibling distance=2cm]
                        node (State02) [state] {$f(x)_{11}$}
                        child{
                            child{
                                node (State03) [leaf] {$\hat{y}_{1}$}
                            }
                        }
                        child{
                            child{ [sibling distance=2.0cm]
                                node (State04) [state] {$\hat{y}_{2}$}
                            }
                        }
                    }
                }
                child{ [sibling distance=2cm]
                    child{
                        node (State10) [state] {$f(x)_{12}$}
                        child{
                            child{
                                node (State11) [leaf] {$\hat{y}_{3}$}
                            }
                        }
                        child{
                            child{
                                node (State12) [state] {$\hat{y}_{4}$}
                            }
                        }
                    }
                }
            };
        \node[right] at (current bounding box.east) {\pbox{\textwidth}{\relax\ifvmode\centering\fi Nam$\textcolor{orange}{\bm{{\hat{e}}}}$ of New \\
            ~\\
            Team}};
        \end{tikzpicture}
    \end{figure}
\end{document}

enter image description here

  • Yes! Thats exatly it! Only a small question - how could one make the drawing smaller, so it fits more to the text? – HonzaB Jan 19 '17 at 21:11
  • There are conflicting issues in your question. You can scale the whole thing making it smaller using scale=0.8, every node/.style={scale=0.8} but you'll lose font size consistency. Another option is to set every node/.style={font=\small, inner sep=<dim> setting <dim> accordinly and use a smaller level distance, which is essentialy resizing the drawing. – Guilherme Zanotelli Jan 19 '17 at 21:14
  • I think I found the proportions I like, but then the logo is very small when put into pdf. I added a link to the Overleaf so you can see it. – HonzaB Jan 19 '17 at 21:41
  • Well, I don't know what to say. You should keep in mind that the dimensions of your drawing are actually real. Which means that the font sizes used are the same when you include your PDF. So you should choose the appropriate font size for "Namê of the Team" and then scale the logo accordingly, not much can be done aside from this... – Guilherme Zanotelli Jan 19 '17 at 21:47
  • Ok, that make sense. Sorry for such a questions, I am really new to Tikz. – HonzaB Jan 19 '17 at 21:55
4

This is an adaption of Guilherme Zanotelli's answer, using Forest, of which I am rather font. It also uses standalone which is less fuss, in my opinion than preview (but uses preview, depending on configuration).

In a logo, a key decision will be font choice. While I'm not sure what I would recommend, as that depends a great deal on context and audience, Computer Modern is unlikely to be a good choice. Just as an illustration, I use kpfonts in the example below.

I've also made a point of demonstrating how to select an arbitrary font size for the text on the right. The first number is the point size. The second is the baseline skip. Scalable fonts are crucial. By default, you are probably getting bitmap Computer Modern. All well and good in their way, but absolutely unsuitable here. (If you want CM, use \usepackage[T1]{fontenc} alone to make sure you get scalable versions.)

I've increased the line widths in the tree because you don't want the lines to disappear if the logo is used at small size. At least, I assume you don't.

logo

\documentclass[border=10pt,multi,tikz,border=5pt]{standalone}
\usepackage{forest,bm}
\usetikzlibrary{shadows}
\usepackage[T1]{fontenc}
\usepackage{kpfonts}
\begin{document}
\begin{forest}
  state/.style={fill=orange},
  leaf/.style={fill=red},
  for tree={
    text centered,
    child anchor=parent,
    text=white,
    circle,
    circular drop shadow,
    math content,
    state,
    font=\large,
    edge={line width=1pt},
  },
  for descendants={
    edge path'={(.child anchor) -- +(0,7.5mm) -- (!u.parent anchor)},
    l sep'=15mm,
  },
  l sep'=7.5mm,
  where n children=0{
    !u.s sep'=15mm,
  }{},
  [X
    [f(x)_{1}
      [f(x)_{11}
        [\hat{y}_{1}, leaf]
        [\hat{y}_{2}]
      ]
      [f(x)_{12}
        [\hat{y}_{3}, leaf]
        [\hat{y}_{4}]
      ]
    ]
  ]
  \node [right, align=center, font=\fontsize{50pt}{75pt}\selectfont] at (current bounding box.east) {Nam$\textcolor{orange}{\bm{{\hat{e}}}}$ of New\\Team};
\end{forest}
\end{document}
  • Wow, what a great answer and recommendations! I will certainly take your comments into account when making final version. Thank you. – HonzaB Jan 20 '17 at 10:51

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.