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.

Preview on Mac OS X 10.8.4

In Adobe Reader and Evince, I see the intended result:

Adobe Reader

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).



% defining the new dimensions and parameters
% declaring the keys in tikz
         hatchshift/.code={\setlength{\hatchshift}{#1}},% must be >= 0
% setting the default values
         hatchshift=0pt,% must be >= 0
% declaring the pattern
\pgfdeclarepatternformonly[\hatchspread,\hatchthickness,\hatchshift,\hatchcolor]% variables
   {custom north west lines}% name
   {\pgfqpoint{\dimexpr-2\hatchthickness}{\dimexpr-2\hatchthickness}}% lower left corner
   {\pgfqpoint{\dimexpr\hatchspread+2\hatchthickness}{\dimexpr\hatchspread+2\hatchthickness}}% upper right corner
   {\pgfqpoint{\dimexpr\hatchspread}{\dimexpr\hatchspread}}% tile size
   {% shape description
    \ifdim \hatchshift > 0pt
%    \pgfsetdash{{1pt}{1pt}}{0pt}% dashing cannot work correctly in all situation this way


\draw[pattern=custom north west lines] (0,0) rectangle (3,4);
\draw[pattern=custom north west lines,hatchspread=6pt,hatchthickness=1pt,hatchcolor=red] (0,0) rectangle (3,4);
\draw[pattern=custom north west lines,hatchspread=10pt,hatchthickness=5pt] (0,0) rectangle (3,4);
\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);


closed as off-topic by percusse, Red, Benedikt Bauer, Claudio Fiandrino, jub0bs Oct 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
  • 4
    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
  • 4
    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

Browse other questions tagged or ask your own question.