For my maths summary I am trying to make a table with all function plots of the trigonometric functions (Something like the picture below, but including the inverses). Since my space is limited to 12 pages I want some of them to be vertically aligned to save some space, just like in the picture. I am fairly new to Latex and I tried doing this using tabular
. However the plots are bit too far on the right – I want them perfectly centered. How can I do this?
My other problem is that if I try to plot functions like tan
, csc
, sec
, arcsin
,arccos
,… they either produce an error or mess everything up. How can I plot these functions?
I also couldn't find any templates with all the trig functions summarized, which I found odd since I thought that would be something I am not the first person in need of. Is there a secret place where such files are shared?
Here is my code for three functions (I included cosine twice so I have something to display):
\documentclass{article}
\usepackage[utf8]{inputenc}
\title{testtt}
\usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb}
\usepackage{amsthm} \usepackage{latexsym} \usepackage{mathtools}
\usepackage{tikz}
\begin{document}
\newcommand*{\xMin}{-9}
\newcommand*{\xMax}{9}
\newcommand*{\yMin}{-3}
\newcommand*{\yMax}{3}
\begin{tabular}{ c c }
\begin{tikzpicture}[>=stealth,scale=0.4]
\draw[very thin,color=gray,scale={pi/2}] ({\xMin*((1)/(2))+0.01},-6/pi+0.01) grid ({\xMax*(1/2)-0.01},7/pi-0.01);
\draw node at ({pi},0) [below] {${\pi}$};
\draw node at ({2*pi},0) [below] [xshift=1pt] {${2\pi}$};
\draw node at ({-pi},0) [below] [xshift=-2pt] {${-\pi}$};
\draw node at ({-2*pi},0) [below] [xshift=-2pt] {${-2\pi}$};
\draw node at (0,1) [left] {$1$};
\draw node at (0,2) [left] {$2$};
\draw node at (0,-1) [left] {$-1$};
\draw node at (0,-2) [left] {$-2$};
\draw [->] [thick] ({\xMin*(pi/4)},0) -- ({\xMax*(pi/4)+0.5},0)
node [right] {$x$};
\draw [->] [thick] (0,-3) -- (0,3.5)
node [above] {$y$};
\draw [-,thin,black,domain={-2*pi}:{2*pi},samples=100]
plot (\x, {sin(\x*180/pi)}) node[above] {$f(x) = \sin(x)$};
\end{tikzpicture} &
\begin{tikzpicture}[>=stealth,scale=0.4]
\draw[very thin,color=gray,scale={pi/2}] ({\xMin*((1)/(2))+0.01},-6/pi+0.01) grid ({\xMax*(1/2)-0.01},7/pi-0.01);
\draw node at ({pi},0) [below] {${\pi}$};
\draw node at ({2*pi},0) [below] [xshift=1pt] {${2\pi}$};
\draw node at ({-pi},0) [below] [xshift=-2pt] {${-\pi}$};
\draw node at ({-2*pi},0) [below] [xshift=-2pt] {${-2\pi}$};
\draw node at (0,1) [left] {$1$};
\draw node at (0,2) [left] {$2$};
\draw node at (0,-1) [left] {$-1$};
\draw node at (0,-2) [left] {$-2$};
\draw [->] [thick] ({\xMin*(pi/4)},0) -- ({\xMax*(pi/4)+0.5},0)
node [right] {$x$};
\draw [->] [thick] (0,-3) -- (0,3.5)
node [above] {$y$};
\draw [-,thin,black,domain={-2*pi}:{2*pi},samples=100]
plot (\x, {cos(\x*180/pi)}) node[above] {$f(x) = \cos(x)$};
\end{tikzpicture} \\
\begin{tikzpicture}[>=stealth,scale=0.4]
\draw[very thin,color=gray,scale={pi/2}] ({\xMin*((1)/(2))+0.01},-6/pi+0.01) grid ({\xMax*(1/2)-0.01},7/pi-0.01);
\draw node at ({pi},0) [below] {${\pi}$};
\draw node at ({2*pi},0) [below] [xshift=1pt] {${2\pi}$};
\draw node at ({-pi},0) [below] [xshift=-2pt] {${-\pi}$};
\draw node at ({-2*pi},0) [below] [xshift=-2pt] {${-2\pi}$};
\draw node at (0,1) [left] {$1$};
\draw node at (0,2) [left] {$2$};
\draw node at (0,-1) [left] {$-1$};
\draw node at (0,-2) [left] {$-2$};
\draw [->] [thick] ({\xMin*(pi/4)},0) -- ({\xMax*(pi/4)+0.5},0)
node [right] {$x$};
\draw [->] [thick] (0,-3) -- (0,3.5)
node [above] {$y$};
\draw [-,thin,black,domain={-2*pi}:{2*pi},samples=100]
plot (\x, {cos(\x*180/pi)}) node[above] {$f(x) = \cos(x)$};
\end{tikzpicture}
\end{tabular}
\end{document}
Best Answer
I would advocate using the
pgfplots
package for this type of graphic.It allows you to use the following, for example
Here's a couple of demonstrations; adjust as you see fit. For reference, see also Axis with trigonometric labels in PGFPlots, for example.
option 1 : using minipages, and individual plots
option 2: just like option 1, but with titles
If you'd like to add titles, we can use the following, for example; you'll see that the new part to the above is
and then, within the code, I've used
\begin{axis}[title={$y=\sin(x)$}]
.option 3: using groupplot
The output is as in option 2, but the input is, perhaps, more pleasing; note that this requires the
groupplots
library, annotated in the code below.If you need to number/reference the figures, then I'd recommend using the
\caption
command, perhaps employing thesubfigure
package.