title: Including SVG into LaTeX
body: <p>I want to include a svg file in a LaTeX document.</p>
  
  <h1>a.svg (given)</h1>
  
  <p><a href="https://i.stack.imgur.com/8aYDu.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8aYDu.png" alt="given.svg"></a></p>
  
  <h1>a.pdf (goal)</h1>
  
  <p><a href="https://i.stack.imgur.com/4LqPV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4LqPV.png" alt="goal.pdf"></a>
  I created the table with OpenOffice, exported it to a pdf-file, imported it into inkscape afterwards and saved it as an svg file.</p>
  
  <h1>What I have tried</h1>
  
  <h2>Include svg directly</h2>
  
  <p>I tried to include the given svg file directly using the <a href="ftp://ftp.dante.de/tex-archive/graphics/svg/svg.pdf" rel="noreferrer" title="svgPackage">svg package</a>:</p>
  
  <pre><code>\usepackage{svg}
  ...
  \includesvg{img/a}
  </code></pre>
  
  <p>But it did not compile, because pdflatex did not found the file a. I also tried a.svg but without any success :(</p>
  
  <h2>Exporting to pdf "on the fly"</h2>
  
  <p>Following <a href="http://tug.ctan.org/tex-archive/info/svg-inkscape/InkscapePDFLaTeX.pdf" rel="noreferrer" title="Include Svg in LaTeX">J. Engelen</a> I tried to generate the pdf file using pdflatex with  -enable-write18 or --shell-escape but it didn't do anything with the .svg file except throwing an error, that the .pdf_tex file is missing.</p>
  
  <h2>Export to pdf / pdf_tex before including</h2>
  
  <p>I exported the svg file using inkscape v. 0.92:</p>
  
  <blockquote>
    <p>inkscape -D -z --file=a.svg --export-pdf=a.pdf --export-latex</p>
  </blockquote>
  
  <p>I got a .pdf file containing the blank table:
  <a href="https://i.stack.imgur.com/4LqPV.png" rel="noreferrer"><img src="https://i.stack.imgur.com/m9zIx.png" alt="raw pdf file"></a>
  And a .pdf_tex file containing the following:</p>
  
  <pre><code>%% Creator: Inkscape inkscape 0.92.1, www.inkscape.org
  %% PDF/EPS/PS + LaTeX output extension by Johan Engelen, 2010
  %% Accompanies image file 'RLE1.pdf' (pdf, eps, ps)
  %%
  %% To include the image in your LaTeX document, write
  %%   \input{&lt;filename&gt;.pdf_tex}
  %%  instead of
  %%   \includegraphics{&lt;filename&gt;.pdf}
  %% To scale the image, write
  %%   \def\svgwidth{&lt;desired width&gt;}
  %%   \input{&lt;filename&gt;.pdf_tex}
  %%  instead of
  %%   \includegraphics[width=&lt;desired width&gt;]{&lt;filename&gt;.pdf}
  %%
  %% Images with a different path to the parent latex file can
  %% be accessed with the `import' package (which may need to be
  %% installed) using
  %%   \usepackage{import}
  %% in the preamble, and then including the image with
  %%   \import{&lt;path to file&gt;}{&lt;filename&gt;.pdf_tex}
  %% Alternatively, one can specify
  %%   \graphicspath{{&lt;path to file&gt;/}}
  %% 
  %% For more information, please see info/svg-inkscape on CTAN:
  %%   http://tug.ctan.org/tex-archive/info/svg-inkscape
  %%
  \begingroup%
    \makeatletter%
    \providecommand\color[2][]{%
      \errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}%
      \renewcommand\color[2][]{}%
    }%
    \providecommand\transparent[1]{%
      \errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}%
      \renewcommand\transparent[1]{}%
    }%
    \providecommand\rotatebox[2]{#2}%
    \ifx\svgwidth\undefined%
      \setlength{\unitlength}{608.85768187bp}%
      \ifx\svgscale\undefined%
        \relax%
      \else%
        \setlength{\unitlength}{\unitlength * \real{\svgscale}}%
      \fi%
    \else%
      \setlength{\unitlength}{\svgwidth}%
    \fi%
    \global\let\svgwidth\undefined%
    \global\let\svgscale\undefined%
    \makeatother%
    \begin{picture}(1,0.13941476)%
      \put(0.12815803,0.12595718){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{352}}}%
      \put(0.18117534,0.12595718){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{320}}}%
      \put(0.23419265,0.12595718){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{288}}}%
      \put(0.28720997,0.12595718){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{256}}}%
      \put(0.34027656,0.12595718){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{224}}}%
      \put(0.39329387,0.12595718){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{192}}}%
      \put(0.44631119,0.12595718){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{160}}}%
      \put(0.4993285,0.12595718){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{128}}}%
      \put(0.56160906,0.12595718){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{96}}}%
      \put(0.61462638,0.12595718){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{64}}}%
      \put(0.66767654,0.12595718){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{32}}}%
      \put(0.7299571,0.12595718){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0}}}%
      \put(0.12007732,0.10191216){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x1}}}%
      \put(0.17309463,0.10191216){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x1}}}%
      \put(0.22611195,0.10191216){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x3}}}%
      \put(0.27912926,0.10191216){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x2}}}%
      \put(0.33214658,0.10191216){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x2}}}%
      \put(0.38521317,0.10191216){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x1}}}%
      \put(0.43823048,0.10191216){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x1}}}%
      \put(0.49124779,0.10191216){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x1}}}%
      \put(0.54426511,0.10191216){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x1}}}%
      \put(0.59728242,0.10191216){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x1}}}%
      \put(0.65033259,0.10191216){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x1}}}%
      \put(0.7033499,0.10191216){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x1}}}%
      \put(0.39329387,0.03056543){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{192}}}%
      \put(0.44631119,0.03056543){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{160}}}%
      \put(0.4993285,0.03056543){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{128}}}%
      \put(0.56160906,0.03056543){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{96}}}%
      \put(0.61462638,0.03056543){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{64}}}%
      \put(0.66767654,0.03056543){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{32}}}%
      \put(0.7299571,0.03056543){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0}}}%
      \put(0.33214658,0.00652041){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{\textit{0}\textit{x}\textit{2}}}}%
      \put(0.38521317,0.00652041){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x1}}}%
      \put(0.43823048,0.00652041){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{\textit{0}\textit{x}\textit{1}}}}%
      \put(0.49124779,0.00652041){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x3}}}%
      \put(0.54426511,0.00652041){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{\textit{0}\textit{x}\textit{2}}}}%
      \put(0.59728242,0.00652041){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x2}}}%
      \put(0.65033259,0.00652041){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{\textit{0}\textit{x}\textit{7}}}}%
      \put(0.7033499,0.00652041){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{0x1}}}%
      \put(0.04755463,0.10270052){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{…}}}%
      \put(0.15358269,0.00730877){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{…}}}%
      \put(0.82929066,0.10210925){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{unkomprimierte Daten}}}%
      \put(0.90260828,0.05441337){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{RleCompress}}}%
      \put(0.84821134,0.0067175){\color[rgb]{0,0,0}\makebox(0,0)[lb]{\smash{komprimierte Daten}}}%
      \put(0,0){\includegraphics[width=\unitlength,page=44]{img/a.pdf}}%
    \end{picture}%
  \endgroup%
  </code></pre>
  
  <p>I used this file within LaTeX like the following:</p>
  
  <pre><code>\begin{figure}
      \centering
      \def\svgwidth{\textwidth}
      \input{a.pdf_tex}    
  \end{figure}
  </code></pre>
  
  <p>The resulting .pdf file from my LaTeX file looks like that:
  <a href="https://i.stack.imgur.com/rFdWr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rFdWr.png" alt="result.pdf"></a></p>
  
  <p>As one can see, the italic font style is everything, inkscape exported. 
  The font color is not exported at all.</p>
  
  <p>The LaTeX font size of the index values should be <code>\tiny</code>.
  Of course I can change the font style manually, but this does not seem like a proper way to me.</p>
  
  <p>Also, the boxes around the index values behave like the following, when I try to resize them using <code>\tiny</code>:
  <a href="https://i.stack.imgur.com/nb4CE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nb4CE.png" alt="Strange box alignment"></a></p>
  
  <p>Does anyone knows, how to proper import svg files, containing text into a LaTeX document while preserving all the font styles and colors and of course the positioning?</p>
  
  <p>Sincerely</p>