1

I use TikZ to create drawings. They are composed of text, arrows, and svg-icons (e.g. coming from the Noun Project). These icons (svg files) are mono-color only (i.e. black & transparent).
What I'm used to do is to download them, change their color using Inkscape (i.e. black -> blue), and then import them as a node:

\node (my-picture) at (13,17) {\includegraphics[width=210pt]{myPicture.svg}};

However, if I want to change one color (e.g. let the main color of my document be green, and not blue anymore), I need to manually edit each .svg file.

Question: Would it be possible to include the raw .svg-file and specify its color as a TikZ option? E.g. \node [svgcolor=orange] (my-picture) at (13,17) {\includegraphics[width=210pt]{myPicture.svg}};

ebosi
  • 11,692
  • 3
    I don't believe so but lets wait experts. – Sigur Jan 27 '17 at 16:48
  • My main expectation is to be able to set the color of the imported icon using one color previously defined in my .tex document . I'm open to various solutions - e.g. generating a TikZ path from the svg (I know I could further search in this direction, but it seems to be a "too dirty" solution), etc. – ebosi Jan 27 '17 at 16:58
  • Another dirty solution: write a script to edit the svg file and load the edited copy. Small, simple, well structured files shoudl be amenable to this. – Chris H Jan 27 '17 at 17:00
  • Could do it use lualatex, but that would take some elbow grease. – JPi Jan 27 '17 at 17:01
  • @ChrisH Interesting. However, I'd like it to be automatically updated when I change the \definecolor{myMainColor}{}{} definition... / @JPi : what's your idea? (where could I search further on the topic?) - If possible, I'd like a pdflatex-compliant solution, but xelatex/lualatex ones would be also ok – ebosi Jan 27 '17 at 17:04
  • In the list of other options, there is also the "save as tex file" from Inkscape, see http://ctan.math.utah.edu/ctan/tex-archive/info/svg-inkscape/InkscapePDFLaTeX.pdf (edit: extraneous brackets removed). (Bonus points: you get the same fonts as your document.) You would still need to write your own script, but on the (very long) run it would be easier to edit the text files once to make them "call" an external color (as opposed to changing all image files each time you change color). – user114516 Jan 27 '17 at 17:05
  • @JM114516 I know this option, but I think it only makes your text be written by TikZ (i.e. picture is imported as-is), doesn't it? – ebosi Jan 27 '17 at 17:08
  • 1
    @ebo Yes, but: Inkscape generates the image part as a multi-page pdf, and tikz will \put it page by page in the final composition. If you find a way to choose the page that interests you, you can change its color via the tricks shown http://tex.stackexchange.com/questions/29227/can-includegraphics-be-used-to-change-an-image-color#29252 (second answer) / http://tex.stackexchange.com/questions/65071/change-color-in-finished-pdf-file/65083#65083 . Not a simple solution by any means, but it's possible. – user114516 Jan 27 '17 at 17:16
  • @JM114516 Thank you for the link, they are really interresting. I indeed succeed in changing the color by: 1/ convert svg into pdf; 2/ uncompress the pdf; 3/ comment color changes data in the pdf sourcecode; 4/ use \color{myMainColor} before \includegraphics[...]{myFile.pdf}. I however need to secure step 3 (I've used the 'try'n'fail' approach here!) – ebosi Jan 27 '17 at 17:35
  • Why don't you export tikz code from Inkscape? Then you can edit the files once to include a custom colour name which you specify in your main document. The code exported is not very easy to edit for most purposes, but it should be pretty easy for something like this. – cfr Jan 28 '17 at 01:21
  • tikzfadingfrompicture – Symbol 1 Jan 28 '17 at 17:00
  • @PaulGaborit Thanks for the link: I actually solved my issue following a similar process as Heiko's answer. But I'll however study yours further. After all, I think my question is a duplicate of the one you refereed to - so thank you! – ebosi Feb 03 '17 at 08:27

0 Answers0