3

MWE

\documentclass[12pt]{article}
\usepackage[a4paper,top=1 in,bottom=1 in,left=0.7 in,right=0.7 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[misc]{ifsym}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{amssymb}
\allowdisplaybreaks
\usepackage{kantlipsum}
\usepackage{forest}
\usepackage{tikz,tkz-euclide,xcolor,graphicx}
\usetkzobj{all}
\usetikzlibrary{intersections}
\begin{document}
\begin{minipage}[b]{.6\textwidth}
    \begin{flalign*}
    x^2-3x-10&=0&\\
    \therefore\;\;x^2-5x+2x-10&=0&\\
    \therefore\;\;x\left(x-5\right)+2\left(x-5\right)&=0&\\
    \therefore\;\;\left(x-5\right)\left(x+2\right)&=0&\\
    \therefore\;\;\left(x-5\right)&=0\quad \text{OR}\quad \left(x+2\right)=0&\\
    \therefore\;\;x&=5\quad \text{OR}\quad x=-2&
    \end{flalign*}
\end{minipage}\hfill
\begin{minipage}[t]{0.4\textwidth}
    \begin{tikzpicture}[level distance=1.2cm,
    level 1/.style={sibling distance=1.5cm},
    level 2/.style={sibling distance=1cm}]
    \tikzstyle{every node}=[circle,draw]

    \node (Root) [black] {-10}
    child {node {-5}}
    child {node {2}};

    \end{tikzpicture}
\end{minipage}


\end{document}

Question: How can i vertically align my tikz picture in the same line of the first equation?

  • Just remove the first minipage aligment specifier [b] – Guilherme Zanotelli Oct 20 '16 at 6:25
1

You can make the picture a part of the alignment. In the code below I left only the strictly necessary packages.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{adjustbox}
\usepackage{tikz}

\newcommand{\thf}{\therefore\quad}

\begin{document}
\begin{alignat*}{2}
     & x^2-3x-10=0
&\qquad&
  \begin{adjustbox}{valign=t,set depth=0pt}
    \begin{tikzpicture}[level distance=1.2cm,
    level 1/.style={sibling distance=1.5cm},
    level 2/.style={sibling distance=1cm}]
    \tikzstyle{every node}=[circle,draw]
    \node (Root) [black] {$-10$}
    child {node {$-5$}}
    child {node {$2$}};
    \end{tikzpicture}
  \end{adjustbox}
\\
\thf & x^2-5x+2x-10=0\\
\thf & x(x-5)+2(x-5)=0\\
\thf & (x-5)(x+2)=0\\
\thf & (x-5)=0\quad \text{or}\quad (x+2)=0\\
\thf & x=5 \quad \text{or}\quad x=-2
\end{alignat*}

\end{document}

Some points to note.

  1. I removed \allowdisplaybreaks that in general is to be avoided unless we are in the writing phase (a break in this display would have disastrous consequences)

  2. I removed all \left and \right that do nothing good here and something bad

  3. I chose alignment with respect to the “therefore” symbol rather than alignment at = that seems artificial particularly for the last two lines

  4. I hid the \therefore command in a macro so you are free to change the rendering of \thf to, say, \Leftrightarrow in case you want to underline that each line is completely equivalent to the preceding one

The trick is making the picture as high as a line of text with valign=t and have no depth, so TeX won't leave space for it.

You may want to increase the minimum radius of the circles.

enter image description here

| improve this answer | |
  • THanks a lot for such a nice information and correction. it improve my latex knowledge. – SDP Oct 21 '16 at 5:48
0

In addition to removing the [b] placement specifier from the first minipage environment, you should also

  • use an aligned environment instead of an flalign* environment to avoid inserting vertical whitespace before the group of equations,

  • insert \noindent immediately before the first minipage,

  • remove the \hfill instruction after the first minipage and, instead, insert % (comment char.) immdediately after \end{minipage},

  • use math mode for the circled numbers, i.e., write $-10$, $-5, and $+2$;

  • remove all \left and \right sizing instructions: They don't change any sizes, but they do end up inserting inappropriate horizontal whitespace.

enter image description here

\documentclass[12pt]{article}
\usepackage[a4paper,top=1 in,bottom=1 in,left=0.7 in,right=0.7 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[misc]{ifsym}
%%\usepackage{amsmath} % is loaded by 'mathtools' package
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{amssymb}
\allowdisplaybreaks
\usepackage{kantlipsum}
\usepackage{forest}
\usepackage{tikz,tkz-euclide,xcolor,graphicx}
\usetkzobj{all}
\usetikzlibrary{intersections}
\begin{document}

\noindent  % <---  don't forget this instruction
\begin{minipage}{.6\textwidth}
    $\begin{aligned}  % <--- 'aligned' rather than 'flalign*'
    x^2-3x-10&=0\\    % omit the '&' chars at end of lines
    \therefore\;\; x^2-5x+2x-10 &=0\\
    \therefore\;\; x(x-5)+2(x-5)&=0\\
    \therefore\;\; (x-5)(x+2)   &=0\\
    \therefore\;\; (x-5)&=0\quad \text{or}\quad (x+2)=0\\
    \therefore\;\;     x&=5\quad \text{or}\quad x=-2
    \end{aligned}$
\end{minipage}%  % <--- no \hfill
\begin{minipage}[t]{0.4\textwidth}
    \begin{tikzpicture}[level distance=1.2cm,
    level 1/.style={sibling distance=1.5cm},
    level 2/.style={sibling distance=1cm}]
    \tikzstyle{every node}=[circle,draw]

    \node (Root) [black] {$-10$} % <--- math mode for circled numbers
    child {node {$-5$}}  
    child {node {$+2$}};
    \end{tikzpicture}
\end{minipage}
\end{document} 
| improve this answer | |
  • Ohh thank you so much for giving some nice corrections it is very helpful – SDP Oct 21 '16 at 5:49

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.