Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1705,6 +1705,7 @@ raw template
{%- endblock in_prompt -%}
"""


exporter_attr = AttrExporter()
output_attr, _ = exporter_attr.from_notebook_node(nb)
assert "raw template" in output_attr
Expand Down
4 changes: 4 additions & 0 deletions share/templates/latex/base.tex.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ override this.-=))
% Basic figure setup, for now with no caption control since it's done
% automatically by Pandoc (which extracts ![](path) syntax from Markdown).
\usepackage{graphicx}
% Pandoc may emit alt={...} for images. Treat it as metadata so graphicx
% and adjustbox do not reject otherwise valid images.
\makeatletter\define@key{Gin}{alt}{}\makeatother

% Keep aspect ratio if custom image width or height is specified
\setkeys{Gin}{keepaspectratio}
% Maintain compatibility with old templates. Remove in nbconvert 6.0
Expand Down
6 changes: 6 additions & 0 deletions tests/exporters/test_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def test_export_book(self):
)
assert len(output) > 0

def test_graphics_alt_key_is_defined(self):
"""Pandoc image alt metadata should be accepted by the LaTeX preamble."""
output, _resources = LatexExporter().from_notebook_node(v4.new_notebook())

assert r"\define@key{Gin}{alt}{}" in output

@onlyif_cmds_exist("pandoc")
def test_very_long_cells(self):
"""
Expand Down
Loading