2

Question: In my work i am dealing with minipage and how can i shift above the second part of minipage? I mean top aligned the second part.

MWE:

\documentclass[12pt, a4paper]{article}
\usepackage[top=0.7 in,bottom=0.7 in,left=0.7 in,right=0.7 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{cellspace}
\usepackage{parskip}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
%reduce top margin
\addtolength{\headsep}{-0.5cm}
%for line spacing
\usepackage{setspace}
\setstretch{0.85}

\begin{document}
\begin{minipage}[t]{.35\textwidth}
    \centering
    \setlength\cellspacetoplimit{9pt}
    \setlength\cellspacebottomlimit{9pt}
    \begin{tabular}{Sc|Sc}
        2                      & 4096 \\ \hline
        2                      & 2048 \\ \hline
        2                      & 1024  \\ \hline
        2                      & 512  \\ \hline
        2                      & 256   \\ \hline
        2                      & 128 \\ \hline
        2                      & 64 \\ \hline
        2                      & 32  \\ \hline
        2                      & 16  \\ \hline
        2                      & 8  \\ \hline
        2                      & 4  \\ \hline
        2                      & 2  \\ \hline
        \multicolumn{1}{c|}{} & 1  
    \end{tabular}
\end{minipage}\hspace{\fill}%
\begin{minipage}[t]{0.55\textwidth}
    \begin{flalign*}
    4096&=\underline{2\times 2\times 2}\times \underline{2\times 2\times 2}\times \underline{2\times 2\times 2}\times \underline{2\times 2\times 2}\\[6pt]
    &=2^3 \times 2^3\times 2^3\times 2^3\\[6pt]
    &=(2\times 2\times 2\times 2)^3\\[6pt]
    &=16^3
    \end{flalign*}
\end{minipage}
\end{document} 
  • You have to add [t] also to the tabular environment. But then it is still not completely aligned, since the flalign* environment has some space above it. Use aligned instead. – gernot Apr 10 '17 at 8:40
1

You have to change two things:

  • Add the option [t] also to the tabular environment. Otherwise it is vertically centered on the first line of minipage. With the t option the baseline of the tabular will be its first line.

  • Use aligned with the t option instead of flalign*. aligned is similar to a tabular and forms a box, whereas flalign* displays its contents with additional space above it.

enter image description here

\documentclass[12pt, a4paper]{article}
\usepackage[top=0.7 in,bottom=0.7 in,left=0.7 in,right=0.7 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{cellspace}
\usepackage{parskip}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
%reduce top margin
\addtolength{\headsep}{-0.5cm}
%for line spacing
\usepackage{setspace}
\setstretch{0.85}

\begin{document}
\begin{minipage}[t]{.35\textwidth}
    \centering
    \setlength\cellspacetoplimit{9pt}
    \setlength\cellspacebottomlimit{9pt}
    \begin{tabular}[t]{Sc|Sc}
        2                      & 4096 \\ \hline
        2                      & 2048 \\ \hline
        2                      & 1024  \\ \hline
        2                      & 512  \\ \hline
        2                      & 256   \\ \hline
        2                      & 128 \\ \hline
        2                      & 64 \\ \hline
        2                      & 32  \\ \hline
        2                      & 16  \\ \hline
        2                      & 8  \\ \hline
        2                      & 4  \\ \hline
        2                      & 2  \\ \hline
        \multicolumn{1}{c|}{} & 1  
    \end{tabular}
\end{minipage}\hspace{\fill}%
\begin{minipage}[t]{0.55\textwidth}
    \(\begin{aligned}[t]
    4096&=\underline{2\times 2\times 2}\times \underline{2\times 2\times 2}\times \underline{2\times 2\times 2}\times \underline{2\times 2\times 2}\\[6pt]
    &=2^3 \times 2^3\times 2^3\times 2^3\\[6pt]
    &=(2\times 2\times 2\times 2)^3\\[6pt]
    &=16^3
    \end{aligned}
    \)
\end{minipage}
\end{document} 


\documentclass[12pt, a4paper]{article}
\usepackage[top=0.7 in,bottom=0.7 in,left=0.7 in,right=0.7 in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{cellspace}
\usepackage{parskip}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
%reduce top margin
\addtolength{\headsep}{-0.5cm}
%for line spacing
\usepackage{setspace}
\setstretch{0.85}

\begin{document}
    \setlength\cellspacetoplimit{9pt}
    \setlength\cellspacebottomlimit{9pt}
    \begin{tabular}[t]{Sc|Sc}
        2                      & 4096 \\ \hline
        2                      & 2048 \\ \hline
        2                      & 1024  \\ \hline
        2                      & 512  \\ \hline
        2                      & 256   \\ \hline
        2                      & 128 \\ \hline
        2                      & 64 \\ \hline
        2                      & 32  \\ \hline
        2                      & 16  \\ \hline
        2                      & 8  \\ \hline
        2                      & 4  \\ \hline
        2                      & 2  \\ \hline
        \multicolumn{1}{c|}{} & 1  
    \end{tabular}
    \qquad
    \(\begin{aligned}[t]
    4096&=\underline{2\times 2\times 2}\times \underline{2\times 2\times 2}\times \underline{2\times 2\times 2}\times \underline{2\times 2\times 2}\\[6pt]
    &=2^3 \times 2^3\times 2^3\times 2^3\\[6pt]
    &=(2\times 2\times 2\times 2)^3\\[6pt]
    &=16^3
    \end{aligned}
    \)
\end{document} 
|improve this answer|||||
  • its nice but can we get same result inside minipage? – Maths4Sandy Apr 10 '17 at 8:47
  • @snehal What happens if you try? – gernot Apr 10 '17 at 8:49
  • It works perfectly. – Maths4Sandy Apr 10 '17 at 8:50

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.