Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I tried to plot tangent lines to the graph of a function using tkz-fct. See the example below. However I get the following error message:

ERROR: Use of \tkz@DrawTangentLine doesn't match its definition.

--- TeX said ---
\pgfutil@ifnextchar ...1\def \pgfutil@reserved@a {
                                              #2}\def \pgfutil@reserved@...
 l.17       \tkzDrawTangentLine[draw](4)

Any idea what's wrong with my code?

The example:

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-fct}
\usetkzobj{all}


    \begin{document}

       \begin{tikzpicture}[xscale=1]
          \tikzset{tan style/.style={-}}
          \tkzInit[xmin=0,xmax=10,xstep=1,
          ymin=0,ymax=5,ystep=1]
          \tkzGrid[color=brown,sub,subxstep=50,subystep=200]
          \tkzAxeXY
          \tkzFct[color=red,samples=100,domain = 0:10]{sqrt(1/2.*\x) + sin(1/2.*\x)}
          \tkzDrawTangentLine[draw](4)
       \end{tikzpicture}
    \end{document}
share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

First you don't need usetkzobj. This is for tkz-euclide. Now the problem comes from `sqrt``, a possibility is

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-fct}

\begin{document}

\begin{tikzpicture}[xscale=1]
\tikzset{tan style/.style={-}}
\tkzInit[xmin=0,xmax=10,xstep=1,
        ymin=0,ymax=5,ystep=1]
\tkzGrid[color=brown,sub,subxstep=50,subystep=200]
\tkzAxeXY
\tkzFct[color=red,samples=100,domain = 0:10]{(1./2*\x)**(0.5) + sin(1./2*\x)}
\tkzDrawTangentLine[draw](4)
\end{tikzpicture}
\end{document} 

enter image description here

Explanation : The code is very tricky : first the syntax is the gnuplot's syntax to draw the graph but then to draw some points and the tangent line, I use FP. So I created a macro to translate the gnuplot expression with the syntax of FP. When I wrote tkz-fct, I did not know how to use gnuplot to calculate a single value, now I know how to make this ... but with Lua, perhaps it's preferable to wait some time and to write new macros with luatex. In the case of sqrt, I think I need to modify something because this is a bug !

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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