Search code examples
emacsorg-mode

emacs org-mode: how to choose font when exporting to HTML?


A file under org-mode can be exported to HTML using this:

C-c C-e h o

or

(org-export-dispatch) h o

And you'll get that ugly looking times font...

Is there a simple way to set another font?

Also interested in what is the proper (complicated) way :)


Solution

  • You have different options, depending on how elaborate you want to get... Easiest:

    #+HTML_HEAD_EXTRA: <style>*{font-family: serif !important}</style>
    

    More advanced:

    #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="myStyleSheet.css"/>
    

    You can also put it all into a setup file and include it in your org-file:

    #+SETUPFILE: ~/.emacs.d/org-templates/level-0.org
    

    In that file there could be stuff like this (in this case, Charset, your stylesheet, Mathjax for nice Latex-style formulars):

    #+HTML_HEAD_EXTRA: <meta charset="utf-8">
    #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="static/myStyle.css" />
    #+HTML_HEAD_EXTRA: <script async type="text/javascript" src="https://cdn.rawgit.com/mathjax/MathJax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>