如何对齐数组中的第一行

如何对齐数组中的第一行

我经常需要使用这种格式来输入练习,而且效果不错,但我想知道如何将括号中的字母与相邻练习的第一行对齐。因此,第一个问题是如何使用gatheredinside来实现它array,而后续问题是是否有更合适的方法来实现它。

\documentclass{article}
\usepackage{amssymb,amsmath}

\begin{document}
\noindent \textbf{3.4}
\[
\begin{array}{cccc}
\noindent \textbf{(a)}&
    \begin{gathered}
    \mathbb{Z}^*_{7}=\left\{1,3,5\right\}\\
    4^3=64=1
    \end{gathered}&
        \noindent \textbf{(b)}&
            \begin{gathered}
            \mathbb{Z}^*_{8}=\left\{1,3,5,7\right\}\\
            3^4=81=1\\
            \end{gathered}\\\\
\noindent \textbf{(c)}&
    \begin{gathered}
    \mathbb{Z}^*_{11}=\left\{1,,2,3,4,5,6,7,8,9,10\right\}\\
    \begin{array}{c|cccccccccc}
    \cdot & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\
    \hline
    {\rule{0pt}{2.6ex}} 
    5 & 5 & 10 & 4 & 9 & 3 & 8 & 2 & 7 & 1 & 6\\
    \end{array}\\
    5^{-2}=5^{-1}\cdot 5^{-1}=9\cdot 9=4\\
    \end{gathered}&
        \noindent \textbf{(d)}&
            \begin{gathered}
            \mathbb{Z}^*_{12}=\left\{1,5,7,11\right\}\\
            \begin{array}{c|cccc}
            \cdot & 1 & 5 & 7 & 11\\
            \hline
            {\rule{0pt}{2.6ex}} 
            5 & 5 & 1 & 11 & 7\\
            \end{array}\\
            5^{-4}\cdot 7^2=5^{-1}\cdot 5^{-1}\cdot 5^{-1}\cdot 5^{-1}\cdot 1=5^4=1\\
            \end{gathered}
\end{array}
\]
\end{document}

在此处输入图片描述

答案1

像这样?

在此处输入图片描述

我使用包exams和选项[t]来描述alignedgathered环境:

\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage{amsmath, amsfonts}
\usepackage{array}
\setlength\extrarowheight{2pt}
\newlength\labelwd
\settowidth\labelwd{\bfseries viii.)}
\usepackage{tasks}
\settasks{counter-format =tsk[a].), 
          label-format=\bfseries, 
          label-offset=1em, 
          label-align=right, 
          label-width=\labelwd, 
          item-indent=\dimexpr\labelwd+1em\relax, 
          before-skip =-0.5ex, 
          after-item-skip=\medskipamount}
\usepackage{enumitem}
\setlist[enumerate,1]{% (
        leftmargin=*, itemsep=\baselineskip, 
        label={\textbf{\thesection.\arabic*}}
                    }

\begin{document}

\section{section title}

\begin{enumerate}
\item 
        \begin{tasks}(2)
    \task   $\begin{aligned}[t]
            \mathbb{Z}^*_{7} & = \left\{1,3,5\right\}\\
                        4^3  & = 64 = 1
            \end{aligned}$
    \task   $\begin{aligned}[t]
            \mathbb{Z}^*_{8} & = \left\{1,3,5,7\right\}\\
                        3^4  & = 81 = 1
            \end{aligned}$
    \task   $\begin{gathered}[t]
            \mathbb{Z}^*_{11}=\left\{1,2,3,4,5,6,7,8,9,10\right\}\\
            \begin{array}{c|cccccccccc}
            \cdot & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\
            \hline
            5 & 5 & 10 & 4 & 9 & 3 & 8 & 2 & 7 & 1 & 6\\
            \end{array}\\
            5^{-2}=5^{-1}\cdot 5^{-1}=9\cdot 9=4\\
            \end{gathered}$
    \task   $\begin{gathered}[t]
            \mathbb{Z}^*_{12}=\left\{1,5,7,11\right\}\\
            \begin{array}{c|cccc}
            \cdot & 1 & 5 & 7 & 11\\
            \hline
            5 & 5 & 1 & 11 & 7\\
            \end{array}\\
            5^{-4}\cdot 7^2=5^{-1}\cdot 5^{-1}\cdot 5^{-1}\cdot 5^{-1}\cdot 1=5^4=1\\
            \end{gathered}$
        \end{tasks}
\item           
        \begin{tasks}(2)
        \task   1
        \task   2
        \task   3
        \task   4
        \end{tasks}
\end{enumerate}
\end{document}

附录:tasks2020-03-21 开始,MWE 的版本 V1.2 不再按预期工作。其序言(重现问题中的图像)应更改为:

\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage{enumitem}
\setlist[enumerate,1]{leftmargin=*,
                      itemsep=\baselineskip,
                      label={\textbf{\thesection.\arabic*}}
                    }
\usepackage{amsmath, amssymb}
\usepackage{array}
\setlength\extrarowheight{2pt}

\usepackage{tasks}
\settasks{label=(\alph*),
          label-format=\bfseries,
          label-offset=1em,
          before-skip =-0.5ex,
          after-item-skip=\medskipamount
          }

答案2

只需使用[t] 选项即可gathered。但是,我建议使用tasks来自同名包的环境,该环境用于练习的水平列表。我还建议aligned在相关的地方使用,并且我定义了一个\set命令以获得更轻量的代码:

\documentclass{article}
\usepackage{amssymb,mathtools}
\usepackage{tasks}
\usepackage[showframe]{geometry}
\DeclarePairedDelimiter\set\{\}

\begin{document}
\noindent \textbf{3.4}
\[
\begin{array}{cccc}
\noindent \textbf{(a)}&
    \begin{gathered}[t]
    \mathbb{Z}^*_{7}=\set{1,3,5}\\
    4^3=64=1
    \end{gathered}&
        \noindent \textbf{(b)}&
            \begin{gathered}[t]
            \mathbb{Z}^*_{8}=\set{1,3,5,7}\\
            3^4=81=1\\
            \end{gathered}\\\\
\noindent \textbf{(c)}&
    \begin{gathered}[t]
    \mathbb{Z}^*_{11}=\set{1,2,3,4,5,6,7,8,9,10}\\
    \begin{array}{c|*{10}{c}}
    \cdot & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\
    \hline
    {\rule{0pt}{2.6ex}}
    5 & 5 & 10 & 4 & 9 & 3 & 8 & 2 & 7 & 1 & 6\\
    \end{array}\\
    5^{-2}=5^{-1}\cdot 5^{-1}=9\cdot 9=4\\
    \end{gathered}&
        \noindent \textbf{(d)}&
            \begin{gathered}[t]
            \mathbb{Z}^*_{12}=\set{1,5,7,11}\\
            \begin{array}{c|*{4}{c}}
            \cdot & 1 & 5 & 7 & 11\\
            \hline
            {\rule{0pt}{2.6ex}}
            5 & 5 & 1 & 11 & 7\\
            \end{array}\\
            5^{-4}\cdot 7^2=5^{-1}\cdot 5^{-1}\cdot 5^{-1}\cdot 5^{-1}\cdot 1=5^4=1\\
            \end{gathered}
\end{array}
\]
\vspace{1cm}
\begin{tasks}[counter-format = (tsk[a]), label-format=\bfseries, label-width=1.5em, label-offset=0.5em, column-sep=1em](2)
\task \centering$ \begin{aligned}[t]
    \mathbb{Z}^*_{7} & =\set{1,3,5}\\
    4^3 & =64=1
    \end{aligned} $
\task $ \begin{aligned}[t]
            \mathbb{Z}^*_{8} & =\set{1,3,5,7}\\
            3^4 & =81=1\\
            \end{aligned} $
\task $ \begin{gathered}[t]
 \mathbb{Z}^*_{11}=\set{1,2,3,4,5,6,7,8,9,10}\\
 \begin{array}{c|*{10}{c}}
 \cdot & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\
 \hline
 {\rule{0pt}{2.6ex}}
 5 & 5 & 10 & 4 & 9 & 3 & 8 & 2 & 7 & 1 & 6\\
 \end{array}\\
 5^{-2}=5^{-1}\cdot 5^{-1}=9\cdot 9=4
 \end{gathered} $
\task $ \begin{gathered}[t]
 \mathbb{Z}^*_{12}=\set{1,5,7,11}\\
 \begin{array}{c|*{4}{c}}
 \cdot & 1 & 5 & 7 & 11\\
 \hline
 {\rule{0pt}{2.6ex}}
 5 & 5 & 1 & 11 & 7\\
 \end{array}\\
 5^{-4}\cdot 7^2=5^{-1}\cdot 5^{-1}\cdot 5^{-1}\cdot 5^{-1}\cdot 1=5^4=1
 \end{gathered}$
\end{tasks}

\end{document} 

在此处输入图片描述

相关内容