Better typography for IPython notebooks, now

I came across a long blog about how to make ipython notebooks more aesthetically pleasing recently, and I think there is a lot to be learned there.

The good news is that you can try this out on a notebook-by-notebook basis with a little trick. Just drop this into a cell in any IPython notebook:

import IPython.core.display

IPython.core.display.HTML("""

div.input {
width: 105ex; /* about 80 chars + buffer */
}

div.text_cell {
width: 105ex /* instead of 100%, */
}

div.text_cell_render {
/*font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;*/
font-family: "Charis SIL", serif; /* Make non-code text serif. */
line-height: 145%; /* added for some line spacing of text. */
width: 105ex; /* instead of 'inherit' for shorter lines */
}

/* Set the size of the headers */
div.text_cell_render h1 {
font-size: 18pt;
}

div.text_cell_render h2 {
font-size: 14pt;
}

.CodeMirror {
 font-family: Consolas, monospace;
 }


""")

3 Comments

Filed under Uncategorized

3 responses to “Better typography for IPython notebooks, now

  1. Carl

    This is some neat synchronicity: Just a couple of days ago I was trying to get Gelman’s radon model to work in PyMC and found your blog after I got stuck…

    Thanks for posting this. Some commenters on my post referred to this (and similar) tricks, but it’s good to have an explicit example.

  2. @carl: Synchronicity, indeed!

    You have a good eye for this stuff, and you could use this trick to put together a little ipython notebook style module. I’d love to say:

    import ipynb_style
    ipynb_style.clean()

    and benefit from any future insights you have.

    Here is a gist for that: https://gist.github.com/aflaxman/5707238

  3. Pingback: To See Takes Time: Stiegl Typography Sketched | Jennifer Hartnett-Henderson