# Incompatibility with TikZ and Mac OS X Preview [closed]

I was quite suprised to find that some TikZ documents render incorrectly under Preview (on Mac OS X), despite working fine in Adobe Reader (on Mac OS X) and Evince (on Linux). This is Mac OS X version 10.8.4.

The easiest way to reproduce this is with the custom pattern designs from this answer (see the custom north west lines example in the second code block). I will also reproduce the code below in case that answer is ever edited.

When I view the document in Preview on Mac OS X, this is what I see. Note in the third panel that the thick black lines do not go all the way to the edge of the box.

My question is: is this a result of TikZ using some non-standard (or less well supported) feature of PDFs? Or is this a bug in Preview? (Note: even if this is a bug in Preview, if there is a workaround that is available on the TikZ side, that's probably much easier than trying to get Apple to fix it.)

I tried this in MacTeX (aka TeX Live) 2012 and 2013, and also TeX Live 2013 in Linux. I'm not sure exactly what version of TikZ is installed with those (I have done no customization of my installations).

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{patterns}

% defining the new dimensions and parameters
\newlength{\hatchthickness}
\newlength{\hatchshift}
\newcommand{\hatchcolor}{}
% declaring the keys in tikz
hatchthickness/.code={\setlength{\hatchthickness}{#1}},
hatchshift/.code={\setlength{\hatchshift}{#1}},% must be >= 0
hatchcolor/.code={\renewcommand{\hatchcolor}{#1}}}
% setting the default values
hatchthickness=0.4pt,
hatchshift=0pt,% must be >= 0
hatchcolor=black}
% declaring the pattern
{custom north west lines}% name
{\pgfqpoint{\dimexpr-2\hatchthickness}{\dimexpr-2\hatchthickness}}% lower left corner
{% shape description
\pgfsetlinewidth{\hatchthickness}
\ifdim \hatchshift > 0pt
\pgfpathmoveto{\pgfqpoint{0pt}{\hatchshift}}
\pgfpathlineto{\pgfqpoint{\dimexpr0.15pt+\hatchshift}{-0.15pt}}
\fi
\pgfsetstrokecolor{\hatchcolor}
%    \pgfsetdash{{1pt}{1pt}}{0pt}% dashing cannot work correctly in all situation this way
\pgfusepath{stroke}
}

\begin{document}

\begin{center}
%
\begin{tikzpicture}
\draw[pattern=custom north west lines] (0,0) rectangle (3,4);
\end{tikzpicture}%
%
\begin{tikzpicture}
\draw[pattern=custom north west lines,hatchspread=6pt,hatchthickness=1pt,hatchcolor=red] (0,0) rectangle (3,4);
\end{tikzpicture}%
%
\begin{tikzpicture}
\draw[pattern=custom north west lines,hatchspread=10pt,hatchthickness=5pt] (0,0) rectangle (3,4);
\end{tikzpicture}%
%
\begin{tikzpicture}% hatchshift must be >= 0
\draw[pattern=custom north west lines,hatchspread=10pt,hatchcolor=red] (0,0) rectangle (3,4);
\draw[pattern=custom north west lines,hatchspread=10pt,hatchcolor=blue,hatchshift=2.5pt] (0,0) rectangle (3,4);
\draw[pattern=custom north west lines,hatchspread=10pt,hatchcolor=green!65!black,hatchshift=5pt] (0,0) rectangle (3,4);
\draw[pattern=custom north west lines,hatchspread=10pt,hatchcolor=violet,hatchshift=7.5pt] (0,0) rectangle (3,4);
\end{tikzpicture}%
%
\end{center}

\end{document}

-

## closed as off-topic by percusse, Red, Benedikt Bauer, Claudio Fiandrino, JubobsOct 30 '13 at 9:22

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

The same issue happens with the built-in PDF previewer of TeXShop, from the MacTeX distribution. Interestingly, though, the issue does not arise with the PDF previewer in TeXworks that also comes with MacTeX. At least, that's what happens on my machine, as of version 3.23 of TeXShop and version 0.4.5 r.1280 of TeXworks. –  Adam Liter Aug 6 '13 at 6:30
I've seen similar problems with OSX in some mailing lists but can't locate them. It's not related to TikZ but viewer if I remember correctly. –  percusse Aug 6 '13 at 7:48
It's not really surprising that you see the same issue in TeXShop since it relies on OSX's PDF routines. TeXWorks on the other hand uses poppler AFAIK. –  Simifilm Aug 6 '13 at 7:57
This question appears to be off-topic because it is about a particular PDF viewer and its functionality that cannot be solved in the scope of TeX programming. –  percusse Oct 30 '13 at 8:51