Let k be a field and let X be a finite type scheme over k. Let F be a coherent O_X-module which is *generically invertible*. This means there exists a an open dense subscheme such that F is an invertible module when restricted to that open.

**Lemma:** There exists an open subscheme U containing all codimension 1 points, an invertible O_U-module L, and a map a : L → F|_U which is generically an isomorphism, i.e., there exists an open dense subscheme of U such that a restricted to that open is an isomorphism.

*Proof.* We already have a triple (U, L, a) for some dense open U in X. To prove the lemma we can proceed by adding 1 codimension 1 point ξ at a time. To do this we may work over the 1-dimensional local ring at ξ, where the existence of the extension is more or less clear.

Now assume that X is equidimensional of dimension d. Then we have a Chow group A_{d-1}(X) of codimension 1 cycles. If X is integral this is called the Weil divisor class group. For F as above we pick (U, L, a) as in the lemma. Observe that A_{d-1}(U) = A_{d-1}(X).

**Def:** The *divisor associated to* F is c_1(L) ∩ [U]_d + [Coker(a)]_{d-1} – [Ker(a)]_{d-1}

The notation here is as in the chapter Chow Homology of the Stacks project. The first term c_1(L) ∩ [U]_d is the first chern class of L on U and the other two terms involve taking lengths at codimension 1 points. Using the lemma to compare different triples for F it is easy to verify this is well defined as an element of A_{d-1}(X).

**Def:** Assume in addition X is generically Gorenstein, i.e., there exists a dense open which is Gorenstein. Let ω and ω’ be the cohomology sheaves of the dualizing complex of X in degrees -d and -d+1. The *canonical divisor* K_X is the divisor associated to ω minus [ω’]_{d-1}.

There you go; you’re welcome!

**Rmks:**

1. Fulton’s “Intersection Theory” defines the todd class of X in complete generality.

2. If X is generically reduced, then X is generically regular, hence generically Gorenstein and our definition applies.

3. The term [ω’]_{d-1} is zero if X is Cohen-Macaulay in codim 1.

4. If X is Gorenstein in codimension 1, then our canonical divisor agrees with the canonical divisor you find in many papers.

5. A canonical divisor of an equidimensional X can always be defined: either by Fulton or by generalizing the definition of the divisor associated to F to the case where F and O_X define the same class in K_0(Coh(U)) for some dense open U. This will always be true for ω. Just takes a bit more work.

6. If X is proper and equidimensional of dimension 1, then χ(F) = deg(divisor asssociated to F) + χ(O_X) whenever F is generically invertible.

7. If X is proper and equidimensional of dimension 1, then deg(K_X) = – 2χ(O_X).

8. If X is a curve and f : Y → X is the normalization, then K_X = f_*(K_Y) + 2 ∑ δ_P P where δ_P is the delta invariant at the point P (Fulton, Example 18.3.4).

9. If X is equidimensional of dimension 1 and Z ⊂ X is the largest CM subscheme agreeing with X generically, then K_X = K_Z – 2 ∑ t_P P where t_P is the length of the torsion submodule in O_{X,P}.

**Edit 3/1/2016:** Jason Starr commented below that there is a refinement which is sometimes useful, namely, one can ask for a Todd class and Riemann-Roch in K-theory and he just added by email: “In our joint work on rational simple connectedness of low degree complete intersections, we need to know that certain (integral) Cartier divisor classes on moduli spaces are Q-linearly equivalent. It is not enough to know that the pushforward cycles classes to the (induced reduced) coarse moduli scheme are rationally equivalent. So we need the Riemann-Roch that works on K-theory. In fact, the relevant computations are in our earlier manuscript about “Virtual canonical bundle …”, and we slightly circumvent Riemann-Roch in the computation. But, morally, we are using a Todd class that lives in K-theory, not just in CH_*.”