3

Consider an image created by the following fig.tex:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}
    \draw[thick,solid,->] (0,0) -- (1,0);
    \draw[thick,solid,->] (0,0) -- (0,1);
    \draw[thick,solid,->] (0,0) -- (-1,-1);
  \end{tikzpicture}
\end{document}

Let's compile it with latex -> dvips -> ps2pdf to create fig_latex.pdf and with pdflatex to create fig_pdflatex.pdf.

Then include these figures in the following:

\documentclass{standalone}
\usepackage{graphicx}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}
    \draw (0,0) node[draw] {regular: \includegraphics{fig_latex.pdf}};
    \draw (0,-3) node[draw, dashed] {dashed latex: \includegraphics{fig_latex.pdf}};
    \draw (0,-6) node[draw, dashed] {dashed pdflatex: \includegraphics{fig_pdflatex.pdf}};
  \end{tikzpicture}
\end{document}

All we're doing is defining TikZ nodes and including the images inside. Now the problem is that for the image compiled with latex the enclosing dashed specification gets transferred to the image itself, something that doesn't happen with the image compiled with pdflatex:

example image: dashed node around tikz image compiled with latex causes the contents to be dashed as well

Is there a way to protect the contents of the image on the enclosing level, without having to, say, recompile the existing image file using pdflatex?

1 Answers1

2

Well you can reset the dash pattern with \pdfliteral{ [] o d}. But I'm not sure if this is worth it. There can be other graphic parameters which can be wrong. See also Tikz changes included graphics

\documentclass{standalone}
\usepackage{graphicx}
\usepackage{tikz}
\begin{document}
  \begin{tikzpicture}
    \draw (0,-3) node[draw, dashed] {dashed latex: \includegraphics{fig-latex.pdf} };
    \draw (0,-6) node[draw, dashed] {dashed latex: \pdfliteral{ [] o d}\includegraphics{fig-latex.pdf} };
  \end{tikzpicture}
\end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • Thank you, I couldn't manage to find the linked post. I guess I'll follow your suggestion and recompile with pdflatex to make sure that no other property gets changed. – Andras Deak Nov 20 '18 at 19:03