5

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

\begin{equation}
\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}
\end{equation}

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)? enter image description here

1
5

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]
\begin{equation}
\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}
\end{equation}
\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.

enter image description here

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

It is absolutely works fine for me:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
    \begin{equation}
        \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{equation}
\end{document}

enter image description here

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

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]
\begin{equation}
\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}}
\end{equation}
\lipsum[1][4-6]

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.