问题:我在工作中处理 minipage,如何才能将 minipage 的第二部分移到上面?我的意思是将第二部分顶部对齐。
梅威瑟:
\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}
答案1
你必须改变两件事:
[t]
还需将选项添加到tabular
环境中。否则,它将在 的第一行垂直居中minipage
。使用该t
选项,表格的基线将是其第一行。aligned
与选项一起使用t
,而不是flalign*
。aligned
类似于tabular
并形成一个框,而flalign*
在其上方显示其内容并留有额外的空间。
\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}