2

I'm recreating and old middle school (Europe) textbook table in LaTeX about some very common functions (see below). I would like a feedback if some people think i should do some improvement or add others functions as i have room to add one more row (ie 4 functions).

\begin{table}[H]
        \centering
        \begin{tabular}{|c|c|c|c|}
        \hline
        \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={{\LARGE Constant}},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=-3:3, blue, smooth, thick] { 2 };
          \end{axis}
        \end{tikzpicture} &
        \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={\LARGE Linear},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=-3:3, blue, smooth, thick] { x };
          \end{axis}
        \end{tikzpicture} & 
        \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={\LARGE Absolute Value},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=-3:3, blue, smooth, thick] { abs(x) };
          \end{axis}
        \end{tikzpicture} & 
        \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={{\LARGE Quadratic}},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=-3:3, blue, smooth, thick] { x^2 };
          \end{axis}
        \end{tikzpicture} \\
        $f(x)=c^{te}$ & $f(x)=x$ & $f(x)=|x|$ & $f(x)=x^2$\\ \hline
        \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={{\LARGE Square root}},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=-3:3, blue, samples=200, smooth, thick] { sqrt(x) };
          \end{axis}
        \end{tikzpicture} & \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={{\LARGE Cubic}},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=-3:3, blue, samples=200, smooth, thick] { x^3 };
          \end{axis}
        \end{tikzpicture} & \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={{\LARGE Cube root}},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=-3:3, blue, samples=200, smooth, thick] { x^(2/3) };
          \end{axis}
        \end{tikzpicture} & 
        \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={{\LARGE Inverse}},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=-3:3, blue, samples=200, smooth, thick] { 1/x };
          \end{axis}
        \end{tikzpicture} \\
        $f(x)=\sqrt{x}$ & $f(x)=x^3$ & $f(x)=\sqrt[3]{x}$ & $f(x)=\dfrac{1}{x}$\\ \hline
        \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={{\LARGE Rational}},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=-3:-0.1, blue, samples=200, smooth, thick] { 1/x^2 };
            \addplot [domain=0.1:3, blue, samples=200, smooth, thick] { 1/x^2 };
          \end{axis}
        \end{tikzpicture}  & 
        \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={{\LARGE Logarithmic}},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=0.1:3, blue, samples=200, smooth, thick] { ln(x) };
          \end{axis}
        \end{tikzpicture}  & \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={{\LARGE Exponential}},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=-3:3, blue, samples=200, smooth, thick] { e^x };
          \end{axis}
        \end{tikzpicture}  & \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={{\LARGE Grestest Integer (step function)}},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot +[thick, samples at={-3,-2,-1,...,2,3},
               jump mark left] {ceil(x+1)};
             \addplot  [thick, samples at={-2,-1,0,...,2,3}, only marks,
               mark options={draw=blue,fill=white}] {(x)};
          \end{axis}
        \end{tikzpicture}  \\
        $f(x)=\dfrac{1}{x^2}$ & $f(x)=\ln(x)$ & $f(x)=e^x$ & $f(x)=[x]$\\ \hline
        \multicolumn{1}{|c|}{\cellcolor[HTML]{EFEFEF}\begin{tabular}[c]{@{}c@{}}Trigonometric\\ Functions\end{tabular}} & \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={{\LARGE Sine}},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=-3:3, blue, samples=200, smooth, thick] { sin(deg(pi*x)) };
          \end{axis}
        \end{tikzpicture} & \begin{tikzpicture}[scale=0.45]
          \begin{axis} [axis lines=center,
          title={{\LARGE Cosine}},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
            \addplot [domain=-3:3, blue, samples=200, smooth, thick] { cos(deg(pi*x)) };
          \end{axis}
        \end{tikzpicture} & \begin{tikzpicture}[scale=0.45]
        \begin{axis}[%
            axis lines=middle,
            title={{\LARGE Tangent}},
            axis on top,
            xlabel=$x$,
            ylabel=$y$,
            domain=-2*pi:2*pi,
            xmin=-7,
            xmax=7,
            ymin=-5,
            ymax=5,
            trig format plots=rad, %<- 
            xtick={-2*pi,-3*pi/2, -pi, -pi/2,pi/2,pi,3*pi/2,2*pi},
            xticklabels={$-2\pi$, $-\frac{3\pi}{2}$, $-\pi$, $-\frac{\pi}{2}$, $\frac{\pi}{2}$,$\pi$,$\frac{3\pi}{2}$,$2\pi$},
            every axis y label/.style={rotate=0, black, at={(0.5,1.05)},},
            every axis x label/.style={rotate=0, black, at={(1.05,0.5)},},,
            font=\footnotesize,     
         ]
        \pgfplotsinvokeforeach{-5,-3,...,3}{
        \pgfmathsetmacro{\xmin}{ifthenelse(#1==-5,-2*pi,#1*pi/2+0.01)}
        \pgfmathsetmacro{\xmax}{ifthenelse(#1==3,2*pi,#1*pi/2+pi-0.01)}
        \addplot[samples=51,smooth,blue,domain=\xmin:\xmax]{tan(x)};
        \draw[densely dotted] (#1*pi/2,\pgfkeysvalueof{/pgfplots/ymin})
         -- (#1*pi/2,\pgfkeysvalueof{/pgfplots/ymax});
        }
        \end{axis}
        \end{tikzpicture} \\ 
        \cellcolor[HTML]{EFEFEF} $\rightarrow$ & $f(x)=\sin(x)$ & $f(x)=\cos(x)$ & $f(x)=\tan(x)$
         \\ \hline
        \end{tabular}
    \end{table}

enter image description here

Thanks for your feedback

2
  • Are there specific things that you would like to improve? If not then the question is a bit vague and dependent on people's opinions (which is off-topic on the site) I'm afraid.
    – Marijn
    Commented Dec 25, 2022 at 16:02
  • Yes the design, the informations on the axis and as requested in the original question: what kind of other functions i should add as i have room for 4 others one... Commented Dec 25, 2022 at 17:44

1 Answer 1

4

My main suggestion, in terms of LaTeX code efficiency, is to create a macro that can be used for 13 of the 15 pics; see the macro \mypic in the code below for an example of how this might be done.

Still on the topic of LaTeX code efficiency, I suggest you employ an array environment instead of a tabular environment. This would allow you to get rid of lots of $ symbols and thus cut down on code clutter. And, by reducing the value of \arraycolsep, one can increase the value of the scale option; your readers might like that.

In terms of graphical accuracy, I'd say that the markers on the horizontal axes don't look right for the sine and cosine functions. You may want to orient yourself on how you handled the x-axis labeling in the case of the tangent function.

Finally, on the subject of overall aesthetics, do consider getting rid of all vertical and horizontal lines -- they're not needed, and they won't be missed.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters as needed
\usepackage{colortbl,array,mathtools,tikz,pgfplots}

% Typographic strut, for use in final pic:
\newcommand\mystrut{\vphantom{\frac12}} 
% The following macro is used in 13 of the 15 pics below:
\newcommand\mypic[3][]{%
  \begin{tikzpicture}[scale=0.52]
      \begin{axis} [axis lines=center,
        title={\LARGE #2},
        xmin=-3,xmax=3,
        ymin=-3,ymax=3,
        ytick={-3,-2,...,3}]
      \addplot [domain=-3:3, blue, #1, smooth, thick] { #3 };
      \end{axis}
  \end{tikzpicture}%
}

\begin{document}
\begin{table}[ht!]
\setlength\arraycolsep{1pt} % default: 5pt
\centering
$\begin{array}{@{} cccc @{}}
%\hline
  \mypic{Constant}{2} &
  \mypic{Linear}{x} & 
  \mypic{Absolute Value}{abs(x)} & 
  \mypic{Quadratic}{x^2} \\
  f(x)=\mbox{const.} & f(x)=x & f(x)=|x| & f(x)=x^2 \\[3ex]
%\hline
  \mypic{Square root}{sqrt(x)} & 
  \mypic{Cubic}{x^3} & 
  \mypic{Cube root}{x^(2/3)} & 
  \mypic[samples=200]{Inverse}{1/x} \\
  f(x)=\sqrt{x} & f(x)=x^3 & f(x)=\sqrt[3]{x} & f(x)=1/x \\[3ex] 
%\hline
  \mypic{Rational}{1/x^2} & 
  \mypic{Natural Logarithm}{ln(x)} & 
  \mypic{Exponential}{e^x} & 
  \begin{tikzpicture}[scale=0.52]
      \begin{axis} [axis lines=center,
          title={\LARGE Greatest Integer (step function)},
          xmin=-3,xmax=3,
          ymin=-3,ymax=3,
          ytick={-3,-2,...,3}]
      \addplot +[thick, samples at={-3,-2,-1,...,2,3},
               jump mark left] {ceil(x+1)};
      \addplot  [thick, samples at={-2,-1,0,...,2,3}, only marks,
               mark options={draw=blue,fill=white}] {(x)};
      \end{axis}
  \end{tikzpicture}  \\
  f(x)=1/x^2 & f(x)=\ln(x) & f(x)=e^x & f(x)=\lceil x\rceil \\[3ex]
%\hline
  \cellcolor[HTML]{EFEFEF}
  \begin{tabular}{@{}c@{}}Trigonometric\\Functions\end{tabular} & 
  \mypic{Sine}{sin(deg(pi*x))} & 
  \mypic{Cosine}{cos(deg(pi*x))} & 
  \begin{tikzpicture}[scale=0.52]
      \begin{axis}[%
      axis lines=middle,
      title={\LARGE Tangent},
      %axis on top,
      %xlabel=$x$,
      %ylabel=$y$,
      domain=-2*pi:2*pi,
      xmin=-6.5,xmax=6.5,
      ymin=-5,ymax=5,
      trig format plots=rad, %<- 
      xtick={-2*pi,-3*pi/2,-pi,-pi/2,pi/2,pi,3*pi/2,2*pi},
      xticklabels={$\mathllap{-}2\pi\mystrut$, $-\frac{3}{2}\pi$,$-\pi\mystrut$,  $-\frac{1}{2}\pi$, 
                   $\frac{1}{2}\pi$,$\pi\mystrut$,    $\frac{3}{2}\pi$,$2\pi\mystrut$},
      every axis y label/.style={rotate=0, black, at={(0.5,1.05)},},
      every axis x label/.style={rotate=0, black, at={(1.05,0.5)},},,
      ytick={-5,-2.5,...,5},
      %font=\footnotesize
      ]
      \pgfplotsinvokeforeach{-5,-3,...,5}{
        \pgfmathsetmacro{\xmin}{ifthenelse(#1==-5,-2*pi,#1*pi/2+0.01)}
        \pgfmathsetmacro{\xmax}{ifthenelse(#1==3,2*pi,#1*pi/2+pi-0.01)}
        \addplot[samples=51,smooth,blue,domain=\xmin:\xmax,thick]{tan(x)};
        \draw[densely dotted] (#1*pi/2,\pgfkeysvalueof{/pgfplots/ymin})
         -- (#1*pi/2,\pgfkeysvalueof{/pgfplots/ymax});
      }
      \end{axis}
  \end{tikzpicture} \\ 
  \cellcolor[HTML]{EFEFEF} \rightarrow & 
  f(x)=\sin(x) & f(x)=\cos(x) & f(x)=\tan(x) \\ 
%\hline
\end{array}$
\end{table}
\end{document}
1
  • 1
    Thanks that a good technical LateX improvement indeed! Commented Dec 25, 2022 at 17:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .