When writing in LaTeX with the explicit intention to later convert into epub, then this here might be helpful to consider for inclusion in the source files:
github.com/michal-h21/tex4ebook
On Debian, it is included in the 'texlive-extra-utils' package.