Next week I'll be giving a lecture on spectral sequences in algebraic geometry, and in the notes I'm preparing I wanted to put the spectral sequence below the title of the corresponding section in the table of contents. The \addcontentsline command was known to me, but \addtocontents wasn't, and there is one caveat in using it: you need to make sure you put \par at the end of the what you are adding (if it is actual text), forcing the next item to get its own paragraph.

So the macro


does the trick (change the vertical spacing to your liking), and using it just requires to say \tocequation{$a^2+b^2=c^2$} after the corresponding \section. A small excerpt of the result is

Table of contents containing an equation

The final results will be posted somewhere next week. I'll be posting a follow-up blogpost on some nitpickery regarding the notation for Čech cohomology later.