# LaTeX

### Plotting with TikZ, Part III: Plotting a function defined by a formula, and plotting functions that go through certain points

In the last post, I described how I use TikZ to create a graph that might otherwise be created freehand: In this post, I will describe one method for using TikZ to to plot a function defined by a formula, such as $$y = \left(2x^2 - x - 1\right)e^{-x}.$$ Then I will show two ways to make a function go through a certain point. Plotting from a formula Simple example There are a number of ways to achieve this, and PGF actually includes the functionality to perform calculations in TeX.

### Plotting with TikZ, Part II: Functions without formulæ

In the last post, I explained why TikZ is awesome for making plots. One good use case for handmade TikZ plots is to typeset a question like this: (2 points each) A plot of the graph of the function $f$ is below: For each of the following expressions, either evaluate the expression or state that it is undefined: a. $\lim_{x \rightarrow 2^{-}} f(x)$ b. $\lim_{x \rightarrow 2^{+}} f(x)$

### Plotting with TikZ, Part I: Why?

This is the first part of a three-part series of posts on generating plots of graphs with TikZ. Last year, I left my position as a mathematics professor, after teaching mathematics at the college level for 15 years (nine years as a faculty member, and six years as a graduate teaching fellow). In that time, I picked up a lot of tricks using LaTeX to produce teaching materials (handouts and slides).

### LaTeX mailmerge package

The LaTeX mailmerge package is super useful, especially for creating multiple versions of tests. Before I discovered mailmerge, my workflow for writing a test was basically: Write one version of the test. Make a duplicate of the file. Edit the file to change all the constants. At least, that was my intended workflow. But typically I would also: Realize that there was some change I wanted to make to the test.

The other day, I was writing some lecture notes for my linear algebra class, and wanted to create the following diagram (to illustrate the concept of a Markov chain): I had a very limited time in which to finish these notes. Fortunately, I found the tkz-graph package, which made this a snap: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 \documentclass{standalone} \usepackage{tikz} \usepackage{fouriernc} \usepackage{tkz-graph} \begin{document} \begin{tikzpicture} \SetGraphUnit{5} \Vertex[x=0, y=10]{0 points}; \Vertex[x=0, y=5]{1 point}; \Vertex[x=0, y=0]{Win}; \Vertex[x=5, y=5]{Lose}; \Edge[style ={->}, label={$1/3$}]({0 points})({1 point}); \Edge[style ={->}, label={$1/3$}]({1 point})({Win}); \Edge[style ={->}, label={$1/6$}]({0 points})({Lose}); \Edge[style ={->}, label={$1/6$}]({1 point})({Lose}); \Loop[style ={->}, label={$1/2$}, labelstyle={fill=white}]({0 points}); \Loop[style ={->}, label={$1/2$}, labelstyle={fill=white}]({1 point}); \Loop[style ={->}, label={$1$}, dir=EA, labelstyle={fill=white}]({Lose}); \Loop[style ={->}, label={$1$}, labelstyle={fill=white}]({Win}); \end{tikzpicture} \end{document} You don’t even have to specify the locations of the vertices; you can throw caution to the wind and have LaTeX decide where to place them!