The Code described in  produces the following output : For the description of my algorithm I need the equal signs to be perfectly aligned in one vertical line but currently there is still a small but noticeable offset.

 TeX-Code :

\usepackage{algorithmicx}
\usepackage{algorithm}

\newcommand{\algrhs}{\hfill \parbox[t]{\algrhswidth}{#1}}

\begin{algorithm} [H]
\begin{algorithmic}
\State $A_1 = B_1 + C_1$ \algrhs{$A_2 = B_2 - C_2$}
\State $X_1 = Y_1 + Z_1$ \algrhs{$X_2 = Y_2 + Z_2$}
\end{algorithmic}
\end{algorithm}


You need to make sure that the equation sides have equal width. That can be achieved by placing the smaller elements inside a box of larger width via \makebox (X_x is wider than A_x and B_x +/- C_x is wider than Y_x +/- Z_x): \documentclass{article}
\usepackage{algpseudocode}
\usepackage{algorithm,calc}

\newcommand{\mathbox}[r]{\makebox[\widthof{$#2$}][#1]{$#3$}}

\begin{document}

\begin{algorithm}[H]
\begin{algorithmic}
\State $\mathbox{X_1}{A_1} = B_1 + C_1$ \hfill $\mathbox{X_2}{A_2} = B_2 - C_2$
\State $X_1 = \mathbox[l]{B_1 + C_1}{Y_1 + Z_1}$ \hfill
$X_2 = \mathbox[l]{B_2 - C_2}{Y_2 + Z_2}$
\end{algorithmic}
\end{algorithm}

\end{document}


In the above example, I've made \mathbox act like \makebox[<width>][<alignment>]{<stuff>} and calc for measuring the width of something via \widthof.

• Works perfectly fine. Can not upvote due to my low reputation value. Jan 13 '16 at 22:14

Use \eqmakebox[<tag>][<pos>]{<text>} to set all <text> with alignment <pos> under the same <tag> within the same width box. \documentclass{article}
\usepackage{algpseudocode}
\usepackage{algorithm,eqparbox}

\begin{document}

\begin{algorithm}[H]
\begin{algorithmic}
\State $\eqmakebox[lhs1][r]{$A_1$} = B_1 + C_1$ \hfill
$\eqmakebox[lhs2][r]{$A_2$} = \eqmakebox[rhs2][l]{$B_2 - C_2$}$
\State $\eqmakebox[lhs1][r]{$X_1$} = Y_1 + Z_1$ \hfill
$\eqmakebox[lhs2][r]{$X_2$} = \eqmakebox[rhs2][l]{$Y_2 + Z_2$}$
\end{algorithmic}
\end{algorithm}

\end{document}