h1, h2 { page-break-after: avoid; page-break-before: auto; } pre, blockquote { border: 1px solid #999; page-break-inside: avoid; } img { max-width: 100% !important; page-break-inside: avoid; } section { page-break-after: always; &#cover { padding: 3cm 0cm; text-align: center; h1 { font-size: 1.5cm; } } &#summary { text-align: center; ul { font-size: 0.5cm; line-height: 1.8em; padding: 0px; margin: 0px; list-style: none; } > ul { > li { margin-bottom: 1cm; > a { font-size: 0.6cm; } } } } article { margin: 1.5cm; /* Big centered title */ &.new-chapter { page-break-after: always; font-size: 0.6cm; text-align: center; padding: 3cm 0cm; border-top: 1px solid #ccc; @media print { border: none; } } .exercise { margin: 1cm 0cm; padding: 0.4cm; page-break-inside: avoid; border: 3px solid #ddd; .exercise-header { margin-bottom: 0.4cm; padding-bottom: 0.2cm; border-bottom: 1px solid #ddd; } } } }