Skip to content

Instantly share code, notes, and snippets.

@adunning
Created August 12, 2014 02:51
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save adunning/e81342fd8e9a9da9ff51 to your computer and use it in GitHub Desktop.
Save adunning/e81342fd8e9a9da9ff51 to your computer and use it in GitHub Desktop.
Better default epub.css for Pandoc (tested with iBooks)
/* This defines styles and classes used in the book */
body { margin: 0; text-align: justify; font-size: medium; font-family: Athelas, Georgia, serif; }
code { font-family: monospace; }
h1 { text-align: left; }
h2 { text-align: left; }
h3 { text-align: left; }
h4 { text-align: left; }
h5 { text-align: left; }
h6 { text-align: left; }
h1.title { }
h2.author { }
h3.date { }
ol.toc { padding: 0; margin-left: 1em; }
ol.toc li { list-style-type: none; margin: 0; padding: 0; }
/* Disable hyphenation for headings to avoid single-syllable-lines.
*/
h1,
h2 {
-epub-hyphens: none;
-webkit-hyphens: none;
-moz-hyphens: none;
hyphens: none;
}
/* Set the minimum amount of lines to show up on a separate page. (There is not much support for this at the moment.)
*/
p,
blockquote {
orphans: 2;
widows: 2;
}
/* Turn on hyphenation for paragraphs and captions only.
*/
p,
figcaption {
-epub-hyphens: auto;
-webkit-hyphens: auto;
-moz-hyphens: auto;
hyphens: auto;
}
/* Shortcodes for page-break rules.
Use data attributes to designate if and how the page should be broken before, inside or after an element.
*/
h1, h2, h3, h4, h5, h6,
table, img, figure, video,
[data-page-break~=inside][data-page-break~=avoid] { page-break-inside: avoid; }
[data-page-break~=after] { page-break-after: always; }
h1, h2, h3, h4, h5, h6,
[data-page-break~=after][data-page-break~=avoid] { page-break-after: avoid; }
[data-page-break~=before] { page-break-before: always; }
[data-page-break~=before][data-page-break~=avoid] { page-break-before: avoid; }
img[data-page-break~=before] { page-break-before: left; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment