Since there is more room to fit the reacting chemicals in a D battery, do they last longer or do they both have the same amount of materiel?
The glib answer is yes, D batteries keep going, and going…
Batteries are generally rated for capacity in terms of amp-hours. This indicates the amount of charge the battery is capable of holding. For example, a 5 amp-hour battery being used in a 1 amp circuit will be drained in 5 hours. There are some real world considerations that make that time longer but that’s the general idea.
Since there is more room, as you put it, in a D cell there is a great deal more capacity. D cells have about six times the storage of a AA cell.
How long any cell lasts depends on the load it’s connected to. Batteries are rated for their current delivering capacity over time, or “amp hours”. D cells have less bulk (internal) resistance & can provide larger bursts of instantaneous current than C, AA or AAA cells can. A car battery can deliver 800-1000 amps of instantaneous current, but only for about 30 seconds.
And considering the OP, I should have said a D cell provides about twelve times the capacity of a AAA cell.
I remember reading a battery comparison test in Consumer Reports a while ago. The Sears D-cell was in reality a AA, built up with padding until it was D-sized. Seemed a little dishonest to me.