Hello all.

It seems that \usetikzlibrary is sometimes read, sometimes not, and I don't 
understand why. 

Rationale:

I would like, using one file, to use it to produce a picture, as with LaTeX's 
Standalone class,
but to be able to include it in a calling document as well, for better 
management of fonts, etc.
Thus this is most convenient. I have everything in the main document and I can 
quickly reuse any figure elsewhere.


What I did:

I use \readfile in a main ConTeXt file document.tex to include the file 
included.tex .
The file included.tex should contain *just* the TikZ picture and what is needed 
to compile it "standalone".


The issue:

It seems I can call the file with the TikZ picture description multiple times, 
with \readfile,
from within the very same \placefigure.

However, if I call it by using two successive \placefigure commands,
the \usetikzlibrary[blabla] in the included file doesn't seem to be recognised.
E.g. with the provided example below, the key "right angle" is not understood, 
as if \usetikzlibrary[angles] was not there.

One workaround would be to use 
\usetikzlibrary[allTheLibrariesISupposeMightEverBeNeeded]
in the calling file. But I don't like it. I would rather have only the TikZ 
libraries relevant to some picture included in the corresponding file.

I'm quite startled by the fact that :
  >  \placefigure[here][]{This is a figure}{
  >    \readfile{included}{}{File not found.}
  >    \readfile{included}{}{File not found.}
  >  }
compiles but
  >  \placefigure[here][]{This is a figure}{
  >    \readfile{included}{}{File not found.}
  >  }
  >  \placefigure[here][]{This is a figure}{
  >    \readfile{included}{}{File not found.}
  >  }
does not.


All the best!


Example:

%%%% Begin document.tex

\usemodule[tikz]

\starttext

\usetikzlibrary[angles] % Doesn't compile if this is commented out.

%\placefigure[here][]{This is a figure}{
%  \readfile{included}{}{File not found.}
%  \readfile{included}{}{File not found.}
%}

\placefigure[here][]{This is a figure}{
  \ReadFile{included}{}
}
\placefigure[here][]{This is a figure}{
  \ReadFile{included}{}
}

\stoptext
%%%% End document.tex

%%%% Begin included.tex
\usemodule[tikz]
\usetikzlibrary[angles]
%\doifnotmode{*text,*bodypart}{ \startTEXpage[fit] }
\doifnotmode{*text,*bodypart}{ \startTEXpage[fit] \usemodule[tikz] 
\usetikzlibrary[angles] }
\hbox{\starttikzpicture[]
  \draw[]
       (0,0) coordinate (A) node[left] {$A$}
    -- (4,0) coordinate (B) node[right] {$B$}
    -- (0,3) coordinate (C) node[left] {$C$}
    -- cycle
    pic [draw, angle radius=0.5cm] {right angle = B--A--C} ;
\stoptikzpicture}
\doifnotmode{*text,*bodypart}{ \stopTEXpage }
%%%% End included.tex

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to