Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX export: Support SVG image files via the svg LaTeX package #2190

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
19 changes: 17 additions & 2 deletions share/templates/latex/base.tex.j2
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ override this.-=))
\usepackage{graphicx}
% Keep aspect ratio if custom image width or height is specified
\setkeys{Gin}{keepaspectratio}
% Maintain compatibility with old templates. Remove in nbconvert 6.0
\let\Oldincludegraphics\includegraphics
% Ensure that by default, figures have no caption (until we provide a
% proper Figure object with a Caption API and a way to capture that
% in the conversion process - todo).
Expand Down Expand Up @@ -93,6 +91,23 @@ override this.-=))
% normalem makes italics be italics, not underlines
\usepackage{soul} % strikethrough (\st) support for pandoc >= 3.0.0
\usepackage{mathrsfs}
\usepackage{svg} % enable support for rendering SVGs via Inkscape
\makeatletter
% Hook to includgraphics to pass SVGs to \includesvg
\let\includegraphics@original\includegraphics
% Hook
\renewcommand{\includegraphics}[2][]{%
\def\svgextension{svg}
\filename@parse{#2}%
\ifx\filename@ext\svgextension
\includesvg[width=\textwidth,#1]{#2}
\else
\includegraphics@original[#1]{#2}
\fi
}%
\makeatother
% Maintain compatibility with old templates. Remove in nbconvert 6.0
\let\Oldincludegraphics\includegraphics
((* endblock packages *))

((* block definitions *))
Expand Down
Loading