我正在用 LaTeX 重新创建旧中学(欧洲)教科书表格,其中包含一些非常常见的函数(见下文)。如果有人认为我应该做一些改进或添加其他函数,我希望得到反馈,因为我还有空间可以添加一行(即 4 个函数)。
\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}
感谢您的反馈意见
答案1
就 LaTeX 代码效率而言,我的主要建议是创建一个可用于 15 张图片中的 13 张的宏;请参阅\mypic
下面代码中的宏以获取如何执行此操作的示例。
仍然在 LaTeX 代码效率的话题上,我建议您使用环境array
而不是tabular
环境。这将允许您摆脱大量$
符号,从而减少代码混乱。而且,通过降低值\arraycolsep
,可以增加选项的值scale
;您的读者可能会喜欢这一点。
就图形准确性而言,我认为水平轴上的标记对于正弦和余弦函数来说看起来不太正确。您可能需要了解如何在正切函数的情况下处理 x 轴标记。
最后,关于整体美观,请考虑去掉所有垂直线和水平线——它们是不需要的,而且不会被忽略。
\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}