首先,这是一个很棒的网站,它教会了我很多关于乳胶的知识,希望我也能学会如何绘制图表。
该图来自 YouTube 上解释复数的视频:
我想象代码看起来像这样:
\documentclass[11pt]{article} %allowed 12pt
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
%text explaining the diagram goes here
\begin{tikzpicture}
%\begin{centre}
\draw[latex-latex] (-4.5,0) -- (4.5,0) ; %edit here for the axis
\foreach \x in {-4,-3,-2,-1,0,1,2,3,4} % edit here for the number on vertical lines
\draw[shift={(\x,0)},color=black] (0pt,3pt) -- (0pt,-3pt);%mooves top daches, (left tilt, up hight)---(right tilte, down hight)
%up arrow for \sqrt {-1}\in \mathbb{C}
\foreach \x in {-\infty \in \mathbb{Z} ,,-\sqrt {2}\in \mathbb{R},-\dfrac {1} {1}\in \mathbb{Q} ,0,1\in \mathbb{N},\dfrac {2} {4}\in \mathbb{Q},\pi\in\mathbb{R} ,\infty \in \mathbb{Z} } % edit here for the numbers at each position
%down arrow for -\sqrt {-1}\in \mathbb{C}
\draw[shift={(\x,0)},color=black] (0pt,0pt) -- (0pt,-3pt) node[below]{$\x$};%mooves botom dashes
%\end{centre}
\end{tikzpicture}
%text after the diagram goes here
\end{document}
谢谢您的帮助,我尝试查看 pgfmanual,但似乎找不到可以遵循的示例。
答案1
您在寻找类似的东西吗?下面我提供原始编码(即我不使用循环或类似的东西)。我不明白您是否只想要那种绘图或宏来以那种风格绘制您想要的任何图片。
\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[xscale = 1.5]
% draw axis
\draw [thick, ->] (0,0.25) -- (0,2.2);
\draw [thick, ->] (0,-0.65) -- (0,-2.2);
\draw [thick, <->] (-4.5,0) -- (4.5,0);
% draw lines in x axis
\draw (0,-0.2) -- (0,0.2); % zero
\draw (0.5,-0.2) -- (0.5,0.2); % 2/4 \in \mathbb{Q}
\draw (1.3,-0.2) -- (1.3,0.2); % 1 \in \mathbb{N}
\draw (-1,-0.2) -- (-1,0.2); % -1/1 \in \mathbb{Q}
\draw (3.14159265359,-0.2) -- (3.14159265359,0.2); % \pi \in \mathbb{R}
\draw (4,-0.2) -- (4,0.2);
\draw (-4,-0.2) -- (-4,0.2);
\draw (-2,-0.2) -- (-2,0.2); %-\sqrt(2) \in \mathbb{R}
% write math symbols
\node [below] at (0,-0.2) {$0$};
\node [below] at (0.5,-0.2) {$\frac{2}{4}\in\mathbb{Q}$};
\node [below] at (1.3,-0.2) {$1\in\mathbb{N}$};
\node [below] at (-1,-0.2) {$-\frac{1}{1}\in\mathbb{Q}$};
\node [below] at (3.14159265359,-0.2) {$\pi\in\mathbb{R}$};
\node [below] at (-2,-0.2) {$-\sqrt{2}\in\mathbb{R}$};
\node [above] at (4,0.2) {$\infty$};
\node [above] at (-4,0.2) {$-\infty$};
\node [right] at (0,1.5) {$\sqrt{-1} \in \mathbb{C}$};
\node [left] at (0,-1.5) {$-\sqrt{-1} \in \mathbb{C}$};
\end{tikzpicture}
\end{document}