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 really was working on this now for a long time. I need a tangent line on a parabola; here is my working example:

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{arrows,calc,intersections,decorations.markings}
\usepackage{relsize}
\begin{document}
\begin{tikzpicture}[
        ]
        \draw[very thick, ->, >=stealth', line join=miter]   (6,0) node(xline)[right] {$x_i$} -|
                          (0,6) node(yline)[above] {$y_i$};
            \draw[blue,thick,name path = line 1]          (4,1) coordinate () parabola (0,3);
            \draw[blue,thick,name path = line 2]         (4,2) coordinate ( ) parabola (0,4);
            \draw[blue,thick,name path = line 3]         (4,3) coordinate ( ) parabola (0,5);
            \draw[dashed ,name path = line 4](1,0) coordinate () -- (1,5);
            \draw[dashed ,name path = line 5](3,0) coordinate () -- (3,5);
            \fill[red,name intersections={of=line 1 and line 4}]     (intersection-1) circle (2pt) node { };
    \end{tikzpicture}
\end{document}

Instead of the red dot I want a tangent line. Does anyone of you know how to do this?

enter image description here

\begin{tikzpicture}[
    tangent/.style={
        decoration={
            markings,% switch on markings
            mark=
                at position #1
                with
                {
                    \coordinate (tangent point-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (0pt,0pt);
                    \coordinate (tangent unit vector-\pgfkeysvalueof{/pgf/decoration/mark info/sequence number}) at (1,0pt);
                }
        },
        postaction=decorate
    },
    use tangent/.style={
        shift=(tangent point-#1),
        x=(tangent unit vector-#1),
    },
    use tangent/.default=1
]
    \draw[thick, <->, line join = miter->]   (6,0) node(xline)[right] {$x_i$} -|
                      (0,6) node(yline)[above] {$y_i$};
\draw[dashed ,name path = line1](1,0) coordinate () -- (1,5);
\draw [blue,tangent=0.3,name path = line2] (4,1)    parabola  (0,3);
\fill[red,name intersections={of=line1 and line2}]     (intersection-1) circle (2pt) node {};
\draw [orange, thick, use tangent] (-1,0) -- (1,0) ;
\end{tikzpicture}
share|improve this question
6  
have you seen these questions –  cmhughes Sep 28 '12 at 16:38
2  
Welcome to TeX.SE. Let us know if any of those questions provided you with a solution you could use. –  Peter Grill Sep 28 '12 at 18:43
    
Hi! Thanks Herbert for adding the pic! - and cmhughes I saw these examples and I wanted to use the intersection thing. I guess this tex.stackexchange.com/questions/25928/… best describes what I want but I was not able to modify the code as I want; how do you define the tangent to be on the intersection? Is there any way to say tangent = intersection? –  Gine Oct 1 '12 at 9:32
    
I have added the new piece of code above! (...how can I add a comment of more than 600 characters? :-) sorry...) –  Gine Oct 1 '12 at 9:39
1  
Have a Look at tex.stackexchange.com/questions/60392/… –  Uwe Ziegenhagen Oct 2 '12 at 1:25
show 1 more comment

1 Answer 1

enter image description here

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows, intersections}

\begin{document}

    \begin{tikzpicture}
        [ 
            extended line/.style={shorten >=-#1,shorten <=-3cm}
            , extended line/.default=1cm
        ]

        \clip (-2, -1) rectangle (7,8);

        \draw [very thick, <->, >=stealth', line join=miter]
            (6,0) node (xline)[right] {$x_i$} -|
            (0,7) node (yline) [above] {$y_i$}
        ;

        \draw [blue, ultra thick, name path = my parabola] (5,1) parabola (1,7);
        \draw [name path = my reference] (2,0) -- (2,5);

        \draw [dotted, name path = line 1] (4   , 0) -- (4   , 5);
        \draw [dotted, name path = line 2] (3   , 0) -- (3   , 5);
        \draw [dotted, name path = line 3] (2.01, 0) -- (2.01, 5);


        \fill [name intersections = {of = my parabola and my reference, name = my dot}];

        \fill [name intersections = {of = my parabola and line 1, name = i1}];
        \fill [name intersections = {of = my parabola and line 2, name = i2}];
        \fill [name intersections = {of = my parabola and line 3, name = i3}];

        \fill [red]    (i1-1) circle (1.1pt);
        \fill [orange] (i2-1) circle (1.1pt);
        \fill [black]  (i3-1) circle (1.1pt);

        \draw [red   , extended line             ] (my dot-1) -- (i1-1);
        \draw [orange, extended line = 2cm       ] (my dot-1) -- (i2-1);
        \draw [black , extended line = 4cm, thick] (my dot-1) -- (i3-1);

    \end{tikzpicture}
\end{document}
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.