Commits

Georg Brandl committed 6b6e62e

Raise a better error on too many section levels.

Comments (0)

Files changed (1)

sphinx/latexwriter.py

             self.this_is_the_title = 0
             raise nodes.SkipNode
         elif isinstance(parent, nodes.section):
-            self.body.append(r'\%s{' % self.sectionnames[self.sectionlevel])
+            try:
+                self.body.append(r'\%s{' % self.sectionnames[self.sectionlevel])
+            except IndexError:
+                from sphinx.application import SphinxError
+                raise SphinxError('too many nesting section levels for LaTeX, '
+                                  'at heading: %s' % node.astext())
             self.context.append('}\n')
         elif isinstance(parent, (nodes.topic, nodes.sidebar)):
             self.body.append(r'\textbf{')