标记数轴

标记数轴

我正在将教授的 .doc 文件转换为 LaTeX,以便我们可以进行更复杂的格式化,但我遇到了一个问题。

我想在 LaTeX 中重新创建这个数字线。

数轴

帮助了解使用哪个包以及学习哪些命令将会很有帮助。

答案1

您可以使用TikZ;该手册很棒,包含大量示例;在下面的例子中,基本结构是\node\draw

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
% a straight line segment
\draw (0.5,0) -- (10.5,0);
% the ticks and their labels
\foreach \x  in {1,...,10}
  \draw[xshift=\x cm] (0pt,2pt) -- (0pt,-1pt) node[below,fill=white] {\the\numexpr\x +112\relax};
% the thicker segment
\draw[ultra thick] (2.06,0) -- (8.94,0);
% the labels
\node[fill=white,draw=black,circle,inner sep=2pt,label=above:{$L_1=114.06$}] at (2.12,0) {};
\node[fill=white,draw=black,circle,inner sep=2pt,label=above:{$L_1=119.94$}] at (8.9,0) {};
\node at (5.5,-0.8) {$\mu$};
\end{tikzpicture}

\end{document}

在此处输入图片描述

下面是使用pgfplots(内部使用TikZ并且对于绘图非常有用):

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
  axis y line=none,
  axis lines=left,
  axis line style={-},
  xmin=112.5,
  xmax=121.5,
  ymin=0,
  ymax=1,
  xlabel=$\mu$,
  scatter/classes={o={mark=*}},
  restrict y to domain=0:1,
  xtick={113,114,...,121}
]
\addplot table [y expr=0,meta index=1, header=false] {
114.06 o
119.94 o
};
\node[coordinate,label=above:{$L_1=114.06$}] at (axis cs:114.06,0.05) {};
\node[coordinate,label=above:{$L_2=119.94$}] at (axis cs:119.94,0.05) {};
\end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

对于这种图表,你实际上不需要任何额外的软件包,LaTeX 可以独立完成:

在此处输入图片描述

\documentclass{article}

\begin{document}
\newcounter{nn}
\setlength\unitlength{2pt}

\begin{picture}(100,100)

\put(10,60){$L_1=114.06$}
\put(70,60){$L_2=119.94$}
\put(50,30){$\mu$}
\put(0,50){\line(1,0){100}}
\multiput(10,50)(10,0){9}{\line(0,1){5}}
\setcounter{nn}{113}%
\multiput(10,40)(10,0){9}{\makebox(0,0){\thenn\stepcounter{nn}}}

\thicklines
\put(20,50){\circle{3}}
\put(80,50){\circle{3}}

\linethickness{2pt}
\put(20,50){\line(1,0){60}}
\end{picture}

\end{document}

相关内容