Put a caption under a drawn picture
Put the picture
inside a minipage
. This will allow it to be included in a figure
environment, which will therefore allow a \caption
.
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{figure}[ht]
\centering
\begin{minipage}{1.3in}
\begin{picture}(185,90)
\put(0,0){\framebox(30,30)}
\put(30,0){\framebox(30,30)}
\put(60,0){\framebox(30,30)}
\put(0,30){\framebox(30,30)}
\put(30,30){\framebox(30,30)}
\put(60,30){\framebox(30,30){\Large{\#}}}
\put(0,60){\framebox(30,30){\Large{\#}}}
\put(30,60){\framebox(30,30){\Large{\#}}}
\put(60,60){\framebox(30,30){\Large{\#}}}
\put(15,45){\vector(1,0){30}}
\end{picture}
\end{minipage}
\caption{Here is my caption.}
\end{figure}
\lipsum[2]
\end{document}
Following up on the OP's comment, one can, in order to get multiple images on a single line, place adjacent minipage
s on the same line, as long as they don't exceed the \linewidth
.
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{figure}[ht]
\centering
\begin{minipage}{1.3in}
\begin{picture}(185,90)
\put(0,0){\framebox(30,30)}
\put(30,0){\framebox(30,30)}
\put(60,0){\framebox(30,30)}
\put(0,30){\framebox(30,30)}
\put(30,30){\framebox(30,30)}
\put(60,30){\framebox(30,30){\Large{\#}}}
\put(0,60){\framebox(30,30){\Large{\#}}}
\put(30,60){\framebox(30,30){\Large{\#}}}
\put(60,60){\framebox(30,30){\Large{\#}}}
\put(15,45){\vector(1,0){30}}
\end{picture}
\end{minipage}
\begin{minipage}{1.3in}
\begin{picture}(185,90)
\put(0,0){\framebox(30,30)}
\put(30,0){\framebox(30,30)}
\put(60,0){\framebox(30,30)}
\put(0,30){\framebox(30,30)}
\put(30,30){\framebox(30,30)}
\put(60,30){\framebox(30,30){\Large{\#}}}
\put(0,60){\framebox(30,30){\Large{\#}}}
\put(30,60){\framebox(30,30){\Large{\#}}}
\put(60,60){\framebox(30,30){\Large{\#}}}
\put(15,45){\vector(1,0){30}}
\end{picture}
\end{minipage}
\caption{Here is my caption.}
\end{figure}
\lipsum[2]
\end{document}
You're stating too big a bounding box for the picture; moreover you're forgetting the empty argument for the empty boxes. Note that \Large
doesn't take an argument.
\documentclass{article}
\usepackage{pict2e}
\begin{document}
\begin{figure}
\centering
\begin{picture}(90,90)
\put(0,0){\framebox(30,30){}}
\put(30,0){\framebox(30,30){}}
\put(60,0){\framebox(30,30){}}
\put(0,30){\framebox(30,30){}}
\put(30,30){\framebox(30,30){}}
\put(60,30){\framebox(30,30){\Large\#}}
\put(0,60){\framebox(30,30){\Large\#}}
\put(30,60){\framebox(30,30){\Large\#}}
\put(60,60){\framebox(30,30){\Large\#}}
\put(15,45){\vector(1,0){30}}
\end{picture}
\caption{A picture}
\end{figure}
\end{document}
There is no problem with more than one picture:
\documentclass{article}
\usepackage{pict2e}
\begin{document}
\begin{figure}
\centering
\begin{picture}(90,90)
\put(0,0){\framebox(30,30){}}
\put(30,0){\framebox(30,30){}}
\put(60,0){\framebox(30,30){}}
\put(0,30){\framebox(30,30){}}
\put(30,30){\framebox(30,30){}}
\put(60,30){\framebox(30,30){\Large\#}}
\put(0,60){\framebox(30,30){\Large\#}}
\put(30,60){\framebox(30,30){\Large\#}}
\put(60,60){\framebox(30,30){\Large\#}}
\put(15,45){\vector(1,0){30}}
\end{picture}\qquad
\begin{picture}(90,90)
\put(0,0){\framebox(30,30){}}
\put(30,0){\framebox(30,30){}}
\put(60,0){\framebox(30,30){}}
\put(0,30){\framebox(30,30){}}
\put(30,30){\framebox(30,30){}}
\put(60,30){\framebox(30,30){\Large\#}}
\put(0,60){\framebox(30,30){\Large\#}}
\put(30,60){\framebox(30,30){\Large\#}}
\put(60,60){\framebox(30,30){\Large\#}}
\put(15,45){\vector(1,0){30}}
\end{picture}
\caption{A picture}
\end{figure}
\end{document}
A better way to draw the picture is using lines instead of boxes: this avoids the “doubling” of the inner lines.
\documentclass{article}
\usepackage{pict2e}
\begin{document}
\begin{figure}
\centering
\begin{picture}(90,90)
\polygon(0,0)(90,0)(90,90)(0,90)
\put(30,0){\line(0,1){90}}
\put(60,0){\line(0,1){90}}
\put(0,30){\line(1,0){90}}
\put(0,60){\line(1,0){90}}
\put(15,75){\makebox(0,0){\Large\#}}
\put(45,75){\makebox(0,0){\Large\#}}
\put(75,75){\makebox(0,0){\Large\#}}
\put(75,45){\makebox(0,0){\Large\#}}
\put(15,45){\vector(1,0){30}}
\end{picture}
\caption{A picture}
\end{figure}
\end{document}
Note how the border is drawn with \polygon
.