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}

3 Answers 3

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

3
  • The question also asks for the (middle) 2 in the last line to be centered. Jun 11, 2020 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.
    – user194703
    Jun 11, 2020 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. Jun 11, 2020 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

2
  • The last line in the second example isn't aligned. Oversight? Jun 11, 2020 at 22:05
  • No, it was purposely: I don't like very much this blank space in the first example and I found it was worth giving up on the alignment for this last equation
    – Bernard
    Jun 11, 2020 at 22:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .