  In this paper, we give a sufficient condition for a set $\mathal G$ of
polynomials to be a Gr\"obner basis with respect to a given term-order for the
ideal $I$ that it generates. Our criterion depends on the linkage pattern of
the ideal $I$ and of the ideal generated by the initial terms of the elements
of $\mathcal G$. We then apply this criterion to ideals generated by minors and
pfaffians. More precisely, we consider large families of ideals generated by
minors or pfaffians in a matrix or a ladder, where the size of the minors or
pfaffians is allowed to vary in different regions of the matrix or the ladder.
We use the sufficient condition that we established to prove that the minors or
pfaffians form a reduced Gr\"obner basis for the ideal that they generate, with
respect to any diagonal or anti-diagonal term-order. We also show that the
corresponding initial ideal is Cohen-Macaulay and squarefree, and that the
simplicial complex associated to it is vertex decomposable, hence shellable.
Our proof relies on known results in liaison theory, combined with a simple
Hilbert function computation. In particular, our arguments are completely
algebraic.
