2

I am trying to include a svg file using the \includesvg command. The svg file looks like this when opened in Illustrator as it includes some math mode text:

enter image description here

Now, I would like the image to use the artboard as shown in the screenshot as the viewbox. However, as there is text outside the artboard before LaTeX turns it into math mode text, the following happens when compiled:

enter image description here

Here I've placed the image in an \fbox for clarity. Additional whitespace is added to fit the text in its unformatted form. Is there some way of modifying the svg in order to restrict its size to the artboard size from Illustrator?

UPDATE: The following is a MWE (.tex and .svg) for the above issue. Clearly, the "size" as understood by the \includesvg command is calculated based on the unformatted text - I would like to just use the width parameter of the svg file.

test.tex:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{svg}

\begin{document}

\fbox{\includesvg[width=\linewidth]{test.svg}}

\end{document}

test.svg:

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
 width="737" height="368.5" viewBox="0 0 737 368.5" style="enable-background:new 0 0 737 368.5;" xml:space="preserve">
    <style type="text/css">
    .st0{fill:#FFFFFF;stroke:#1D1D1B;stroke-miterlimit:10;}
    .st2{fill:#1D1D1B;}
    .st3{font-family:'MyriadPro-Regular';}
    .st4{font-size:24px;}
    </style>
    <title>Title</title>
    <rect x="112.7" y="179.8" transform="matrix(0.9408 -0.3391 0.3391 0.9408 -45.3695 139.9065)" class="st0" width="530" height="40"/>
    <text transform="matrix(1 0 0 1 553.21 254.7425)" class="st2 st3 st4">$\Delta P_o = qlc_o\cdot\dot V^2$</text>
</svg>

  • 1
    can you share the svg and the code for a short document that includes it? – ian May 30 at 17:39
  • @ian included a MWE – Toivo Säwén Jun 1 at 10:38
1

You should set inkscapearea to page instead of the default drawing in the package options:

\usepackage[inkscapearea=page]{svg}

Note that you have to change your svg file or delete the exported files in the folder svg-inkscape for the image to be newly exported with this option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.