2

With the contribution of a kind user : it has been possible to reproduce this scheme :

enter image description here

Using this code :

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}

\begin{document}
 \begin{tikzpicture}
\draw[very thick](-6,0) -- (-3.84,0) -- ++ (1mm,2mm) -- ++ (2mm,-4mm) -- ++ (1mm,2mm)
                        -- ( 3.36,0) -- ++ (1mm,2mm) -- ++ (2mm,-4mm) -- ++ (1mm,2mm)
                        -- (6,0);
\foreach \x/\i in {-5/x_{{1}{2}}, -4/x_{\frac{3}{2}},-2/, -1/x_{i-\frac{3}{2}}, 
                    1/x_{i+\frac{3}{2}}, 2, 4/x_{N_x-\frac{1}{2}}, 5/x_{N_x+\frac{1}{2}}}
\draw(1.2*\x, 2mm) -- ++ (0,-4mm) node[below]{$\i$};
%
\foreach \x/\i [evaluate=\x as \xx using \x+1] in {-5/1, -2/i-1, -0.5/i, 1/i+1, 4/N_x}
\path (1.2*\x,0) -- node[above, font=\small] {$\i$} (1.2*\xx,0);

\end{tikzpicture}
\end{document}

Now I am trying to add dots on specific points like in the image below :

enter image description here

I tried to manipulate a little bit the line node[above,...] by writing :

\documentclass[margin=3mm]{standalone}
\usepackage{tikz}

\begin{document}
 \begin{tikzpicture}
\draw[very thick](-6,0) -- (-3.84,0) -- ++ (1mm,2mm) -- ++ (2mm,-4mm) -- ++ (1mm,2mm)
                        -- ( 3.36,0) -- ++ (1mm,2mm) -- ++ (2mm,-4mm) -- ++ (1mm,2mm)
                        -- (6,0);
\foreach \x/\i in {-5/x_{{1}{2}}, -4/x_{\frac{3}{2}},-2/, -1/x_{i-\frac{3}{2}}, 
                    1/x_{i+\frac{3}{2}}, 2, 4/x_{N_x-\frac{1}{2}}, 5/x_{N_x+\frac{1}{2}}}
\draw(1.2*\x, 2mm) -- ++ (0,-4mm) node[below]{$\i$};
%
\foreach \x/\i [evaluate=\x as \xx using \x+1] in {-5/1, -2/i-1, -0.5/i, 1/i+1, 4/N_x}
\path (1.2*\x,0) -- node[circle,fill,above, font=\small] {$\i$} (1.2*\xx,0);

\end{tikzpicture}
\end{document}

And it ended up with this result ...

What is wrong with this try ?

Thank you very much for your help.

enter image description here

2
  • Make two separate node, the one contain text should be above, the circle one should not be above.
    – user202729
    May 15, 2022 at 11:24
  • @user202729 I am trying to do so but I am surely writing it wrongly because it doesn't work : I have just added this line : \node[circle,fill,inner sep=1/8pt] {-5/1, -2/i-1, -0.5/i, 1/i+1, 4/N_x};
    – Waxler
    May 15, 2022 at 12:10

1 Answer 1

1

Try replacing the line like this:

\path (1.2*\x,0) -- node[circle,fill,label=above:\small$\i$] {} (1.2*\xx,0);

instead of

\path (1.2*\x,0) -- node[circle,fill,above, font=\small] {$\i$} (1.2*\xx,0);
4
  • Thank you @kabenyuk : it worked perfectly. Could you please tell me the difference between the two lines ? I am not sure to get how did it work. Thank you
    – Waxler
    May 15, 2022 at 13:35
  • label creates a second node off to one side (above). The filled node is empty. May 15, 2022 at 13:38
  • For more on labels, see "The TikZ and PGF Packages Manual" for version 3.1.5bl on page 55.
    – kabenyuk
    May 15, 2022 at 14:02
  • Ok : thank you for reference !
    – Waxler
    May 15, 2022 at 14:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .