# How to align first line in an array

I quite often need to use this kind of format for typing up exercises and it is satisfactory but I am wondering how I can align the letter in brackets with the first line of the exercise adjacent to it. So the first question would be how do I accomplish it using gathered inside array and the follow up question would be if there isn't a more appropriate way of accomplishing it.

\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}


like this?

I use package exams and options [t] for aligned and gathered environments:

\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage{amsmath, amsfonts}
\newlength\labelwd
\settowidth\labelwd{\bfseries viii.)}
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*}}
}
\usepackage{array}
\setlength\extrarowheight{2pt}

\begin{document}

\section{section title}

\begin{enumerate}
\item
\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}$
\item
\end{enumerate}
\end{document}

• Thanks! I'll definitely take a closer look at the exams package. – ifearthenight Apr 18 '17 at 7:28

Just use the [t] option for gathered. However, I suggest using the tasks environment, from the homonymous package, which is done for horizontal lists of exercises. I also suggest using aligned where relevant, and I defined a \set command to have a lighter code:

\documentclass{article}
\usepackage{amssymb,mathtools}
\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}$