The word "expletive" is commonly understood to mean a swear word, but that is not, in fact, its oldest meaning. Merriam-Webster defines expletive as follows:
1 a : a syllable, word, or phrase inserted to fill a vacancy (as in a sentence or a metrical line) without adding to the sense
especially : a word (such as it in "make it clear which you prefer") that occupies the position of the subject or object of a verb in normal English word order and anticipates a subsequent word or phrase that supplies the needed meaningful content
b : an exclamatory word or phrase
especially : one that is obscene or profane
2 : one that serves to fill out or as a filling
Expletive in the sense of a swear word has been common since at least the 1930s. The quotation from In the Midst of Alarms demonstrates that it was definitely prevalent even before then, but the primary meaning would be "filler". Since swear words are fillers that don't add to the literal meaning of the phrase, using expletive for swear word is appropriate.
This latter sense of the term became the most recognized one after the Watergate scandal. When the Nixon White House tapes were released in 1973 and 1974, transcripts substituted expletive deleted for every obscenity on the recordings. Since then, we tend to assume that expletive must mean swear word. But in 1874, when Barr was writing, expletive would have had the primary meaning of filler.
The narrator is making a kind of pun. On the one hand, damn is an expletive in the sense of a swear word. On the other hand, mathematics books would not contain swear words. It's a subtle, deadpan joke that relies on increasingly shifting attributions of meaning: the narrator is equating the ordinary words with which maths books are filled with filler and then, with a pun on the dual meaning of expletive, with swear words.