I am working on a textbook. I like the aesthetics of side notes when they are present on a page. I do not like the aesthetics of the large empty margin when no side note is present on a page. Is there a way for latex to dynamically modify the margin size if no side note is detected on a page (or vice versa).
I've explored using afterpage along with newgeometry, but they require specific knowledge about where the pagebreaks will occur.