答案1
我想,要开始使用和喜爱 TikZ,您需要一些示例 =p 这是一个快速草稿;您可能需要调整文本和字体等等。
\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\begin{document}
% #1 x coordinate.
\newcommand{\vandbarrier}[1]{%
\node at (#1, 1) {\scriptsize $V = \infty$};
\node[scale = 0.5] at (#1, 0.5) {\textbf{(Barrier)}};%
}
% #1 x coordinate.
\newcommand{\vabove}[1]{%
\node[anchor = south] at (#1, 2) {\scriptsize $V = \infty$};%
}
\begin{tikzpicture}
\fill[gray]
(0, 0) rectangle (1, 2)
(2, 0) rectangle (3, 2);
\vandbarrier{0.5}
\vandbarrier{2.5}
\vabove{1}
\vabove{2}
\node[anchor = north] at (1, 0) {\scriptsize 0};
\node[anchor = north] at (2, 0) {\scriptsize $L$};
\node[anchor = north] at (3, 0) {\scriptsize $x$};
\node[anchor = south] at (1.5, 0) {\scriptsize $V = 0$};
\draw[<->] (0, 0) to (3, 0);
\draw[->] (1, 0) to (1, 2);
\draw[->] (2, 0) to (2, 2);
\end{tikzpicture}
\end{document}
如果您认为定义我使用的两个命令有点过分,只需复制粘贴定义或其他操作即可。我只是不喜欢复制粘贴东西。我认为这样更容易修改。哦,如果最终在环境中figure
,您可以将这两个命令定义放在figure
环境本身中,紧跟在 之后\begin
,以避免污染全局范围。
答案2
我对量子力学笔记中 Alice 的回答做了一些修改:
\documentclass[tikz, border=5mm]{standalone}
\usepackage{color}
\usetikzlibrary{calc}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\begin{document}
% #1 x coordinate.
\newcommand{\vandbarrier}[1]{%
\node at (#1, 1.3) {\scriptsize $V = \infty$};
%
}
% #1 x coordinate.
\begin{tikzpicture}
\fill[gray!30]
(-1, 0) rectangle (0, 2.5)
(4, 0) rectangle (5, 2.5);
\vandbarrier{-0.5}
\vandbarrier{4.5}
\node[anchor = north] at (0, 0) {\scriptsize 0};
\node[anchor = north] at (4, 0) {\scriptsize $a$};
\node[anchor = north] at (2, 0) {\scriptsize $x$};
\node[anchor = south] at (2, 1) {\scriptsize $V = 0$};
\node[anchor = north] at (2, 0) {\scriptsize $x$};
\node[anchor = north] at (2, 2) {\scriptsize $\psi_n(x)=\sqrt{\frac{2}{a}}\sin\left(\frac{n\pi}{a}x\right)$};
\node[anchor = north] at (2, 2.5) {\scriptsize $E_n(x)=\frac{n^2\pi^2\hbar^2}{2ma^2}$};
\draw[<->] (-1, 0) to (5, 0);
\draw[->] (4, 0) to (4, 2.5);
\draw[->] (0, 0) to (0, 2.5);
%Functions
\draw[red, thick, domain=0:4, samples=200] plot (\x, {sin(180*\x/4)}) ;
\draw[blue, thick, domain=0:4, samples=200] plot (\x, {sin(360*\x/4)}) ;
\draw[green, thick, domain=0:4, samples=200] plot (\x, {sin(540*\x/4)}) ;
\end{tikzpicture}
\end{document}