Question: ![](https://i.imgur.com/kq8sPmh.png)

I would like to have these expressions aligned so that the kerning and slightly different character widths do not result in an uneven overall appearance. I tried using an `align` environment within `algorithm` but it resulted in errors. Here is a MWE:

![](https://i.imgur.com/AVI6WKb.png)

```
\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}

\begin{document}

\begin{algorithm}
\caption{Euclid’s algorithm}\label{alg:euclid}
\begin{algorithmic}[1]
\Procedure{Euclid}{$m,l$}\Comment{The g.c.d. of m and l}
\State $r\gets m\bmod l$
\While{$r\not=0$}\Comment{We have the answer if r is 0}
\State $m\gets l$
\State $l\gets r$
\State $r\gets m\bmod l$
\EndWhile\label{euclidendwhile}
\State \textbf{return} $l$\Comment{The gcd is l}
\EndProcedure
\end{algorithmic}
\end{algorithm}

\end{document}

```

Source: <https://www.writelatex.com/examples/euclids-algorithm-an-example-of-how-to-write-algorithms-in-latex/mbysznrmktqf>

Answer: 
Something like this?

```
\begin{tikzpicture}
% Set horizontal range 
\pgfmathsetmacro{\nx}{8}
% Set vertical range 
\pgfmathsetmacro{\ny}{2.5}

\pgfmathsetmacro{\xmin}{2*(sqrt(\ny+1)-1)/\ny}
\pgfmathsetmacro{\xmint}{2/sqrt(\ny)}
\pgfmathsetmacro{\xminb}{4/\ny}
\pgfmathsetmacro{\xmax}{2*\nx}

\begin{axis}[xmin=0,xmax=\xmax,axis x line*=middle, axis y line*=left, xtick=\empty, ytick=\empty]
    \addplot[red,domain=\xmin:\xmax,samples=100]{1/x^2-1/x};
    \addplot[domain=\xminb:\xmax,samples=100]{-1/x};
    \addplot[domain=\xmint:\xmax,samples=100]{1/x^2};
\end{axis}
\end{tikzpicture}

```

You can set the horizontal and vertical range in the first lines, the units for nx and ny are the coordinates of the minimum point of the graph.
May be this:

```
 \documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
  \begin{tikzpicture}
\begin{axis}[
xmax=1,
xmin=0,
ymax=10,
ymin=-250,
]
\addplot[
red,
%smooth,       %% this will spoil the plot
domain=-5:5,
samples=1000,thick
]
{0.5/x²-22/x};
\end{axis}
\end{tikzpicture}
\end{document}

```

![enter image description here](https://i.stack.imgur.com/VcwiC.png)