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.

What drew me primarily to LaTeX is beautiful typesetting, especially its capability to render mathematical texts and figures beautifully. As a high school teacher, I use LaTeX a lot to create handouts. To draw my figures, I usually use TikZ. I have no experience on coding before LaTeX and so I don't know when my style is already bad or if it is any good at all. What I know is that the code gets the job done.

Now, to get to the question in the title, here is a code that I wrote using TikZ for a topic on limits of functions for high school students.

\documentclass{article}

\usepackage{tkz-fct}
\usetikzlibrary{arrows}

\begin{document}

    \begin{tikzpicture}[scale=0.5]
        \tkzInit [xmin=-7,xmax=7,ymin=-7,ymax=7]
        \begin{scriptsize}
        \tkzGrid[color = gray!30!white]
        \tkzAxeXY
        \end{scriptsize}
        \draw (-2,3) circle (3pt);
        \fill (1,2) circle (3pt);
        \draw (1,4) circle (3pt);
        \fill (-2,4) circle (3pt);
        \fill (7,-1) circle (3pt);
        \draw [-latex] (-2.1,2.9) parabola (-4.9,-7);
        \draw (1,2) parabola (-1.9,2.9);
        \draw [-latex] (1.1,3.9) parabola (2.9,-7);
        \draw [-latex] (7,-1) parabola (3.1,7);
        \draw [dashed = on 3pt off 3pt] (-5,-7) -- (-5,7);
        \draw [dashed = on 3pt off 3pt] (3,-7) -- (3,7);
    \end{tikzpicture}

\end{document}

This is supposed to be a graph of a function $f$ with the following properties:

  • \lim\limits_{x\rightarrow -5^+} f(x) = -\infty$ (My use of \limits here is how I really use it in my handouts and test papers since it makes the math easier to read by my high school students)
  • \lim\limits_{x\rightarrow -2^-} f(x) = 3$
  • \lim\limits_{x\rightarrow 1^+} f(x) = 4$
  • \lim\limits_{x\rightarrow 3^-} f(x) =-\infty$
  • \lim\limits_{x\rightarrow 3^+} f(x) = +\infty$

Note that I used a lot of parabola in my TikZ code, though I just used them because it made my code shorter and so saved me a lot of encoding time and doing manual computations (which I could then use for tutoring students having difficulty with calculus) for the placement of nodes/coordinates. (Also, I have little patience at this point with bezier curves. I know, I really have to change this behavior soon.) But note that in the actual PDF, there is a space between the hole at (-2,3) and the curves connected to it. So my first question really is:

How do I create a curve with one end a hole? I have once tried something like \draw [o-] (-2,3) -- (1,2); but I end up with an awkward-looking figure.

Also, as you can see, I have mixed TikZ code using some syntax from the standard TikZ and @Altermundus 's tkz-fct (which I think is just okay since the package tkz-fct is built on top of TikZ). Again, my main reason is practicality, attaining my goal without using several foreach loops. So my second question is, is this okay, sound LaTeX coding?

share|improve this question
    
Unrelated: I looked at your blog and found some of the images scanned into a tex file. So, I thought I'll point you to a link that might probably help you. this one in particular Search around the site and our Tikz experts would have written about most of your doubts. –  kan Aug 15 '12 at 9:31
    
As for this question, I don't see the question distinctly but it might just be me. But, I'd suggest that you rewrite your question to make the question explicit. –  kan Aug 15 '12 at 9:32
    
@KannappanSampath, one of my questions concern cases when one has a discontinuity in the graph like say a function defined by $f(x)=\frac{x-1}{(x-1)(x+2)}$. This one has a hole (discontinuity) at (1,1/3). Once, I tried doing an import from Geogebra but the discontinuity was not shown in the figure. Drawing a circle centered at (1,1/3) will just give a circle on top of the $f(x) = 1/(x+2)$ at $x=1$. –  hpesoj626 Aug 15 '12 at 9:55
add comment

1 Answer

up vote 4 down vote accepted

Here the code with only tkz-fct. It's possible to use only tikz or the excellent pgfplots.

Some strange problems appears with gnuplot, it's why you can see sometimes (-5) instead of -5 or (-1)(x-1)*2 instead of -1(x-1)**2.

\documentclass{article}
\usepackage{tkz-fct}
\usetikzlibrary{arrows}

\begin{document}

    \begin{tikzpicture}[scale=0.5,font=\scriptsize]
        \tkzInit [xmin=-7,xmax=7,ymin=-7,ymax=7]
        \tkzGrid[color = gray!30!white] 
        \tkzVLines[dashed = on 3pt off 3pt,color=blue]{(-5),3}
        \tkzAxeXY
        \tkzFct[domain=-4.8:-2,<-]{-1.2*(x+2)**2+3}
        \tkzFct[domain=-2:1]{(x-1)**2/9+2}
        \tkzFct[domain=1:2.6,->]{(-1)*(x-1)**2/0.25+4}
        \tkzDefPointByFct[with=b](-2)  
        \tkzDrawPoint[fill=white](tkzPointResult)
        \tkzDefPointByFct[draw,with=b](1)
        \tkzDefPointByFct[with=c](1) 
        \tkzDrawPoint[fill=white](tkzPointResult)
    \end{tikzpicture}

\end{document} 

enter image description here

share|improve this answer
    
Do you have some manual for this package? it seems very useful to me but I can't find the manual. I can read french if needed –  leo Aug 15 '12 at 19:59
    
Thank you very much for the speedy reply @Altermundus. Great. This helps a lot. Although I would still like to know your opinion about the mixed syntaxes. –  hpesoj626 Aug 16 '12 at 2:15
    
It's possible to mix the syntaxes but I prefer to avoid the mix when it's possible. –  Alain Matthes Aug 16 '12 at 5:23
    
@leo sorry for the moment the manual is only in french but there are a lot of examples. –  Alain Matthes Aug 16 '12 at 5:25
    
And where is the french manual? :) –  leo Aug 16 '12 at 15:29
show 2 more comments

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.