Lemma 32.5.1. Let $W$ be a quasi-affine scheme of finite type over $\mathbf{Z}$. Suppose $W \to \mathop{\mathrm{Spec}}(R)$ is an open immersion into an affine scheme. There exists a finite type $\mathbf{Z}$-algebra $A \subset R$ which induces an open immersion $W \to \mathop{\mathrm{Spec}}(A)$. Moreover, $R$ is the directed colimit of such subalgebras.

Proof. Choose an affine open covering $W = \bigcup _{i = 1, \ldots , n} W_ i$ such that each $W_ i$ is a standard affine open in $\mathop{\mathrm{Spec}}(R)$. In other words, if we write $W_ i = \mathop{\mathrm{Spec}}(R_ i)$ then $R_ i = R_{f_ i}$ for some $f_ i \in R$. Choose finitely many $x_{ij} \in R_ i$ which generate $R_ i$ over $\mathbf{Z}$. Pick an $N \gg 0$ such that each $f_ i^ Nx_{ij}$ comes from an element of $R$, say $y_{ij} \in R$. Set $A$ equal to the $\mathbf{Z}$-algebra generated by the $f_ i$ and the $y_{ij}$ and (optionally) finitely many additional elements of $R$. Then $A$ works. Details omitted. $\square$

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the toolbar).