Skip to content

Enable usage of LaTeX SVG package #1

Open
0xBigfish wants to merge 1 commit into
CheariX:mainfrom
0xBigfish:feat/svg-package
Open

Enable usage of LaTeX SVG package #1
0xBigfish wants to merge 1 commit into
CheariX:mainfrom
0xBigfish:feat/svg-package

Conversation

@0xBigfish
Copy link
Copy Markdown

Allow compilation of documents using the svg package

The svg package (\usepackage{svg}) allows including SVG images into LaTeX documents using \includesvg[widht=\textwidth]{path/to/svg}. This syntax is very similar to including "normal" graphics like JPG or PNG using \includegraphics[widht=\textwidth]{path/to/image}.

Under the hood, the svg package uses inkscape to transform SVG images into PDFs which are then embedded into the document. This pull request adds inkscape to the image to allow compilation of documents using the svg package.

Reproduce Bug

  • requires you to create a directory images and place an SVG file called Diagram.drawio.svg into it.
\documentclass[aspectratio=169, 10pt]{beamer}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{svg}

\begin{document}
\begin{frame}{Here is an SVG diagram}
\centering
\includesvg[width=\textheight]{images/Diagram.drawio.svg}

\end{frame}
\end{document}

Settings for VS Code / Codium to compile the file via LaTeX Workshop using the current version of the dev container

{
  "latex-workshop.latex.recipes": [
    {
      "name": "latexmk",
      "tools": [
        "latexmk"
      ]
    }
  ],

  "latex-workshop.latex.tools": [
    {
      "name": "latexmk",
      "command": "latexmk",
      "args": [
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "--shell-escape",
        "-pdf",
        "-outdir=%OUTDIR%",
        "%DOC%"
      ]
    }
  ],

  "latex-workshop.synctex.afterBuild.enabled": true,
  "latex-workshop.view.pdf.trim": 1,
  "latex-workshop.view.pdf.viewer": "tab",

  "telemetry.enableTelemetry": false,
  "latex-workshop.docker.enabled": true,
  "latex-workshop.docker.image.latex": "ghcr.io/chearix/vscode-devcontainer-latex:main"
}

Error Log

Note the hints of missing information regarding Inkscape and the missing converted files.

<SNIP>

Package svg Warning: No version of Inkscape was detected by invoking
(svg)                `inkscape -V'
(svg)                so the Inkscape export will fail quite sure as the
(svg)                command is probably unknown to your OS. You could set
(svg)                `inkscapeversion=<version>' manually but this is very
(svg)                unlikely to work on input line 8.

(./test.nav)
Package svg Info: Calling Inkscape on input line 13.
runsystem(inkscape "images/Diagram.drawio.svg" -D --export-latex --export-filen
ame="Diagram.drawio_svg-tex.pdf")...executed.

runsystem(inkscape "images/Diagram.drawio.svg" -D --export-latex \relax --witho
ut-gui --export-pdf="Diagram.drawio_svg-tex.pdf")...executed.



./test.tex:13: Package svg Error: Inkscape version not detected.

See the svg package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.13 \end{frame}
                
It was tried to invoke `inkscape'
for file "images/Diagram.drawio.svg"
but no result was produced. Check the log file
and set `inkscapeversion=<version>' manually.

runsystem(inkscape "images/Diagram.drawio.svg" -D --export-latex --export-filen
ame="Diagram.drawio_svg-tex.pdf")...executed.


Package svg Warning: The export with Inkscape failed for file
(svg)                `images/Diagram.drawio.svg'
(svg)                Troubleshooting: Please check in the log file how
(svg)                the invocation of Inkscape took place and try to
(svg)                execute it yourself in the terminal on input line 13.


./test.tex:13: Package svg Error: File `Diagram.drawio_svg-tex.pdf' is missing.


See the svg package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.13 \end{frame}
                
Did you run the export with Inkscape? There's no file
`./svg-inkscape/Diagram.drawio_svg-tex.pdf'
although `images/Diagram.drawio.svg' was found.


./test.tex:13: Package svg Error: File `Diagram.drawio_svg-tex.pdf_tex' is miss
ing.

See the svg package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.13 \end{frame}
                
Did you run the export with Inkscape? There's no file
`./svg-inkscape/Diagram.drawio_svg-tex.pdf_tex'
although `images/Diagram.drawio.svg' was found.

<SNIP>

Reproduce Fix

  • Build the adjusted Docker image (where inkscape is present) and recompile. I called the adjusted image latex-workshop.docker.image.latex": "ghcr.io/chearix/vscode-devcontainer-latex:with-inkscape

Update this single line in the .vscode/settings.json file to use the new dev-container image.

  "latex-workshop.docker.image.latex": "ghcr.io/chearix/vscode-devcontainer-latex:with-inkscape",

…ocker image

The LaTeX svg package requires inkscape to
transform SVGs into PDF which are then
embedded in the document.

The svg package can be used using
\usepackage{svg}
@0xBigfish 0xBigfish changed the title Draft: Enable usage of LaTeX SVG package Enable usage of LaTeX SVG package May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant