6

I have several graphics which include dashed lines. In the PDF, everything looks exactly as it should. When I print, however, the dashed line disappears completely. What should I do to prevent this?

\begin{tikzpicture}
\node (a) at (0,1) [vertex] {};
\node (b) at (0.7,1.7) [vertex] {};
\node (c) at (1.7,1.7) [vertex] {};
\node (d) at (2.4,1) [vertex] {};
\node (e) at (1.7,0.3) [vertex] {};
\node (f) at (0.7,0.3) [vertex] {};
\draw (a) -- (b);
\draw (b) -- (c);
\draw (c) -- (d);
\draw (d) -- (e);
\draw (e) -- (f);
\draw [dashed] (f) -- (a);
\end{tikzpicture}
4
  • Welcome to TeX.SX! First thing to check: is your printer driver up-to-date? Feb 18, 2015 at 3:46
  • 4
    Do you have a setting in your document making the lines especially thin? Low-resolution printers have trouble with ultra thin.
    – Thérèse
    Feb 18, 2015 at 4:23
  • 2
    Please complete your example so that people can compile it.
    – cfr
    Feb 18, 2015 at 12:26
  • I do not have any printer settings in the document. I'll try a new printer this evening, but I would be quite surprised if the one I was using didn't have up to date drivers.
    – William
    Feb 18, 2015 at 22:35

4 Answers 4

8

My job involves emailing a lot of PDFs to people to print out, so the "update your printer driver" solution doesn't really help me.

But what I've founded is that while dotted or dashed lines refuse to print, dotted or dashed sine waves show up fine, even if the amplitude is zero. So I put the following at the top of my document:

\usetikzlibrary{snakes}
\tikzstyle{printersafe}=[snake=snake,segment amplitude=0 pt]

Then add [printersafe] as a style to every dotted line in the code, e.g.:

\draw [densely dotted,printersafe] (0,-6) -- (10,-6);

These lines show up fine, even when printed by TAs who experience the original issue.

3

So, I recently ran into this problem and found @Jonah's solution. Thing is, it doesn't really work with how tikz behaves now, so I made the following changes which should make this code more up-to-date:

\usetikzlibrary{decorations.pathmorphing}
\tikzstyle{printersafe}=[decoration={snake,amplitude=0pt}]

With this you can also use printersafe within tikz-cd environments. Hope this helps!

1
  • Once you have sufficient reputation this should be a comment to the post.
    – TeXnician
    May 16, 2017 at 4:25
1

Using a new printer fixed the issue, so apparently it WAS a driver issue as Paul suggested.

0

Another solution: drawing your own dashed lines

It seems that Tikz doesn't always do what we expect it to do. Especially in combination with things such as edge[transform canvas={xshift=4}] or custom functions like rounded arrows as can be found in this post. In those cases, the printer sometimes just doesn't print normal dashed lines. That's why we need to use a workaround.

The other answer with printersafe didn't work for me. Also, I want to send the pdf to other people so I can't update their printers. I needed a solution that would always work.

I found a workaround that imitates a dashed line using a foreach loop with normal lines:

\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{figure}[h!]
\begin{tikzpicture}[every path/.style={>=latex}]

% Normal dashed line
\draw[->,thick,black,dashed] (0,1) -- (4,1) node[anchor=west] {Normal dashed line};

% Specify dashed line starting coordinate and length
\def\x{0}; \def\y{0}; \def\length{4} \def\N{19}; 
% Draw dashed line using normal lines
\pgfmathsetmacro{\step}{(0.5+1/(4*\N))*\length/\N}; \pgfmathparse{\N-1};
\foreach \i in {0,...,\pgfmathresult} {\draw[thick,black] (\x+2*\i*\step,\y) -- (\x+2*\i*\step+\step,\y);}; 
\draw[->,thick,black] (\x+\length,\y) -- (\x+\length+0.01,\y) node[anchor=west] {Custom dashed line};

\end{tikzpicture}
\end{figure}
\end{document}

This simply mimicks a normal dashed line by drawing multiple lines after each other. Parameters are \x for the starting x-coordinate, \y for the y-level of the line, \length for the length in coordinates of the line and \N for the amount of stripes.

The example provided only draws horizontal lines from left to right, but the code can easily be adjusted to draw other dashed lines (such as vertical lines, right-to-left, etc.)

This solution will still allow you to print dashed lines if your printer does print the normal lines but the dashed lines do not show up (for some reason).

Output on pdf:

pdf arrows

2
  • If it cannot print the minimum PostScript object which is a dashed line than I wouldn't claim that it would print these. You can't know in advance what they have.
    – percusse
    Aug 26, 2016 at 13:56
  • @percusse Sure, I've changed that sentence. Anyway, I've tested this elaborately and it always works for very complex tikz pictures which normally wouldn't have the printed dashed lines.
    – Jean-Paul
    Aug 26, 2016 at 14:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .