4

TEXstudio is the only MAC software (although not originally designed for MAC) that has a PDF viewer that renders perfectly well dashed and hatched lines drawn with tikz. What does TEXstudio do that all the other softwares (TEXshop, TEXnicle, Preview, Acrobat Reader) don't do ? Does TEXstudio bring with it the perfect PDF encoding ? Is tikz sending ambiguous PDF instructions ?

    \documentclass[]{article}
    \usepackage{tikz}
    \usetikzlibrary{patterns}
    \usepackage[most]{tcolorbox}

    % code taken from Arberto Sartori:  http://www.albertosartori.it/latexother.php
    \makeatletter
    \pgfdeclarepatternformonly[\LineSpace,\LineWidth]{my north east lines}
        {\pgfqpoint{-\LineWidth}{-\LineWidth}}{\pgfqpoint{\LineSpace}{\LineSpace}}
        {\pgfqpoint{\LineSpace}{\LineSpace}}%
        {
            \pgfsetcolor{\tikz@pattern@color}
            \pgfsetlinewidth{\LineWidth}
            \pgfpathmoveto{\pgfqpoint{-\LineWidth}{-\LineWidth}}
            \pgfpathlineto{\pgfqpoint{\LineSpace + 0.1pt}{\LineSpace + 0.1pt}}
            \pgfusepath{stroke}
        }
    \makeatother

    \newdimen\LineSpace
    \newdimen\PointSize
    \newdimen\LineWidth
    \tikzset{
        line space/.code={\LineSpace=#1},
        line space=3pt
    }
    \tikzset{
        point size/.code={\PointSize=#1},
        point size=.5pt
    }
    \tikzset{
        pattern line width/.code={\LineWidth=#1},
        pattern line width=.4pt
    }


    \tcbset{dash/.style={%
    enhanced,%
    frame style={pattern=my north east lines,pattern color=blue!80!white,
    line space=9pt,pattern line width=3pt,dashed},%
    leftrule=5mm,rightrule=5mm,toprule=5mm,bottomrule=0.3mm}} %

    \tcbset{hatch/.style={%
    enhanced,%
    frame style={pattern=my north east lines,pattern color=red!80!white,
    line space=9pt,pattern line width=3pt},%
    leftrule=5mm,rightrule=5mm,toprule=5mm,bottomrule=0.3mm}} %

    \begin{document}


    \begin{tcolorbox}[dash]
    North east DASHED lines
    \end{tcolorbox}


    \begin{tcolorbox}[hatch]
    North east HATCHED lines
    \end{tcolorbox}


    \end{document}

Perfect PDF result viewed (zoom-independent) in TEXStudio: enter image description here

TEXshop / failure dash + hatch: enter image description here3

TEXshop / zoom on / failure dash, but OK hatch: enter image description here

TEXnicle / failure dash + hatch: enter image description here

TEXnicle / zoom-on / failure dash + hatch: enter image description here

Preview (OS 10.10) / same result as TEXnicle / failure dash + hatch: enter image description here

Preview (OS 10.10) / zoom on / same result as TEXnicle / failure dash + hatch: enter image description here

Acrobat Reader 11.0.09/ failure dash, but hatch OK enter image description here

Acrobat Reader 11.0.09 / zoom on / failure dash, but hatch OK enter image description here

SDrolet
  • 4,908
  • 2
    Looks perfect with evince, I mean identical to TEXstudio. – Tarass Nov 17 '14 at 06:44
  • If you change the order hatchbefore dash all is red. Looks like in TeXStudio with TeXworks viewer. Doesn't work with SumatraPDF and PDFX-change viewer. – Ignasi Nov 17 '14 at 07:39
  • Acrobat should be fine from your screenshot. Play with the zoom level. – percusse Nov 17 '14 at 08:33
  • Sorry:"red" and "blue" were another issue, not the main one for that question / I updated my screen shots and question accordingly. – SDrolet Nov 17 '14 at 16:03
  • I blame the pattern code – percusse Nov 17 '14 at 21:19
  • Percusse, could you be more precise ? – SDrolet Nov 17 '14 at 21:20
  • I doubt it is the reason for the different renderings but \pgfqpoint{\LineSpace + 0.1pt}{\LineSpace + 0.1pt} is never going to work as \pgfqpoint does not do any calculations. – Mark Wibrow Nov 17 '14 at 21:23
  • Why the code ? Even if you use the built-in tikz pattern=north east lines, you get the same results with the different viewers for MAC. And, if the problem were the code, why would TEXstudio be the only one to guess it right ? – SDrolet Nov 17 '14 at 23:34
  • 1
    I don't have any problems with sumatra and Acroread with regular patterns. It has been always an issue with other viewers that is asked elsewhere on this site. I'll take a look – percusse Nov 18 '14 at 22:13

1 Answers1

2

The rendering is performed by the PDF rendering engine/library used by the program. For example:

  • TeXstudio uses poppler.
  • SumatraPDF uses MuPDF.
  • Adobe uses its own proprietary engine.
  • OSX has its own PDF engine (not an expert here but I assume Preview uses the builtin PDF capabilities of Quartz)

I don't know the details of the PDF specification here. Either it's ambigous or not all engines implement it strictly. Either way, the different engines interpret your example differently.

Tim Hoffmann
  • 11,159
  • Similar question: http://tex.stackexchange.com/questions/217879/tikz-pattern-north-west-lines-dashed – SDrolet Mar 28 '15 at 22:00