I want to add a frame to a picture. i start to draw the picture by tikz. after drawing, it is the time adding frame. now, how can i know the following two points to add the frame, assuming that frame's width is equal to the page's width:
- how can i get the lower left corner's coordinate of the picture?
- how can i get how high the picture is?
if i have these two points, i can draw a rectangle for the frame. or is any other way to realize this purpose?
@Thorsten: just adding fbox
seemed not to be enough.
\documentclass[titlepage,a4paper]{article}
\usepackage{tikz}
\usepackage[lmargin=2.500000cm,rmargin=2.500000cm,tmargin=2.500000cm,bmargin=2.500000cm]{geometry}
\begin{document}
\section[General remarks]{General remarks}
\subsection[Geometry and coordinate system]{Geometry and coordinate system}
The main layout of the structure is adopted:\\
\fbox{
\begin{tikzpicture}[scale=1,thick]
\useasboundingbox (0,0) rectangle (70mm,5);
\begin{scope}[shift={(20mm,0)}]
\foreach \xoffset in {0,5.2}
{
\begin{scope}[shift={(\xoffset,0)}]
\draw[xstep=1,ystep=1] (0,0) grid (5,5);
\end{scope}
}
\end{scope}
\end{tikzpicture}
}
\end{document}
based on Martin
's comment, following code is added. as a newbie, it took me some time to find a way to add some spacing around picture. so this might save time for other newbies.
\documentclass[titlepage,a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage[lmargin=2.500000cm,rmargin=2.500000cm,tmargin=2.500000cm,bmargin=2.500000cm]{geometry}
\begin{document}
\section[General remarks]{General remarks}
\subsection[Geometry and coordinate system]{Geometry and coordinate system}
The main layout of the structure is adopted:\\
\begin{tikzpicture}[scale=1,thick]
\begin{scope}[shift={(20mm,0)}]
\foreach \xoffset in {0,5.2}
{
\begin{scope}[shift={(\xoffset,0)}]
\draw[xstep=1,ystep=1] (0,0) grid (5,5);
\end{scope}
}
\end{scope}
\coordinate (B) at (current bounding box.south west);
\draw[line width=10pt]
let
\p2 = ($(B) - (10mm,10mm)$)
in
(current bounding box.north east) ++(10mm,10mm) rectangle (\p2);
\end{tikzpicture}
\end{document}
another method uses backgrounds
. please refer to Andrew
's comment at the below.
\hspace*{2cm}
instead then the box given by fbox would be nicer than in your picture.