CCed to ConTeXt mailing list.

On Tue, 21 Jul 2009, Mojca Miklavec wrote to pgf.user list:

Hello,

I noticed that a large number of
   \begin{tikzpicture} \draw (0,0) -- (5,1); \end{tikzpicture}
breaks at line end while
   \starttikzpicture \draw (0,0) -- (5,1); \stoptikzpicture
just generates an infinitely long line.

Is there any simple way to fix the behaviour in ConTeXt?

Don't know.

I also don't like the behaviour in
   \placefigure{title}{\starttikzpicture ... \stoptikzpicture}
that has to be surrounded with
   \hbox{\starttikzpicture ... \stoptikzpicture}
else the figure gets placed at the beginning of line instead of being centered.

This is what is happening. The pgf code basically boils down to this.

\starttext
\newbox\pgfpic

\setbox\pgfpic\hbox to 10pt\bgroup abc \egroup

\placefigure
  {testing box placement}
  {\leavevmode\raise-2pt\box\pgfpic}

\stoptext

Now since \placefigure internally places its contents in a \vbox, this boils down to a differnce beween

\hbox to \textwidth {\hss \vbox{\hbox{abc}} \hss}

\hbox to \textwidth {\hss \vbox{\leavevmode\raise-2pt \hbox{abc}} \hss}

So, the solution is to either patch \placefigure so that

\def\setlocalfloatdimensions#1%
 {...
  \global\setbox\floatbox\hbox% was \vbox
 ....}

or redefine \pgf...@typesetpicturebox to

\def\pgf...@typesetpicturebox#1{%
  ....
  \hbox{\leavevmode\raise-\...@x\box#1}%\hbox added
}


The redefinition at ConTeXt will break some existing documents (i.e., the authors will have to manually add a \vbox where there was none earlier). The redefinition at tikz end will make all pgf code run slightly slower (an extra hbox for each typeset pgfpicture)

If neither of these is acceptable, then we can have a simple wrapper around \start-stop tikzpicture:

\def\startTIKZcode{\hbox\bgroup\starttikzpicture}
\def\stopTIKZcode {\stoptikzpicture\egroup}

which will only affect ConTeXt code.

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to