2

I want to draw a rectangle with a solid dot in each corner. How can I do this?

3
  • 3
    Hi and welcome to TeX.sx. In its current form, your question might not receive many answers. Please take a look at the How to Ask-page and try to improve your question according to the guidance found there. This may require you to show some effort on your part in terms of attempting a solution. If you have questions about what to do or if you don't quite understand what this means, please ask for clarification using the add comment function. Commented Apr 9, 2012 at 12:00
  • 1
    Yes, please clarify. What I posted, it told me initially that my question was not up to standards. Commented Apr 9, 2012 at 12:04
  • Do you use tikz or pstricks? Commented Apr 9, 2012 at 12:06

3 Answers 3

8

This is to give a variant from Marco's answer, concerning the Tikz part of his answer. It looks more like the pstricks answer and does not require that you enter the coordinates twice.

The code is

\documentclass[border=5pt]{standalone}

\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

\draw plot[mark=*,mark size = 1pt,mark options={color=red}] coordinates {(0,0)(1,0)(1,1)(0,1)} -- cycle; 

\end{tikzpicture}
\end{document}

plot will give straight lines segments if you don't ask for a smooth plot from coordinates.

The result is

enter image description here

7

To draw inside LaTeX you can use the package tikz or pstricks. Both packages have their drawbacks and benefits.

PSTricks:

Compile the following example with xelatex or latex-ps-pdf

\documentclass{article}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(0,0)(4,4)
\psline[showpoints=true](1,1)(3,1)(3,3)(1,3)(1,1)
\end{pspicture}
\end{document}

You get the result:

enter image description here

TikZ

Compile with pdflatex:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path (0,0) rectangle (4,4);
\draw (1,1) rectangle(3,3);
\foreach \x/\y in {1/1,3/1,3/3,1/3}
 \fill (\x,\y) circle (2pt);
\end{tikzpicture}
\end{document}

You get: enter image description here

3
\documentclass{scrartcl}
\usepackage{tikz}
\begin{document} 

\tikzset{add reference/.style={insert path={%
    coordinate [pos=0] (#1sw) 
    coordinate [pos=1] (#1ne)                     
    (#1sw |- #1ne)  coordinate (#1nw)
    (#1sw -| #1ne)  coordinate (#1se) 
}}}  

\tikzset{pt/.style={circle,fill=#1,inner sep=0mm,minimum size=4pt}}  

\begin{tikzpicture} 
\draw (0,0) rectangle (4,4) [add reference=R];
\foreach \c in {sw,se,nw,ne}{ \path  (R\c) coordinate[pt=red] ;}
\end{tikzpicture}
\end{document} 

enter image description here

You must log in to answer this question.

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