Skip to content

Commit 1e3485c

Browse files
committed
Set latex_toplevel_sectioning based on toc
1 parent 175efc0 commit 1e3485c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

jupyterbook_latex/events.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ def setup_latex_transforms(app: Sphinx) -> None:
6868
# if using the sphinx-external-toc, we can look if parts are being specified
6969
# TODO this should probably be made more robust
7070
sitemap = getattr(app.config, "external_site_map", None)
71-
if (
72-
sitemap is not None
73-
and sitemap.file_format == "jb-book"
74-
and len(sitemap.root.subtrees) > 1
75-
):
76-
app.config["latex_toplevel_sectioning"] = "part"
77-
app.env.jblatex_captions_to_parts = True
71+
if sitemap is not None:
72+
if sitemap.file_format == "jb-book" and len(sitemap.root.subtrees) > 1:
73+
app.config["latex_toplevel_sectioning"] = "part"
74+
app.env.jblatex_captions_to_parts = True
75+
elif sitemap.file_format == "jb-book":
76+
app.config["latex_toplevel_sectioning"] = "chapter"
77+
elif sitemap.file_format == "jb-article":
78+
app.config["latex_toplevel_sectioning"] = "section"
7879

7980
logger.info(
8081
bold("jupyterbook-latex v%s:") + "engine='%s', toplevel_section='%s'",

0 commit comments

Comments
 (0)