Understanding sheaf of relative differentials for a scheme This concerns section 8 of chapter 2 of Hartshorne's Algebraic Geometry. We consider a morphism of schemes $f:X\to Y$ and a "diagonal morphism" $\Delta :X \to X \times_Y X$.
He then introduces the "sheaf of ideals of $\Delta(X)$ in $W$" where $W$ is an open subset of $X\times_Y X$ which contains $\Delta(X)$. I want to clarify this point explicitly. Does he mean then given the inclusion $\iota:\Delta(X) \to W$, the sheaf of ideals he speaks of is the kernel of the map $\iota^\#: \mathcal O_W \to \iota_*\mathcal O_{\Delta(X)}$?
He then goes on to define the sheaf of relative differentials as $\Delta^*(\mathcal J/\mathcal J^2)$ where $\mathcal J$ is the sheaf of ideals in question.
If my interpretation is correct, I would still appreciate an explicit, non-trivial example, to elucidate the formalism, as I don't think I have any intuition for this construction.
 A: You have a misconception here: $W$ is not just some arbitrary open set! Let's start by reproducing the text:

Let $f:X\to Y$ be a morphism of schemes. We consider the diagonal morphism $\Delta: X\to X\times_YX$. It follows from the proof of (4.2) that $\Delta$ gives an isomorphism of $X$ onto its image $\Delta(X)$, which is a locally closed subscheme of $X\times_YX$, i.e., a closed subscheme of an open subset $W\subset X\times_YX$.
Definition. Let $\mathscr{I}$ be the sheaf of ideals of $\Delta(X)$ in $W$. Then we can define the sheaf of relative differentials of $X$ over $Y$ to be the sheaf $\Omega_{X/Y}=\Delta^*(\mathscr{I/I}^2)$ on $X$.

$\Delta(X)$ is a closed subscheme of a specific open subscheme $W\subset X\times_YX$. From here, we have a closed immersion $i:\Delta(X)\hookrightarrow W$, which gives us that the ideal sheaf $\mathscr{I}$ of $\Delta(X)$ inside $W$ is exactly the kernel of the morphism $i^\sharp: \mathcal{O}_W\to i_*\mathcal{O}_{\Delta(X)}$. (This part of your interpretation is correct,  and is exactly the definition of a closed immersion.)
Here are some examples:

*

*In the case when $X\to Y$ is separated, then $\Delta(X)$ is honestly closed inside $X\times_Y X$. For instance, if $X=\Bbb A^1_R=\operatorname{Spec} R[x]$ and $Y=\operatorname{Spec} R$, then $X\times_Y X=\operatorname{Spec} R[x_1,x_2]$, $W=X\times_YX$ and $\Delta(X)$ is the closed subscheme cut out by the ideal $(x_1-x_2)$, which is the kernel of the map $R[x_1,x_2]\to R[x]$ given by sending $x_1\mapsto x$ and $x_2\mapsto x$. (Here, I'm using the equivalence between quasicoherent sheaves on affine schemes and modules over the ring of global sections to work with modules instead of sheaves. If you don't like it, hit everything with the tilde/associated sheaf functor.)


*One can generalize (1) to the case of $X,Y$ affine, represented by $\operatorname{Spec} A$ and $\operatorname{Spec} B$, respectively. Since affine morphisms are separated, we can again take $W=X\times_Y X$ and calculate that the sheaf of ideals of $\Delta(X)$ is the sheaf associated to the module generated by $1\otimes_B a - a\otimes_B 1$ for all $a\in A$, as the structure sheaf of $X\times_YX$ is the sheaf associated to the module $A\otimes_BA$, which maps to $A$ by the obvious multiplication map sending $x\otimes_B y\mapsto xy$.


*In the case where $X\to Y$ is not separated, we actually need to pick $W$ in an interesting way. Consider the easiest example: let $Y=\operatorname{Spec} k$ and $X$ the affine line over $k$ with two origins $0_1,0_2$. Then the two closed points of $X\times_Y X$ given by $(0_1,0_2)$ and $(0_2,0_1)$ are in $\overline{\Delta(X)}$ but not in $\Delta(X)$, so we can construct $W$ to kick them out: let $W=(X\times_Y X) \setminus \{(0_1,0_2),(0_2,0_1)\}$. Now $\Delta$ is an honestly closed subscheme of $W$, and we can then compute the kernel of the map of structure sheaves affine-locally as in case 2 and patch together.
