3

Consider the following LaTeX manuscript featuring a TikZ picture* containing an empty, red-bordered node placed at the picture's origin.

\documentclass{article}
\usepackage{tikz}
\begin{document}
    \tikz \path[draw=red] (0,0) node[draw] {};
\end{document}

When this manuscript is compiled with pdflatex the result is a pdf file with the following picture of a red square, as expected:

The output of pgflatex

However, when the same manuscript is compiled with latex the result is a dvi file with the following picture of a black square:

The output of latex

When the node is replaced by a line segment:

\tikz path[draw=red] (0,0) -- (1,0);

both pdf and dvi look the same, showing a red line segment, as expected:

A red line segment

Why does latex draw a black square?


* This picture was the subject of this post, which may or may not be related to the present question; I suspect that it is, but I don't know for sure, hence the separate question.

Evan Aad
  • 11,066
  • 1
    try \documentclass{article} \usepackage{tikz} \begin{document} \tikz \path (0,0) node[draw=red] {}; \end{document} (this is more correct code) and see if now appear difference between latex and pdftex – Zarko Aug 06 '17 at 07:44
  • @Zarko: Thanks, but this was not my question. – Evan Aad Aug 06 '17 at 07:45
  • 2
    i just like to point, that the way you write the code is not correct, so appearing colors are accidentally such as you see them (they aren't well defined) ... but let us wait to some latex/tikz guru, what (s)he will say. – Zarko Aug 06 '17 at 07:50
  • 5
    TikZ and DVI doesn't always play well together, see e.g. https://tex.stackexchange.com/questions/84182/ and https://tex.stackexchange.com/questions/5826/. Not sure if this same thing is the cause of the problems here though, I don't know much about the very low level stuff. – Torbjørn T. Aug 06 '17 at 08:07
  • How do you view the dvi? – Ulrike Fischer Aug 06 '17 at 09:07
  • 1
    @TorbjørnT.: Thanks. This was a good lead. However, I think that the etiologies of the two problems are different, since the solution to that question doesn't work here. The solution to that question was simply to convert the dvi file to ps or pdf using dvips or dvipdf. However, if I do so with my dvi file, the resulting ps/pdf picture is still a black square. – Evan Aad Aug 06 '17 at 09:09
  • @UlrikeFischer: By double-clicking the file in Finder on a macOS Sierra 10.12.6. It opens in TeXShop 3.84. – Evan Aad Aug 06 '17 at 09:11
  • 4
    @Zarko I don't agree. The syntax \path[draw=red] is allowed and should have a well-defined effect on nodes on the path. To me it looks like a bug in one of the driver. – Ulrike Fischer Aug 06 '17 at 13:10
  • 4
    I'm voting to close this question as off-topic because it's a bug in the PGF backend driver for dvi. – Paul Gaborit Aug 06 '17 at 13:17
  • 1
    @PaulGaborit: If it is a bug, why does it make my question off topic? Would you vote to close this question too? – Evan Aad Aug 06 '17 at 13:24
  • 1
    @PaulGaborit I've reopened: questions which are due to bugs are normally OK if the bug is 'open' and if the question isn't phrased as an out-and-out bug report. – Joseph Wright Aug 06 '17 at 15:47
  • I'm with @UlrikeFischer here: looks like a timing issue bug with colour specials. Not sure who should post an answer .... – Joseph Wright Aug 06 '17 at 15:48
  • 1
    @JosephWright If Evan Aad asked for a workaround, we could answer the question. But, here, the only answer is: it's a bug. – Paul Gaborit Aug 06 '17 at 16:41
  • @PaulGaborit https://tex.meta.stackexchange.com/questions/6988/questions-which-are-bug-reports-revisited – Joseph Wright Aug 06 '17 at 16:47
  • 1
    @JosephWright Ok. I copy the official answer... ;-) – Paul Gaborit Aug 06 '17 at 16:52

2 Answers2

3

This is basically a bug in the default PGF backend driver for DVI (pgfsys-dvips), and as such, it should be reported using https://sourceforge.net/p/pgf/bugs/.

Paul Gaborit
  • 70,770
  • 10
  • 176
  • 283
  • Note that TeXShop (which the OP was using) converts the dvi to pdf, so (as the manual states (section 10.2.1), the pgf driver should be explicitly to pgfsys-dvipdfm.def. This actually doesn't help for TeXShop, but remedies the situation for skim (a Mac specific viewer) when viewing the dvi (it also converts it). So I am not sure if this is a bug in PGF or merely a viewer issue. – Mark Wibrow Aug 07 '17 at 08:29
  • @MarkWibrow All PDF backend drivers are correct. – Paul Gaborit Aug 07 '17 at 08:42
2

as latex/tikz gurus find out your problem is caused by bug, but as workaround until bug will be eliminated you can use my suggestion in the first comment:

\documentclass{article} 
\usepackage{tikz} 
\begin{document} 
\tikz \path (0,0) node[draw=red] {}; 
\end{document}

apparently my claim, that is my code more correct then yours, is wrong. thank to Ulrike Fischer for pointing me to my mistake.

Zarko
  • 296,517