Perhaps the question is unclear. I know how to put a tikzpicture inside a box. I made it in this question like this


But in this case I put a box (\pgfpicperhaps it's the final box) into a box and I would like to know if it's possible to save the final box when \endtikzpicture arrives.

I'm not sure but I think the good box is \pgfpic. In the file pgfcorescopes.code.tex and at the end of the macro \endpgfpicture, I found \pgfsys@endpicture and then \pgfsys@typesetpicturebox\pgfpic. Th first seems to depend of the driver and I don't understand the code and for the second macro \pgfsys@typesetpicturebox the definition is inside the file pgfsys.code.tex

Here the code of this macro :

  \advance\pgf@ya by-\pgf@picminy\relax%
  \advance\pgf@picmaxy by-\pgf@picminy\relax% maxy is now the height
  \advance\pgf@picmaxx by-\pgf@picminx\relax% maxx is now the width
  \pgf@xa=\pgf@trimleft@final\relax  \ifdim\pgf@xa=0pt \else\kern\pgf@xa\fi
  \pgf@xa=\pgf@trimright@final\relax \ifdim\pgf@xa=0pt \else\kern\pgf@xa\fi

But I don't understand the comment about this macro :

% Called after a picture has been typeset in box #1. This
% command should insert the box into the normal TeX code. The box #1
% will still be a ``raw'' box that contains only the \special's. The
% job of this command is to resize and shift this box according to the
% baseline shift and the size of the box.
% This command has a default implementation.

Well I'm lost in all these codes and I'm not sure if what I want is possible. Perhaps it's a bad idea.

  • 2
    The code of the spy library has a box \copy application which may be inspiring for you.
    – percusse
    May 12 '12 at 17:36
  • Interesting and fine idea ! I need to give a look at this code but at first glance, the code is short but ... without comments. May 12 '12 at 18:06
  • Yes, it's a little bit difficult to make your way around it but the general idea is to use the box content in the path picture option. If you look at the manual for path picture it's a little bit easier to understand the motivation.
    – percusse
    May 12 '12 at 18:13

If I say

  \draw (0,0) -- (1,1) ;

then the log from \showbox\mycandle (with high values of \showboxbreadth and \showboxdepth) is

> \box36=
.\pdfcolorstack 0 push {0 g 0 G}
..\glue 0.2
..\hbox(0.0+0.0)x0.0, shifted -0.2
...\pdfliteral{q }
...\pdfliteral{0 G }
...\pdfliteral{0 g }
...\pdfliteral{0.3985 w }
....\glue 0.0
....\glue 0.0
....\glue 0.0
....\glue 0.0
....\glue 0.0
....\glue 0.0
....\glue 0.0
....\glue 0.0
....\glue 0.0
....\glue 0.0
....\glue 0.0
....\glue 0.0
....\pdfliteral{q }
....\glue 0.0
....\glue 0.0
....\pdfliteral{0.0 0.0 m }
....\pdfliteral{2.83484 2.83484 l }
....\pdfliteral{S }
....\pdfliteral{Q }
....\glue 0.0 plus 1.0fil minus 1.0fil
...\pdfliteral{n }
...\pdfliteral{Q }
...\glue 0.0 plus 1.0fil minus 1.0fil
.\pdfcolorstack 0 pop

So you've not the final box, which is surrounded by suitable \pdfcolorstack instruction (in pdflatex). They become \special{color push gray 0} and \special{color pop} with latex or xelatex. I don't think it's really safe trying to get the inner box before those paired commands are issued.

  • Finally "The box #1 will still be a ``raw'' box that contains only the \special's." is the problem ? I think you are right when you say "it's not really safe trying ...". So it was a bad idea! May 12 '12 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.