My main program for producing books is, and has been for many years, Adobe InDesign. It gives great typographical control and produces very good ePub3 files. However, I've never been entirely happy with it, especially since Adobe introduced its expensive subscription model.
Perhaps the biggest problem when producing printed books with InDesign is that, being wedded to the WYSIWYG model, it doesn't have automatic page make-up. Long before InDesign even existed, in the early 1980s, Leslie Lamport had taken Donald Knuth's TeX typesetting program, developed back in the 1960s, and had created a markup language called LaTex. This language allows you to mark up the elements of a book (or article) by function (e.g. chapter, subhead, subsubhead, etc.). Many tedious tasks are automated: numbering of chapters, figures, tables and equations (TeX and LaTeX are partcularly good a mathematical setting) is automatic; instead of placing an illustration at a particular place, you can tell the program to place it somewhere near a particular piece of text, at the top of the page. There are tools for indexing, cross-referencing and creating bibliographies.
Of course, being about forty years old (and being based on an even earlier program), LaTeX is showing its age a bit. When I started using it, you couldn't even use PostScript fonts with it and OpenType fonts hadn't even been invented – and neither had unicode. The remarkable thing is that Donald Knuth, a mathematician, had not only designed TeX but also a program called MetaFont to create the bitmap fonts (and would generate them in the required sizes on the fly).
Fortunately, the large TeX/LaTex community has been coming up with solutions for LaTeX's weaknesses. It is now possible to use OpenType fonts and unicode input. Because LaTeX is well-structured, it is remarkably easy to convert it to ePub3 format and even to convert mathematics to MathML, the format used to display mathematics in ePub3. You can even convert LaTex to XML but I feel that is the wrong way around. If one wants XML, one should start with that and convert it to ePub3 and LaTex, which is also possible. In theory, the conversion from XML to ePub3 should be particularly easy as ePub3 consists of XHTML (a subset of XML) held together with a few other files. However, at the moment, I think that starting with LaTeX is probably simpler.
Once you have an ePub3 file, it takes very little work to prepare it for Apple Books. There are also ways to convert the ePub3 file for Kindle. For Diana Dennis's Finding a Way, I tried to produce the Kindle version using two free programs, Calibre and Sigil, both of which have been available for many years. For some reason, neither produced acceptable results. On previous projects I'd tried Amazon's own Kindle Preview program but it kept crashing on my Mac. However, I downloaded the latest version and it made a really good conversion. I must also applaud Amazon for their new Kindle Create app. It doesn't convert ePub3 files but it offers several other ways to make Kindle books and works very well.