3

I use the following Latex script

\documentclass{article}
\usepackage{tikz,xcolor}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
\filldraw[fill=gray!40!white, draw=black] (0,0) rectangle (4,2);
\node[black](dot) at (2,1) {\textbullet};
\node[below=0cm of dot]  {\small{$x_a = (2,1)$}};
\end{tikzpicture} 

\end{document}

To get:

Rectangle

Is there a way to add the corner coordinates as well? For example, I would like to see (0,0) in the lower-left corner.

2 Answers2

2

A PSTricks solution only for fun purposes!

enter image description here

\documentclass[pstricks,12pt,border=12pt]{standalone}
\usepackage{pst-eucl}
\begin{document}
\begin{pspicture}(-1,-1)(4,2)
    \psframe[fillstyle=solid,fillcolor=lightgray](0,0)(4,2)
    \pstGeonode[PosAngle={-90},PointName={{x_0=(0,0)},{x_a=(2,1)}}](0,0){O}(2,1){A}
\end{pspicture}
\end{document}
Display Name
  • 46,933
1

Sure.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}
\filldraw[fill=gray!40!white, draw=black] (0,0) 
node[black,label={[font=\small]below:$x_0 = (0,0)$}](dot0){\textbullet}
rectangle (4,2)
node[black,midway,label={[font=\small]below:$x_a = (2,1)$}](dot){\textbullet};
\end{tikzpicture} 

\end{document}

enter image description here

Or

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}[bullet/.style={node contents={\textbullet},
label={[font=\small]below:#1}}]
\filldraw[fill=gray!40!white, draw=black] (0,0) 
node[bullet={$x_0=(0,0)$}] 
rectangle (4,2) node[midway,bullet={$x_a=(2,1)$}];
\end{tikzpicture} 

\end{document}