# How to create a pdf from svg that can be colorized?

This post mentioned that when using PdfLaTeX, One can recolor the blacks of an image to any color using \color.

The Goal: Create an image (preferably scalable(svg)) that can be color adjusted inside LaTeX.

So I created a small black svg vector image in inkscape and saved it as a PDF (with the "PDF+LaTeX", "PDF 1.5" and "use exported object's size" settings), but when I include it with color it stays black...

\definecolor{accent}{RGB}{0, 130, 240} %blue
\color{accent} \includegraphics[height=9pt,clip]{location}


So how do I make a svg image color adjustable in LaTeX?

• Welcome to TeX - LaTeX! Are there colour settings in your image? – Andrew Swann Feb 17 '17 at 10:39
• How do I check that? – LinG Feb 17 '17 at 10:42
• You should be able to read this in the svg file - it is just an xml format. – Andrew Swann Feb 17 '17 at 11:13
• the only two properties that contain the word "color" in their name are pagecolor="#ffffff" and bordercolor="#666666". Besides, why does it matter if my svg file contains color settings? I'm exporting it as a PDF, so shouldn't the pdf not contain any color settings? Also I tried to export it as PNG as well but that didn't work either... – LinG Feb 17 '17 at 11:45
• The technique you are trying to use only works on figures without explicit colour settings. It is overriding a default colour. Colours are also specified in svg files by fill and stroke commands amongst other things. You should adjust the colours outside of latex. – Andrew Swann Feb 17 '17 at 12:29

I suggest an alternative approach to some of the comments:

Use commandline tools to edit the svg file, then import that using the svg package (which in turn converts to pdf using imagemagick).

You might for example (on linux or with cygwin on windows) use something like sed -i 's/fill:#000000/fill:#ff00000' test.svg to switch black to red. From within pdflatex you can use \immediate\write18

In full:

\documentclass{article}
\usepackage{graphicx}
\usepackage{svg}

\begin{document}
\includesvg{test}
\immediate\write18{sed 's/fill:#000000/fill:#ff0000/' test.svg >test1.svg}
\includesvg{test1}
\end{document}