2

I want to align the equation system below in a way that looks good. In particular I would like that the vertical dots are centered at the \equiv and = signs. I would also like that the 2 in the last row is vertically centered below p-5. I hope it is clear what I mean. Could you please show me how to achieve this?

\documentclass[a4paper, 11pt]{book}

\usepackage[a4paper,left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}

\usepackage{amsfonts} \usepackage{amsmath} \usepackage{amssymb} \usepackage{amsthm}

\usepackage{lmodern}

\begin{document}

\begin{align} -1 &\equiv p-1 &= 2 \cdot s &\pmod p\ -3 &\equiv p-3 &= 2 \cdot (s-1) &\pmod p\ -5 &\equiv p-5 &= 2 \cdot (s-2) &\pmod p\ &\vdots &\vdots\ -(p-2) &\equiv 2 &= 2 \cdot (s-(s-1)) &\pmod p. \end{align}

\end{document}

3nondatur
  • 483

3 Answers3

4

Something like this?

I used alignat* instead of align* to have less horizontal spacing between columns. I also used the command \vdotswithin from mathtools to center the vertical dots with the \equiv and = symbols.

\documentclass[a4paper, 11pt]{book}
\usepackage[a4paper,left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{lmodern}

\begin{document}

\begin{alignat}{3} -1 &\equiv p-1 &&= 2 \cdot s &&\pmod p\ -3 &\equiv p-3 &&= 2 \cdot (s-1) &&\pmod p\ -5 &\equiv p-5 &&= 2 \cdot (s-2) &&\pmod p\ &\vdotswithin{\equiv} &&\vdotswithin{=}\ -(p-2) &\equiv \makebox[\widthof{(p-5)}]{(2)} &&= 2 \cdot (s-(s-1)) &&\pmod p. \end{alignat}

\end{document}

Vincent
  • 20,157
3

You can use \vdotswithin from mathtools for the vertical dots. Otherwise you may just use an array.

\documentclass[a4paper, 11pt]{book}
\usepackage[a4paper,left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{mathtools}
\usepackage{array}

\usepackage{lmodern}

\begin{document} [ \begin{array}{@{}r@{}*3{>{{}}l@{}}} -1 &\equiv p-1 &= 2 \cdot s &\pmod p\ -3 &\equiv p-3 &= 2 \cdot (s-1) &\pmod p\ -5 &\equiv p-5 &= 2 \cdot (s-2) &\pmod p\ &\vdotswithin{\equiv} &\vdotswithin{=}&\vdotswithin{\pmod p}\ -(p-2) &\equiv 2 &= 2 \cdot (s-(s-1)) &\pmod p;. \end{array} ] \end{document}

enter image description here

  • The question also asks for the (middle) 2 in the last line to be centered. – barbara beeton Jun 11 '20 at 22:02
  • 1
    @barbarabeeton Well, obviously I missed that (maybe because I did not want to see that;-), but you know the sociology among users here, so I won't touch the answer. Otherwise the usual things will happen... BTW, could you perhaps comment on this comment? I am not sure if my recollections are correct. –  Jun 11 '20 at 22:07
  • Tsk (re the noncentered p). I have commented on the matter covered in the comment; as usual, from my pure-math-centric point of view. – barbara beeton Jun 11 '20 at 22:25
2

I propose one of these slightly different layouts,based on gather* and alignedat with a single \mod p for the whole group:

\documentclass[a4paper, 11pt]{book}
\usepackage{lmodern}

\usepackage[a4paper,left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry} \usepackage{mathtools} \usepackage{amssymb} \usepackage{amsthm}

\begin{document}

\begin{gather} \begin{alignedat}{2} -1 &\equiv p-1 & & = 2\mkern2mu s\ -3 &\equiv p-3 & & = 2(s-1) \ -5 &\equiv p-5 & & = 2(s-2) \[-1.5ex] &\vdotswithin{=} & &\vdotswithin{=} \[-1ex] -(p-2) &\equiv 2 & & = 2 \bigl(s-(s-1)\bigr) \end{alignedat} \qquad\pmod p \end{gather}

\begin{gather} \begin{alignedat}{2} -1 &\equiv p-1 & & = 2\mkern2mu s\ -3 &\equiv p-3 & & = 2(s-1) \ -5 &\equiv p-5 & & = 2(s-2) \[-1.5ex] &\vdotswithin{=} & &\vdotswithin{=} \[-1ex] -(p-2) &\equiv 2 = \mathrlap{2 \bigl(s-(s-1)\bigr)} \end{alignedat} \qquad \pmod p \end{gather}

\end{document}

enter image description here

Bernard
  • 271,350