This document shows how you can get ePub/eBook-like formatting in LaTeX with the memoir document class. You can't yet export directly to ePub from writeLaTeX, but you can export to PDF. To get ePub, you can download the LaTeX source from writeLaTeX and run it through a format conversion tool, such as htlatex to get HTML, and then go from HTML to ePub with a tool like Sigil or Calibre. See this thread on Stack Overflow for more advice.
A very experimental hackety hack to export ePubs from LaTeX on Overleaf, using tex4ebook. After creating a new project from this template and when compilaton has completed, download the generated .epub file using the steps described here. This is provided 'as is' and is not officially supported by Overleaf.
In this sample set-up, the .epub export will only be triggered if the project is set to compile with pdfLaTeX and will likely fail with many packages; this is a very basic example and this is a hackety-hack.
See the tex4ebook Github repository for documentation and discussion; though bear in mind that . Overleaf does not necessary have the most up-to-date tex4ebook release.
This template allows you a quick start creating books with LaTeX that you can directly publish on Amazon, Google, and Leanpub as e-book or printed editions. Check out the accompanying book "Even Better Books with LaTeX the Agile Way in 2023" for step-by-step instructions for this template: https://www.amazon.com/Better-Books-LaTeX-Agile-Book-ebook/dp/B0BMZJ5LF7
Check https://www.instagram.com/p/CnSpX9UqoQ6/ for an illustrated quickstart guide on how to use the template for your book.