1

I have a decorative SVG-figure, and I want to change just one variable, to alter both text- and SVG-colour

Working in Sharelatex, using pdfLatex to compile

SVG to retain its scaling properties

MWE

main.tex

\documentclass{article}

\usepackage{that-theme-of-mine}
\usepackage{svg}
\usepackage{color}

\begin{document}

\begin{figure}
    \includesvg{rectangle}
\end{figure}

\end{document}

that-theme-of-mine.sty

\ProvidesPackage{that-theme-of-mine}

% Enables setting text colour
\usepackage{xcolor}

% Defining my specially chosen colour as #dcdccc
\definecolor{my-special-colour}{HTML}{dcdccc}

% Setting the text colour to be my special colour
\color{my-special-colour}

rectangle.svg

<svg>
<rect width="100" height="100" fill="#ff5566"/>
</svg>

Tried

Next

  • Inkscape through Sharelatex somehow? I get error messages mentioning Inkscape sometimes, but documentation on the two combined seems flimsy
  • Exploring decodearray?
  • TikZ?

Related questions:

- Can \includegraphics be used to change an image color?

  • 2
    The SVG package convert the SVG image to PDF (using Inkscape, I think) before to give it to LaTeX. So controlling the color in SVG is (almost) the same as controlling the color in external PDF. Probably it will be simpler to convert your SVG image to TikZ and then control the color. – Kpym Apr 12 '18 at 20:33
  • @Kpym Looks like it. Fiddled with svg2tikz, and the simplest way right now was to install Inkscape (Portable) on Windows, add the 3 files from svg2tikz to InkscapePortable/App/Inkscape/share/extensions - then open the SVG with Inkscape - Extensions - Export - Export to TikZ path… - select "Tikzpicture" and "Export to clipboard". \definecolor works with TikZ. – Jonta Apr 18 '18 at 19:40

Your Answer

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

Browse other questions tagged or ask your own question.