0

I have created a svg graphic with inkscape and use it in my LaTeX document. The graphic has a couple colorful lines with corresponding colorful arrowheads. Unfortunately pdflatex seems to arbitrarily assign the colors to the arrowheads. Exporting the svg to png in inkscape results in the correct arrowheadcolors, but then of course my math looks ugly. Has anyone experienced the same and knows of a way to get the correct arrowhead colors? There are already two different colors, so it's not like all arrowheads are treated the same.

Here is my minimal example

\documentclass{article}
\usepackage{svg}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\includesvg{arrowhead}
\caption{wrong colors of arrowheads in svg version}
\end{figure}
\begin{figure}
\includegraphics{pngarrowhead}
\caption{correct colors in png version}
\end{figure}
\end{document}

Here is the resulting pdf (screenshot thereof)

produced pdf

Here the png exported with inkscape (pngarrowhead.png)

pngarrowhead.png

And here is the original svg file. Sorry, but I cannot input it here directly, so I share it via a filehoster.

<svg width="98.852mm" height="46.58mm" version="1.1" viewBox="0 0 98.852 46.58" xmlns="http://www.w3.org/2000/svg">
 <defs>
  <marker id="Arrow1Mend" overflow="visible" orient="auto">
   <path transform="matrix(-.4 0 0 -.4 -4 0)" d="m0 0 5-5-17.5 5 17.5 5z" fill="context-stroke" fill-rule="evenodd" stroke="context-stroke" stroke-width="1pt"/>
  </marker>
  <marker id="Arrow1Mstart" overflow="visible" orient="auto">
   <path transform="matrix(.4 0 0 .4 4 0)" d="m0 0 5-5-17.5 5 17.5 5z" fill="context-stroke" fill-rule="evenodd" stroke="context-stroke" stroke-width="1pt"/>
  </marker>
 </defs>
 <g transform="translate(-35.241 -73.283)">
  <path d="m37.042 119.06 47.625-21.167" fill="#0f0" marker-start="url(#Arrow1Mstart)" stop-color="#000000" stroke="#008000" stroke-dasharray="8, 8" style="font-variation-settings:normal"/>
  <g>
   <path d="m84.667 95.25-47.625-21.167" fill="none" marker-end="url(#Arrow1Mend)" stroke="#f0f"/>
   <path d="m84.667 95.25 47.625-21.167" fill="none" marker-end="url(#Arrow1Mend)" stroke="#00f"/>
   <path d="m84.667 95.25 47.625 21.167" fill="#0f0" marker-end="url(#Arrow1Mend)" stroke="#0f0"/>
   <path d="m37.042 116.42 47.625-21.167" fill="#f00" marker-end="url(#Arrow1Mend)" stop-color="#000000" stroke="#f00" style="-inkscape-stroke:none;font-variation-settings:normal"/>
  </g>
  <text x="72.760414" y="82.020821" fill="#000000" font-family="sans-serif" font-size="10.583px" letter-spacing="0px" stroke-width=".26458" word-spacing="0px" style="line-height:1.25" xml:space="preserve"><tspan x="72.760414" y="82.020821" stroke-width=".26458">$x^2$</tspan></text>
 </g>
</svg>
6
  • 1
    something odd with the svg arrow heads, firefox doesn't show heads at all ... chrome shows them all black Apr 20 at 8:16
  • 1
    I added the svg to your question (not sure why you said you needed a file share, it is not very big?) Apr 20 at 8:22
  • Yes, I noticed the weird firefox and chrome behavior as well. Gnome image viewer shows it correctly though. And what puzzles me is that latex shows 2 different arrow head colors, instead of the requested 4. Ah, yeah, thanks for embedding the file. Just did not occur to me.
    – laolux
    Apr 20 at 8:26
  • Optimizing the svg before saving makes it even smaller, but does not change the result in latex. The plain svg output option does not help either.
    – laolux
    Apr 20 at 8:37
  • 1
    Well, the export to pdf is flawed, so probably an issue which should be reported to the Inkscape team
    – mrpiggi
    Apr 20 at 10:56

1 Answer 1

0

As mrpiggi correctly suggested, this is a known issue in inkscape. There is also a workaround listed, which is quite simple.

When selecting a marker for the path (like the arrow head in my example), be sure to always choose a fresh arrow marker from the drop down list, and not a previously used arrow marker which gets conveniently listed on top of the list. To fix broken documents, simply select fresh arrow marker for all arrows in the document.

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.