# How to make the formula id at the middle of all lines?

I have written some formulas in aligned in equation as follows:

\begin{aligned} &~&XNor(b_1,~b_2)=Neg(Xor(b_1,~b_2))~&\wedge~Neg(Xor(b_1,~b_2))=Xor(Neg(b_1),~b_2) \\ \Rightarrow&~&XNor(b_1,~b_2)&=Xor(Neg(b_1),~b_2) \\ \Rightarrow&~&Neg(XNor(b_1,~b_2))&=Neg(Xor(Neg(b_1),~b_2)) \\ \Rightarrow&~&Neg(XNor(b_1,~b_2))&=XNor(Neg(b_1),~b_2) \end{aligned}


But the position of the tag(formula id) is too lower(down). How to make it up to the middle position (as other formulas could)?

Leave it as is (after applying the fixes I propose). When your document is in final version, you can try some tricks like the one below, where the part after the \wedge is artificially made with zero width1 and I cover my tracks by moving everything to the far left.2

1. \lefteqn is the way to make a subformula zero width.
2. \hspace{0pt} at the beginning is necessary in order to move the aligned to the far left.

Avoid ~ in formulas, the spacing after commas is the right one. The operators should be in upright type: Neg is not the product of N, e and g.

\documentclass{article}
\usepackage{amsmath}
\usepackage{lipsum}% for nonsense context

\DeclareMathOperator{\XNor}{XNor}
\DeclareMathOperator{\Neg}{Neg}
\DeclareMathOperator{\Xor}{Xor}

\begin{document}

\lipsum[1][1-3]
\hspace{0pt} \begin{aligned} && \XNor(b_1,b_2)=\Neg(\Xor(b_1,b_2)) & \wedge \lefteqn{\Neg(\Xor(b_1,b_2))=\Xor(\Neg(b_1),b_2)} \\ \Rightarrow && \XNor(b_1,b_2) &= \Xor(\Neg(b_1),b_2) \\ \Rightarrow && \Neg(\XNor(b_1,b_2)) &= \Neg(\Xor(\Neg(b_1),b_2)) \\ \Rightarrow && \Neg(\XNor(b_1,b_2)) &= \XNor(\Neg(b_1),b_2) \end{aligned} \hspace{1000pt minus 1fill}
\lipsum[1][4-6]

\end{document}


Be aware that the trick used here exploits the particular shape of the display, where the top line has to parts each occupying about half of the text width, so it's not at all a general way to solve such problems.

• Your answer helps me a lot, thank you very much~ Dec 9 '21 at 7:47

It is absolutely works fine for me:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{aligned} ~&&Neg(Neg(b)) = b~\wedge~Neg(And(b_1,&~b_2))=Or(Neg(b_1),~Neg(b_2)) \\ \Rightarrow&~&And(b_1,~b_2)=Neg(Or(&Neg(b_1),~Neg(b_2))) \\ \Rightarrow&~&Neg(Or(b_1,~b_2))=And&(Neg(b_1),~Neg(b_2)) \end{aligned}
\end{document}


• I'm sorry I post the wrong formula just now. I correct it now. Could you help to take a look again Dec 9 '21 at 5:53

This uses \mathmakebox from the mathtools package. Interestingly, if the width is too small, the vertical spacing at the top will be smaller, which seems to be related to the length of the previous text.

\documentclass{article}
\usepackage{mathtools}
\usepackage{lipsum}% for nonsense context

\DeclareMathOperator{\XNor}{XNor}
\DeclareMathOperator{\Neg}{Neg}
\DeclareMathOperator{\Xor}{Xor}

\begin{document}

\lipsum[1][1-3]
\mathmakebox[0.7\textwidth][c]{\begin{aligned} && \XNor(b_1,b_2)=\Neg(\Xor(b_1,b_2)) & \wedge \Neg(\Xor(b_1,b_2))=\Xor(\Neg(b_1),b_2) \\ \Rightarrow && \XNor(b_1,b_2) &= \Xor(\Neg(b_1),b_2) \\ \Rightarrow && \Neg(\XNor(b_1,b_2)) &= \Neg(\Xor(\Neg(b_1),b_2)) \\ \Rightarrow && \Neg(\XNor(b_1,b_2)) &= \XNor(\Neg(b_1),b_2) \end{aligned}}
\lipsum[1][4-6]

\end{document}