Lemma 66.12.6. Let $S$ be a scheme. Let $Z \to X$ be an immersion of algebraic spaces over $S$. Assume $Z \to X$ is quasi-compact. There exists a factorization $Z \to \overline{Z} \to X$ where $Z \to \overline{Z}$ is an open immersion and $\overline{Z} \to X$ is a closed immersion.

Proof. Let $U$ be a scheme and let $U \to X$ be surjective étale. As usual denote $R = U \times _ X U$ with projections $s, t : R \to U$. Set $T = Z \times _ U X$. Let $\overline{T} \subset U$ be the scheme theoretic image of $T \to U$. Note that $s^{-1}\overline{T} = t^{-1}\overline{T}$ as taking scheme theoretic images of quasi-compact morphisms commute with flat base change, see Morphisms, Lemma 29.25.16. Hence we obtain a closed subspace $\overline{Z} \subset X$ whose pullback to $U$ is $\overline{T}$, see Properties of Spaces, Lemma 65.12.2. By Morphisms, Lemma 29.7.7 the morphism $T \to \overline{T}$ is an open immersion. It follows that $Z \to \overline{Z}$ is an open immersion and we win. $\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).