3 个数组的对齐:第一个在左侧,第二个在右上方,第三个在右下方

3 个数组的对齐:第一个在左侧,第二个在右上方,第三个在右下方

我有 3 个不同维度的数组。我想将第一个数组放在左侧,第二个放在右上方,第三个放在右下方。到目前为止,我只能放置两个数组,以下是代码:

\documentclass[12 pt, a4paper]{book}
\usepackage{multicol}
\usepackage{geometry}
\geometry{
          a4paper,
          total={170 mm,257 mm},
          left=20 mm,
          top=20 mm,
         }
\usepackage{amsmath,bm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{soul}
\usepackage{indentfirst}
\usepackage[utf8]{inputenc}
\usepackage{palatino}
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{array}
\usepackage{enumitem}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{arydshln}
\usepackage{calc}

\setlength{\parindent}{2em}

\newcommand{\wt}[2]{\underset{\substack{\textstyle\uparrow\\\hidewidth\mathstrut#2\hidewidth}}{#1}}
\definecolor{mygray}{gray}{0.6}

\begin{document}

\textbf{Solution :}
    \[
    \left.
    \hspace{1 cm}
    \arraycolsep=0.2em
    \begin{array}{rrllllll}
          &   &   &   & 1 & 2 & 5 & 5 \\
        \cline{3-8}
        5 & 2 & ) & 6 & 5 & 2 & 9 & 6 \\
          &   & - & 5 & 2 &   &   &   \\
        \cline{4-6}
          &   &   & 1 & 3 & 2 &   &   \\
          &   & - & 1 & 0 & 4 &   &   \\
        \cline{4-7}
          &   &   & 0 & 2 & 8 & 9 &   \\
          &   &   & - & 2 & 6 & 0 &   \\
        \cline{5-8}
          &   &   &   & 0 & 2 & 9 & 6 \\
          &   &   &   & - & 2 & 6 & 0 \\
        \cline{6-8}
          &   &   &   &   & 0 & 3 & 6 \\
    \end{array} 
    \right. \hspace{0.25 cm}\vline \hspace{0.1 cm}
    \arraycolsep=0.2em
    \begin{array}[b]{ccccc@{\hskip 0.5in}ccccc@{\hskip 0.5in}ccccc}
        52 & \times & 1 & = &  52 & 52 & \times & 5 & = & 260 \\
        52 & \times & 2 & = & 104 & 52 & \times & 6 & = & 312 & 52 & \times &  9 & = & 468 \\
        52 & \times & 3 & = & 156 & 52 & \times & 7 & = & 364 & 52 & \times & 10 & = & 520 \\
        52 & \times & 4 & = & 208 & 52 & \times & 8 & = & 416 \\\\
        \hdashline \\
    \end{array}
    \]

\end{document}

我的代码的输出是: 在此处输入图片描述

第三个数组的代码如下:

\[
\begin{array}{ccccccccc}
        & & \textbf{Difference} & \textbf{Value} & & \textbf{Base} & & \textbf{Borrow} & \textbf{Prev. Bit} \\
        11 - 15 & = & -4 < 0 & 11 & + & 16 & = & 27 & \mathrm{A} \rightarrow \underline{9} \\
        \underline{9} - 14 & = & -5 < 0 & 9 & + & 16 & = & 25 & \mathrm{F} \rightarrow \underline{\mathrm{E}}  
\end{array}
\]

期望输出: 在此处输入图片描述

此外,我想要一个标准解决方案,而不是临时解决方案。因此,如果数组的尺寸发生变化,它就会起作用。有人能帮我吗?

答案1

我建议您将这三个array环境嵌入两个嵌套tabular环境中。“外部”两列tabular将由array左列中的环境、垂直规则和tabular右列中的“内部”单列组成。而“内部”表格则包含两个array环境。这种设置乍一听可能有点复杂,但我相信它满足了您对“此问题的标准解决方案而非临时解决方案”的要求。

哦,既然你使用 Palatino 作为正文字体,我也建议你使用 Palatino 数学字体。这可以通过\usepackage{newpxtext, newpxmath}在序言中运行来实现。

在此处输入图片描述

\documentclass[12pt, a4paper]{book}
%% (I've pared the preamble down to the bare minimum needed
%%  to get your code to compile.)
\usepackage{geometry}
\geometry{total={170mm,257mm}, left=20mm, top=20mm}
\usepackage{amsmath,bm,amssymb}
\usepackage[utf8]{inputenc}
\usepackage{newpxtext,newpxmath}
\usepackage{arydshln}

\begin{document}
\noindent
\textbf{Solution :}
\begin{center}
\setlength\tabcolsep{1cm}
\setlength\arraycolsep{0.2em}
\begin{tabular}{@{} c | c @{}} % "outer" tabular

$\begin{array}{@{} rrllllll @{}}
          &   &   &   & 1 & 2 & 5 & 5 \\
        \cline{3-8}
        5 & 2 & ) & 6 & 5 & 2 & 9 & 6 \\
          &   & - & 5 & 2 &   &   &   \\
        \cline{4-6}
          &   &   & 1 & 3 & 2 &   &   \\
          &   & - & 1 & 0 & 4 &   &   \\
        \cline{4-7}
          &   &   & 0 & 2 & 8 & 9 &   \\
          &   &   & - & 2 & 6 & 0 &   \\
        \cline{5-8}
          &   &   &   & 0 & 2 & 9 & 6 \\
          &   &   &   & - & 2 & 6 & 0 \\
        \cline{6-8}
          &   &   &   &   & 0 & 3 & 6 \\
\end{array}$  & 
\begin{tabular}{@{} c @{}} % "inner" tabular
$\begin{array}{@{} *{2}{ccccc@{\hskip 0.5in}} ccccc @{}}
        52 & \times & 1 & = &  52 & 52 & \times & 5 & = & 260 \\
        52 & \times & 2 & = & 104 & 52 & \times & 6 & = & 312 & 52 & \times &  9 & = & 468 \\
        52 & \times & 3 & = & 156 & 52 & \times & 7 & = & 364 & 52 & \times & 10 & = & 520 \\
        52 & \times & 4 & = & 208 & 52 & \times & 8 & = & 416 
\end{array}$\\\\
\hdashline \\
$\begin{array}{@{} *{9}{c} @{}}
& & \text{Diff.} & \text{Value} & & \text{Base} & & \text{Borrow} & \text{Prev.\ Bit} \\
        11 - 15 & = & -4 < 0 & 11 & + & 16 & = & 27 & \mathrm{A} \rightarrow \underline{9} \\
        \underline{9} - 14 & = & -5 < 0 & 9 & + & 16 & = & 25 & \mathrm{F} \rightarrow \underline{\mathrm{E}}  
\end{array}$
\end{tabular} % end of inner tabular
\end{tabular} % end of outer tabular
\end{center}

\end{document}

答案2

我仍然认为这tabularx是可行的方法。

\documentclass[12 pt, a4paper]{book}
\usepackage{multicol}
\usepackage{geometry}
\geometry{
          a4paper,
          total={170 mm,257 mm},
          left=20 mm,
          top=20 mm,
         }
\usepackage{amsmath,bm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{soul}
\usepackage{indentfirst}
\usepackage[utf8]{inputenc}
\usepackage{palatino}
\usepackage[dvipsnames]{xcolor}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{array}
\usepackage{enumitem}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{arydshln}
\usepackage{calc}
\usepackage{tabularx}

\setlength{\parindent}{2em}

\newcommand{\wt}[2]{\underset{\substack{\textstyle\uparrow\\\hidewidth\mathstrut#2\hidewidth}}{#1}}
\definecolor{mygray}{gray}{0.6}

\begin{document}

\textbf{Solution:}
\[
\setlength{\arraycolsep}{0.2em}
\begin{tabularx}{\displaywidth}{ @{\hspace{1cm}} c | X @{} }
$\begin{array}{rrllllll}
     &   &   &   & 1 & 2 & 5 & 5 \\
   \cline{3-8}
   5 & 2 & ) & 6 & 5 & 2 & 9 & 6 \\
     &   & - & 5 & 2 &   &   &   \\
   \cline{4-6}
     &   &   & 1 & 3 & 2 &   &   \\
     &   & - & 1 & 0 & 4 &   &   \\
   \cline{4-7}
     &   &   & 0 & 2 & 8 & 9 &   \\
     &   &   & - & 2 & 6 & 0 &   \\
   \cline{5-8}
     &   &   &   & 0 & 2 & 9 & 6 \\
     &   &   &   & - & 2 & 6 & 0 \\
   \cline{6-8}
     &   &   &   &   & 0 & 3 & 6 \\
   \end{array}$
  &
   \begin{tabular}{@{}w{c}{\linewidth}@{}}
   $\begin{array}[b]{ccccc@{\hskip 0.5in}ccccc@{\hskip 0.5in}ccccc}
      52 & \times & 1 & = &  52 & 52 & \times & 5 & = & 260 \\
      52 & \times & 2 & = & 104 & 52 & \times & 6 & = & 312 & 52 & \times &  9 & = & 468 \\
      52 & \times & 3 & = & 156 & 52 & \times & 7 & = & 364 & 52 & \times & 10 & = & 520 \\
      52 & \times & 4 & = & 208 & 52 & \times & 8 & = & 416 
    \end{array}$
   \\ \\
   \hdashline
   \\
   $\begin{array}{ccccccccc}
        & & \textbf{Difference} & \textbf{Value} & & \textbf{Base} & & \textbf{Borrow} & \textbf{Prev. Bit} \\
        11 - 15 & = & -4 < 0 & 11 & + & 16 & = & 27 & \mathrm{A} \rightarrow \underline{9} \\
        \underline{9} - 14 & = & -5 < 0 & 9 & + & 16 & = & 25 & \mathrm{F} \rightarrow \underline{\mathrm{E}}  
   \end{array}$
  \end{tabular}
\end{tabularx}
\]

\end{document}

在此处输入图片描述

相关内容