如何为线上的某些数字着色并添加阴影

如何为线上的某些数字着色并添加阴影

问题:

  • 在图(1)中我想将 0(零)设为蓝色

  • 在图(2)中,我想给数字加阴影(附图)

梅威瑟:

\documentclass[12pt]{article}
\usepackage[bindingoffset=0.2in,left=0.5in,right=0.5in,top=0.5in,bottom=0.5in,footskip=.25in]{geometry}
\usepackage[centertags]{amsmath}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{enumerate}
\usepackage{makeidx}
\usepackage{tikz}
\usepackage{xparse}
\usetikzlibrary{backgrounds,intersections}
\begin{document}
Figure (1)

    \begin{tikzpicture}[xscale=1.5]
        \draw[thick,latex-latex] (-5,0) -- (5,0)node[right]{};
        \foreach \x in {-4,-3,-2,-1,0,1,2,3,4}{
            \node[fill,circle,inner sep=1.20pt,label=below:$\ifnum\x>0\color{blue}\fi\x$] at (\x,0) {};
        };
    \end{tikzpicture}

\vspace{1.5cm}
Figure (2)

\begin{tikzpicture}[xscale=1.5]
    \draw[thick,latex-latex] (-5,0) -- (5,0)node[right]{};
    \foreach \x in {-4,-3,-2,-1,0,1,2,3,4}{
        \node[fill,circle,inner sep=1.20pt,label=below:$\x$] at (\x,0) {};
    };
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案1

答案:

  1. 而不是>0使用>-1
  2. 画出另一条你喜欢的颜色的线

梅威瑟:

\documentclass[12pt]{article}
\usepackage[bindingoffset=0.2in,left=0.5in,right=0.5in,top=0.5in,bottom=0.5in,footskip=.25in]{geometry}
\usepackage[centertags]{amsmath}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{enumerate}
\usepackage{makeidx}
\usepackage{tikz}
\usepackage{xparse}
\usetikzlibrary{backgrounds,intersections}
\begin{document}
Figure (1)

    \begin{tikzpicture}[xscale=1.5]
        \draw[thick,latex-latex] (-5,0) -- (5,0)node[right]{};
        \foreach \x in {-4,...,4}{
            \node[fill,circle,inner sep=1.20pt,label=below:$\ifnum\x>-1\color{blue}\fi\x$] at (\x,0) {};
        };
    \end{tikzpicture}

\vspace{1.5cm}
Figure (2)

\begin{tikzpicture}[xscale=1.5]
    \draw[line width=5mm, green, yshift=2.5mm] (0,0) -- (4,0);
    \draw[thick,latex-latex] (-5,0) -- (5,0)node[right]{};
    \foreach \x in {-4,...,4}{
        \node[fill,circle,inner sep=1.20pt,label=below:$\x$] at (\x,0) {};
    };
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容