3

Here's my MWE:

\documentclass[11pt]{article}
\usepackage{pgf,tikz}

\begin{document}
\begin{figure}
   \begin{tikzpicture}
       % Bounding box coordinates
       \coordinate (q) at (1,  0);
       \coordinate (t) at (1,  8);
       \coordinate (r) at (12, 8);
       \coordinate (s) at (12, 0);

       % Draw the (invisible) bounding box
       \draw[opacity = 0] (q) -- (t) -- (r) -- (s) -- (q);
   \end{tikzpicture}
\end{figure}
\end{document}

The above MWE compiles using pdflatex to produce an empty page, but if I compile to .dvi using latex, then the resultant dvi file has the rectangle displayed! How can i fix this?

(I need an invisible bounding box in order to draw a 4-part figure, in some of which the box is visible, hence I don't really have an option to remove the box completely. Also, for reason not technical, I need the .dvi file to be rendered correctly as well!)

9
  • If I'm not wrong dvi does not work well with tikz. Why do you need a dvi file?
    – Sigur
    Jun 27, 2014 at 1:22
  • 1
    Why not use \path (q) -- (t) -- (r) -- (s) -- (q); or \draw[white] (q) -- (t) -- (r) -- (s) -- (q);?
    – Sigur
    Jun 27, 2014 at 1:23
  • Or you can use to clip \clip (q) -- (t) -- (r) -- (s) -- (q);
    – Sigur
    Jun 27, 2014 at 1:26
  • @Sigur: The MAJOR issue is, all PDF's show this supposedly invisible box when I print using Google Chrome, but the PDF does not show the figure when viewed on-screen! Since the box shows up on .dvi, I'm figuring that its a latex issue rather than a Chrome issue!
    – TCSGrad
    Jun 27, 2014 at 2:48
  • @Sigur: Your idea of using \draw[white] seems to be the easiest solution to my problem, but doesn't really answer the question why the lines are visible (in dvi or when printed with Google Chrome). Nevertheless, if u post it as an answer, I'm bound to accept it :)
    – TCSGrad
    Jun 27, 2014 at 2:50

1 Answer 1

2

As noted in the comments, DVI and TikZ do not always play nicely together. Here, the problem is opacity, because transparency is not supported by DVI. Several workarounds were posted in the comments.

However, your question as posed is an example of an XY problem. The proper way to specify an explicit bounding box without drawing it is to use the \useasboundingbox command or, equivalently, \path[use as bounding box].

Any one of the commented lines in the code (most of the path you specified is really unnecessary) will give the same bounding box as the last one I've left uncommented:

\documentclass{article}
\usepackage{tikz}

\begin{document}
x% just to illustrate width
\begin{tikzpicture}
  % Bounding box coordinates
  \coordinate (q) at (1,  0);
  \coordinate (t) at (1,  8);
  \coordinate (r) at (12, 8);
  \coordinate (s) at (12, 0);

  % Draw the (invisible) bounding box
%  \useasboundingbox (q) -- (t) -- (r) -- (s) -- (q);
%  \useasboundingbox (q) -- (t) -- (r) -- (s) -- cycle;
%  \useasboundingbox (q) -- (t) -- (r) -- (s);
%  \useasboundingbox (q) -- (t) -- (r) -- cycle;
%  \useasboundingbox (q) rectangle (r);
%  \useasboundingbox (q) -- (r);
  \path[use as bounding box] (q) -- (r);
\end{tikzpicture}%
x% just to illustrate width
\end{document}

You must log in to answer this question.

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