title_body: Software recommendation for writing ebook and exporting to multiple formats I am thinking about writing and/publishing an ebook with the following in mind:
  
  
  It will contain code (needs proper formatting)
  I should be able to publish PDF and EPUB versions
  I might need to have an HTML version of the book too
  
  
  Since I am new to this stuff, I wonder if anyone could give me some points on which software (free/paid) I should use for writing/formatting the ebook.
  
  I have used LaTeX about 8 years ago, and I really liked it, but I am not sure if I can export to the formats I want with LaTeX.
upvoted_answer: Pandoc is your friend here.  
  
  Pandoc can take your input file (LaTeX, markdown, other) and transform it to PDF, EPUB, HTML (and many more).
  
  Pandoc is cross-platform and free under the GPL, although donations are appreciated.
  
  With regards to formatting your code, both LaTeX and markdown have components that will help.  LaTeX has many more layout options.
  
  I've used both LaTeX and markdown to produce ebook (ePub) files.  An example of using pandoc with LaTeX is shown in another ebooks.stackexchange.com question I posted.   
  
  It's great to have a range of options.