mrpiggi / svg

Handling SVG pictures in LaTeX documents using Inkscape, ImageMagick and/or Ghostscript
Other
65 stars 12 forks source link

\includesvg in Beamer causing wrong figure placement #45

Closed gzagatti closed 2 years ago

gzagatti commented 2 years ago

I am facing an issue in which the command when using the beamer class and the svg package. My preamble looks lie this:

\documentclass[aspectratio=169]{beamer}
\usepackage{svg}
\svgsetup{inkscapearea=page, inkscapelatex=false}

Then I want to place an image:

\begin{frame}{Point process}
  \begin{figure}
  \centering
  \includesvg[width=\textwidth]{assets/spatial-pp-realizations.svg}
  \caption{foo}
  \end{figure}
\end{frame}

This will cause the generated image to be placed at the top corner of the slide.

image

However, when placing the file generated by the \includesvg macro directly on the figure:

\begin{frame}{Point process}
  \begin{figure}
  \centering
  \includegraphics[width=0.7\textwidth]{svg-inkscape/spatial-pp-realizations_svg-raw.pdf}
  \caption{foo}
  \end{figure}
\end{frame}

The image then appears in the right place:

image

I think this might be an issue related with the interaction of the svg package and beamer. I have noticed that you define a branch with \if@svgx@beamer.

mrpiggi commented 2 years ago

Maybe, choosing inkscapearea=drawing would be a solution for you? Just see the difference between the outputs of the following example:

\begin{filecontents}[noheader]{foo-example.svg}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg">
  <g>
  <text>Package svg: \LaTeX</text>
  </g>
</svg>
\end{filecontents}

\documentclass[aspectratio=169]{beamer}
\usepackage{svg}
\svgsetup{inkscape=force,inkscapelatex=true}
\svgsetup{inkscapearea=page}
%\svgsetup{inkscapearea=drawing}
\begin{document}
\begin{frame}{Point process}
  \begin{figure}
  \centering
  \fbox{\includesvg{foo-example}}
  \caption{foo}
  \end{figure}
\end{frame}
\end{document}

issue45_page.pdf issue45_drawing.pdf

gzagatti commented 2 years ago

Thanks for your help.

I managed to solve the problem by passing the flag inkscapelatex=true like in your example. It had nothing to do with the inkscapearea option.

With that being said, it would be useful if with the inkscapelatex=false option we obtained the same result as with using the generated pdf image.

mrpiggi commented 2 years ago

Well, there is a huge difference between inkscapelatex=true and inkscapelatex=false how the graphic export is done by Inkscape and the result is output by package svg. I would need the origin SVG file in order to do some investigations.

gzagatti commented 2 years ago

Here is the file.

spatial-pp-realizations

Thanks for taking the time to investigate this issue. It would be useful to know the main difference between inkscapelatex=true and inkscapelatex=false. I was mainly using this option to toggle between using LaTex fonts or Inkscape.

mrpiggi commented 2 years ago

It would be useful to know the main difference between inkscapelatex=true and inkscapelatex=false. I was mainly using this option to toggle between using LaTex fonts or Inkscape.

That's exactly the purpose of this option. But if LaTeX support is enabled, the export done by Inkscape differs as all text snippets are exported to an additional *.pdf_tex file, which has to be processed by package svg in a different manner.

Concerning your provided file, I do not have any problems to use it with beamer and get the expected result with this example and compiling via LuaLaTeX:

\documentclass[aspectratio=169]{beamer}
\usepackage{svg}
\begin{document}
\begin{frame}{Point process}
  \begin{figure}
  \centering
  \includesvg{chart}
  \caption{foo}
  \end{figure}
\end{frame}
\end{document}

issue45

gzagatti commented 1 year ago

Thanks! I can confirm I go the same results as you.