One of the most heartwrenching experiences in knitting is finishing a challenging project—say an intricate Fair Isle pullover—only to discover that it's way bigger than it should have been. You used the yarn and needles that the pattern called for, and used the numbers for your size, but it's ten inches bigger around than the pattern said it would be. You try it on, but no matter how much you try to rationalise about the need for extra ease or the convenience of being able to layer six sweaters underneath it because it gets cold in the winter, you know, and layering is good in the cold, it just doesn't look good. At all. Layers or no.
Shamefaced, you're left with the task of either unravelling the entire thing and starting again, or finding someone who will fit into a pullover sized to fit the Incredible Hulk if he had strangely foreshortened arms and torso.
What went wrong?
Swatch and swatch
Gauge, also called tension, is the number of knitted stitches and rows over a given width or length of knitted fabric, worked in a given pattern. For instance, a pattern might tell you that the gauge at which it is to be knitted is twenty stitches and twenty-five rows over four inches in stockinette stitch. (This would probably be written in abbreviated form, thus: 20 sts and 25 rows = 4" in st st; gauge also might be measured over centimetres instead of inches, as 20 sts and 25 rows= 10cm in st st.) "Stitch gauge" refers specifically to stitches per inch, and "row gauge" refers to rows per inch.
Gauge is just as critical in crochet as it is in knitting, and it is measured the same way.
Gauge depends on a number of factors: the type of yarn you're using, the size of the needles you're working with, the stitch pattern you're following, and your own tension as a knitter, to name a few. As a general rule, bulky yarns that don't have a lot of loft to them tend to produce bigger stitches; this makes the gauge come out to fewer stitches and rows per inch. Thinner yarns, or loftier yarns, will work up with more stitches and rows to the inch. Switching to bigger needles will produce fewer stitches and rows to the inch; smaller needles will yield more stitches and rows to the inch. A naturally tight knitter might have to use larger needles than a loose knitter, to achieve the same gauge with the same yarn. If you had a stressful day you might have to go up a needle size—a knitter's tension will fluctuate based on her mood or tiredness more drastically than you might expect. Ribbing and seed stitch will draw in a bit and therefore will have more stitches to the inch than stockinette stitch. The yarnovers in a lace pattern might cause the knitting to stretch out a bit, and there will be fewer stitches to the inch than a swatch of stockinette. Sometimes, a knitter's tension differs between knitting and purling, so a swatch of stockinette might have more stitches to the inch if she worked it in the round than if she worked it back and forth. Et cetera.
The upshot is that you can't really predict with any accuracy what your gauge is going to be unless you've made a sample piece and measured with a ruler how many stitches and rows there are to the inch, or the centimetre, or any other appropriate unit of length.
The sample piece is called a gauge swatch or tension swatch, and "swatching" is the process of making it. (Or them. Sometimes you need to make more than one swatch until you end up with the appropriate gauge.) Because your tension might be a bit different toward the edges of a knitted piece, you want a swatch to be amply-sized; loosely cast on at least four inches' worth of stitches. The sample gauge above says that four inches would be twenty stitches; when I'm swatching, I cast on six inches' worth for good measure. Where four inches equals twenty stitches, there are five stitches to the inch, so six inches is thirty stitches. (This is about as complicated as knitting math gets.) Work in whatever stitch pattern you want to measure your gauge over—usually stockinette stitch, sometimes a lace or textured pattern, sometimes garter stitch or ribbing, or whatever the pattern specifies—until the swatch is roughly square, then cast off as loosely as you can.
Knitted items usually end up being washed at one point or another, so wash your swatch as you would wash a finished item before you measure gauge. Doing this will help you be prepared for surprises, like cotton that shrinks or wool that blooms. At this point you may as well block it, too, again as you'd block a finished item. When the swatch is completely dry, measure gauge by laying a tape measure across a row of stitches, sticking pins in the knitting exactly four inches apart; do the same for the rows. Then count the stitches and rows between the pins, rounding to the nearest half or quarter of a stitch if you can. Write down those numbers, and the fact that you measured over four inches; this is your gauge.
Measuring over four inches is wiser than measuring over one inch because it's more likely to be accurate: if you round to the nearest half-stitch over one inch, that errant third of a stitch or whatever was rounded out of existence will come back to haunt you. Measuring over four inches minimises its impact.
When you're following a pattern, usually gauge will be provided for you. This means that you need to swatch until you are able to match that gauge: if you are getting too few stitches to the inch, go down a needle size; if you're getting too many, go up a needle size. Lather, rinse, and repeat until your gauge matches what the pattern says; bad things happen if you don't.
When gauge goes wrong
Suppose that my hypothetical Fair Isle pullover is designed to measure 40" around the bust, with a gauge of 5 stitches to the inch. Multiplying those two numbers means that I need to cast on 200 stitches, which is what the pattern calls for. But if I'm getting 4 stitches to the inch—unwittingly, since I didn't bother to swatch and see—those 200 stitches will make a sweater body fifty inches around. Disastrous!
It could just as easily go the other way: if I got 6 stitches to the inch, my 200 stitches would make a sweater about 33" around. Another disaster!
Row gauge is just as important as stitch gauge, though it often fades into the background. Knitting patterns usually specify the length of a piece to be knitted in inches or centimetres, not in rows—but when it comes to things like sleeve caps or v-necks or waist shaping, everything would be thrown off-kilter if your row gauge was wrong. Measure row gauge with the same attention to detail as you measure stitch gauge.
Often, knitted sweaters have bands of ribbing or something similar along their cuffs and hems and collars. Ribbing tends to look sloppy if it's worked on the same size needles that you'd normally use with a given yarn for a flat stitch like stockinette, but it looks tidy and "finished" if it's worked on needles that are a size or two smaller. Patterns will sometimes suggest that you do this, without giving a suggested gauge for the sections worked on smaller needles; this is usually pretty safe because it's worked over a small area and the designer has taken the gauge difference into account. But if you're curious about how it will turn out, it is safer still to swatch and see for yourself.
This is a pretty tedious process to endure if all you want to do is start knitting the goddamned project already. There are a few different ways to circumvent swatching; all of them are to be undertaken at your peril.
Shortcuts
I don't like making gauge swatches, and I'll go to great lengths to avoid them. My two favourite tactics are making things where exact size isn't terribly important—shawls or scarves or curtains or tablecloths—with texture and drape in mind instead of stitches per inch, or making garments without swatching and finding people who fit into them after they're finished. Sometimes neither of these solve anything: perhaps you want to knit something for yourself or another specific person, and perhaps you (or they) are tired of shawls and scarves.
Knitting maven Elizabeth Zimmerman suggested another tactic for dodging gauge swatches, this time when making a sweater: start in on a sleeve with needles you think are the right size, and measure after a few inches to see if you're getting gauge. If you are, congratulations; you're a few inches into a sleeve. If you aren't, rip back and try again with different needles; you aren't out too much time and effort.
This is a fine strategy if you're pressed for time and think you'll be close enough to gauge for the gamble to pay off. Unfortunately, it's still safer—and probably faster in the long run—to bite the bullet and make a proper gauge swatch before you start in on the project; it might be irritating, but you'll know for sure that the end result will turn out exactly the size that you want it.
for hapax, with thanks to DejaMorgana for input.