Lack of dilithium spares is good continuity. Apparently, the stuff is really rare and expensive - and Kirk consumes those crystals in several episodes, quite possibly running out of spares in the process.
FWIW, the last time Kirk was crippled by dilithium shortage, in "Mudd's Women", he had spent the previous episodes at the very edge of the known, in "Where No Man" and "Corbomite Maneuver" by production order (or just "Where No Man" by stardate order), having had no chance to visit a starbase, and was quite plausibly short on supplies. The episode preceding "Elaan of Troyius" in turn was "Immunity Syndrome" where the ship almost completely drained of energy. While the episode did end with our heroes sailing toward the safety of a starbase, "Elaan" opens with the remark that the mission is top secret, and may have diverted our heroes from their intended shore leave.