3

see the given code.

\documentclass[12pt,a4paper]{article}
\usepackage[a4paper,bindingoffset=0.2in,left=0.7in,right=0.7in,top=0.7in,bottom=0.7in,footskip=.25in]{geometry}
\usepackage[centertags]{amsmath}
\usepackage{latexsym}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{newlfont}
\usepackage{enumerate}
\usepackage{makeidx}
\usepackage{tikz}
\usetikzlibrary{backgrounds,intersections}
\begin{document}
        \begin{tikzpicture}
        \draw[thick,latex-latex] (-2,0) -- (6,0)node[right]{$x$};
        \draw[thick,latex-latex] (0,-2) -- (0,6)node[above]{$y$};
        \node at (-0.3,-0.3) {O};
        \foreach \x in {-1,1,2,3,4,5}{
            \node[fill,circle,inner sep=1.5pt,label=below:$\x$] at (\x,0) {};
            \node[fill,circle,inner sep=1.5pt,label=left:$\x$] at (0,\x) {};
        }
        \draw[thick,stealth-stealth, shorten >= -2cm, shorten <= -2cm,name path =b ] (0,4) -- (4,0)
        node[pos=0.65,above,sloped] {$x+y=4$};
        \foreach \x/\y/\name in {0/4/B,4/0/A}{
            \node[fill,circle,inner sep=1.9pt,label={[inner sep=0pt]below left:\name($\x, \y$)}] at (\x,\y) {};
        }

        \end{tikzpicture}
\end{document}

My question is,

when i compile it, i am finding that the labelling of points A(4 , 0)and B(0 , 4) are mixed with labelling of axis. how can i separate it. Please help me.

snehal
  • 71

1 Answers1

1

Like this:

enter image description here

Just use above right instead of below left. The relevant lines in your code to be changed are these:

\foreach \x/\y/\name in {0/4/B,4/0/A}{
    \node[fill,circle,inner sep=1.9pt,label={[inner sep=0pt]above right:\name($\x, \y$)}] at (\x,\y) {};
}

Alternatively, get these two nodes out of the loop body and add them separately outside the \foreach the way you want.

AboAmmar
  • 46,352
  • 4
  • 58
  • 127