# Parts of mini page are not placed properly

Question:

Right now i am working in mini page, the problem is components of mini page are not placed at good place. I want to reduce the space between them and both start from the same line from top (i mean horizontally in same line)

MWE:

\documentclass[12pt,a4paper]{article}
\usepackage[a4paper,vmargin=0.5in,hmargin=0.5in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[misc]{ifsym}
\usepackage{amsmath,amsfonts,amssymb,cancel}
\usepackage{array,booktabs}
\usepackage{forest}
\usepackage{parskip}
\usepackage{tcolorbox}
\begin{document}
\begin{minipage}[t]{.45\textwidth}
\begin{forest}
for tree={circle,draw, l sep=10pt}
[140,black
[2]
[70
[2]
[35
[5]
[7]
]
]
]
\end{forest}
\end{minipage}
%\hfill
\begin{minipage}[b]{.55\textwidth}
\begin{align*}
140 &= 2 \times 2 \times 5 \times 7&\\
&= 2^2 \times 5 \times 7
\end{align*}
\end{minipage}
\end{document}


The reference point for a forest is at the bottom. You can make it at the top so it aligns with a standard line of text with \adjustbox and valign=t. For the equation use aligned.

Finally, decide for the spacing between the objects, here \quad is used.

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{forest}

\begin{document}

\begin{forest}
for tree={circle,draw, l sep=10pt}
[140,black
[2]
[70
[2]
[35
[5]
[7]
]
]
]
\end{forest}%
}% end of adjustbox (the % next to the brace is important
\begin{aligned}[t] 140 &= 2 \times 2 \times 5 \times 7&\\ &= 2^2 \times 5 \times 7 \end{aligned}

\end{document}


With the baseline option, you can vertically align the two parts so that the two instances of 140 are at the same height.

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{forest}

\begin{document}

\begin{forest} baseline, for tree={circle,draw, l sep=10pt}
[140,black
[2]
[70
[2]
[35
[5]
[7]
]
]
]
\begin{aligned}[t] 140 &= 2 \times 2 \times 5 \times 7&\\ &= 2^2 \times 5 \times 7 \end{aligned}

\end{document}


For vertical centering,

\documentclass[12pt,a4paper]{article}
\usepackage{amsmath}
\usepackage{forest}

\begin{document}

\begin{forest} baseline=center, for tree={circle,draw, l sep=10pt}
[140,black
[2]
[70
[2]
[35
[5]
[7]
]
]
]
\end{forest}
\begin{aligned} 140 &= 2 \times 2 \times 5 \times 7&\\ &= 2^2 \times 5 \times 7 \end{aligned}

If you want to set this inside a math display, omit the  characters and exploit gathered. \documentclass[12pt,a4paper]{article} \usepackage{amsmath} \usepackage{forest} \begin{document} \begin{equation*} \begin{gathered} \begin{forest} baseline=center, for tree={circle,draw, l sep=10pt} [140,black [2] [70 [2] [35 [5] [7] ] ] ] \end{forest} \end{gathered}\qquad \begin{aligned} 140 &= 2 \times 2 \times 5 \times 7&\\ &= 2^2 \times 5 \times 7 \end{aligned} \end{equation*} \end{document}  • Pleased to know new things. one request, Is it possible to place right part in the middle? i am asking Just for getting additional information. – Maths4Sandy Mar 19 '19 at 10:21 • @Sandy In the middle of what? – egreg Mar 19 '19 at 10:22 • i mean middle of first part, slightly below from its original position – Maths4Sandy Mar 19 '19 at 10:27 • @Sandy Do you mean that you want the two instances of 140 being aligned? – egreg Mar 19 '19 at 10:29 • Keep left part (tree) as it is. I don't want to move it. I am asking that how the equations part can we push vertically below exact in the middle of the tree. – Maths4Sandy Mar 19 '19 at 10:35 \documentclass[12pt,a4paper]{article} \usepackage[a4paper,vmargin=0.5in,hmargin=0.5in]{geometry} \usepackage[utf8]{inputenc} \usepackage[misc]{ifsym} \usepackage{amsmath,amsfonts,amssymb,cancel} \usepackage{array,booktabs} \usepackage{forest} \usepackage{parskip} \usepackage{tcolorbox} \usepackage{varwidth} \begin{document} \begin{varwidth}[t]{.45\textwidth} \vspace{0pt} \begin{forest} for tree={circle,draw, l sep=10pt} [140,black [2] [70 [2] [35 [5] [7] ] ] ] \end{forest} \end{varwidth} %\hfill \begin{varwidth}[t]{.55\textwidth} \vspace{0pt} 140 = 2 \times 2 \times 5 \times 7 = 2^2 \times 5 \times 7 \$

• Put it between the two varwidth without an empty line! – user2478 Mar 19 '19 at 11:31