Is it possible to mark the intersection point of two tkz-fct functions and print it's coordinates?

For example in this case:




  • When you say "get", do you mean that you want the numeric coordinates, or do you just want to mark the intersection?
    – Jake
    Apr 30, 2012 at 21:20
  • Related: Coordinates of intersections
    – Jake
    Apr 30, 2012 at 21:24
  • @Jake I want both.
    – student
    Apr 30, 2012 at 21:29

2 Answers 2


No there is nothing specific in tkz-fct. You need to use TikZ to do that. With simple functions like in your example, you can use fp.

I think when you have complex functions , it's better to get the intersection with a real mathematics soft.

Actually tkz-fct works only with gnuplot and perhaps it's possible to use tables created by gnuplot to find an approximation of the intersection.

Now perhaps with lua, it's possible to find a fine method.


But I find a solution ! I modified my package but I don't know if there are bad effects:

I used id for 'name path' and I modified \def\tkz@fct


domain      = \tkz@dmin:\tkz@dmax,
samples     = 200,
fp          = true,
id          = tkzfct}
% stockage
\advance\tkz@tkzf@fct by  1 %
\expandafter\edef\csname tkzFctgnu\@alph\tkz@tkzf@fct \endcsname{#2}%
\expandafter\edef\csname tkzFctgnuLast\endcsname{#2}     
 \clip (\tkz@xa,\tkz@ya) rectangle (\tkz@xb,\tkz@yb);
 \draw[name path =\tkz@fct@id,xshift  = -\tkz@x@delta cm,yshift  = -\tkz@y@delta cm,/tkzfct/.cd,#1 ]%
 plot[id=\tkz@fct@id,domain= \tkz@ba:\tkz@bb,samples    = \tkz@fct@samples]%
  \expandafter\edef\csname tkzFct\@alph\tkz@tkzf@fct\endcsname{\tkz@tempb}%
  \expandafter\edef\csname tkzFctLast\endcsname{\tkz@tempb}%


 \fill [red, opacity=0.5, name intersections={of=f and g}]
    (intersection-1) circle (2pt) node {};

enter image description here


With some calculations you can get the coordinate system values like Jakes writes. I need to create a specific macro because sometimes the system is translate and the units can change with xstep and ystep.

Here a solution before a new macro

    \draw [name intersections={of=f and g, by=fxg}] let \p1=(fxg) in
   (fxg) circle (1pt) \pgfextra{\pgfmathsetmacro\xc{\x1/28.45}\pgfmathsetmacro\yc{\y1/28.45*\tkz@init@ystep}} node [right,align=left] {a=\xc\\ b=\yc};

enter image description here

  • Actually Jake's solution is the more useful with name plot/.style={every path/.style={name path global=#1}} because you can avoid to add a big piece of code. Another possibility is to modify directly the package but it's preferable to wait a new version. Apr 30, 2012 at 22:24
  • Looks great. It worked for me in some examples and in others not. But I didn't figure out yet where the problem is.
    – student
    May 1, 2012 at 20:03
  • And with Jake's idea, do you have the same problems ? every path/.style={name path global=A} May 1, 2012 at 20:19
  • Perhaps the problem is that I have too old tikz and tkz versions. When I have more time I will update them and try it again.
    – student
    May 1, 2012 at 20:26

It is possible if you use TikZ directly to plot and combine it with the intersections library.




   name plot/.style={every path/.style={name path global=#1}}

\tkzFct[name plot=A,color=red,domain=0:4]{2*x**2+5}
\tkzFct[name plot=B,color=blue,domain=0:4]{-x**3+15}
\draw [name intersections={of=A and B, by=AxB}] (AxB) circle (2pt);

With the following line you can read out the absolute coordinates of the intersection point as it is placed in the resulting picture. With some calculations you can get the coordinate system values I guess …

\draw [name intersections={of=A and B, by=AxB}] let \p1=(AxB) in
   (AxB) circle (1pt) node [right] {\x1,\y1};


File list

 *File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
 tkz-fct.sty    2011/06/01 1.16 c function 
tkz-base.sty    2011/06/01 1.16 c tkz-base
    etex.sty    1998/03/26 v2.0 eTeX basic definition package (PEB)
    tikz.sty    2010/10/13 v2.10 (rcs-revision 1.76)
     pgf.sty    2008/01/15 v2.10 (rcs-revision 1.12)
  pgfrcs.sty    2010/10/25 v2.10 (rcs-revision 1.24)
everyshi.sty    2001/05/15 v3.00 EveryShipout Package (MS)
 pgfcore.sty    2010/04/11 v2.10 (rcs-revision 1.7)
graphicx.sty    1999/02/16 v1.0f Enhanced LaTeX Graphics (DPC,SPQR)
  keyval.sty    1999/03/16 v1.13 key=value parser (DPC)
graphics.sty    2009/02/05 v1.0o Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    1999/03/16 v1.09 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/message (HO)
 ltxcmds.sty    2011/04/18 v1.20 LaTeX kernel commands for general use (HO)
  pgfsys.sty    2010/06/30 v2.10 (rcs-revision 1.37)
pgfsyssoftpath.code.tex    2008/07/18  (rcs-revision 1.7)
pgfsysprotocol.code.tex    2006/10/16  (rcs-revision 1.4)
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
pgfcomp-version-0-65.sty    2007/07/03 v2.10 (rcs-revision 1.7)
pgfcomp-version-1-18.sty    2007/07/23 v2.10 (rcs-revision 1.1)
  pgffor.sty    2010/03/23 v2.10 (rcs-revision 1.18)
numprint.sty    2008/02/17 v1.38 Print numbers (HH)
   array.sty    2008/09/09 v2.4c Tabular extension package (FMi)
      fp.sty    1995/04/02
defpattern.sty    1994/10/12
fp-basic.sty    1996/05/13
fp-addons.sty    1995/03/15
 fp-snap.sty    1995/04/05
  fp-exp.sty    1995/04/03
fp-trigo.sty    1995/04/14
  fp-pas.sty    1994/08/29
fp-random.sty    1995/02/23
  fp-eqn.sty    1995/04/03
  fp-upn.sty    1996/10/21
 fp-eval.sty    1995/04/03
pdftexcmds.sty    2011/04/22 v0.16 Utilities of pdfTeX for LuaTeX (HO)
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
epstopdf-base.sty    2010/02/09 v2.5 Base part for package epstopdf
  grfext.sty    2010/08/19 v1.1 Managing graphics extensions (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Defining keys (HO)
kvoptions.sty    2010/12/23 v3.10 Keyval support for LaTeX options (HO)
kvsetkeys.sty    2011/04/07 v1.13 Key value parser (HO)
etexcmds.sty    2011/02/16 v1.5 Prefix for e-TeX command names (HO)
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
  • @Altermundus, wouldn’t it be possible to apply name path to \tkzFct? I tried it but it doesn’t work – I guess the options of \tkzFct are send to plot and not to \draw or something like that …
    – Tobi
    Apr 30, 2012 at 21:30
  • 1
    You can use every path/.style={name path global=A} in the options of the \tkzFct.
    – Jake
    Apr 30, 2012 at 21:35
  • I made a change to tkf-fct to use name path directly Apr 30, 2012 at 22:06
  • @jake : fine solution ! because I forgot global with name path globaland it's why I remove a scope but perhaps I can remove it without problem. Apr 30, 2012 at 22:26
  • Thanks, but I get the error: Package tikz Error: I do not know the path named A'`
    – student
    May 1, 2012 at 19:52

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.