Recently, I needed to do this kind of drawing and that's what I used (I think I made a mix between codes from Jake, Martin and me. Missing cases where dimensions are small. I kept all the code to show the result. The third argument wit dim
can b used to place the label (right, left etc.)
\documentclass[11pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{ arrows, calc,decorations,decorations.markings,decorations.text}
\pgfkeys{/pgf/decoration/.cd, distance/.initial = 10pt}
\pgfdeclaredecoration{add dim}{final}{
\state{final}{%
\pgfmathsetmacro{\dist}{\pgfkeysvalueof{/pgf/decoration/distance}}
\pgfpathmoveto{\pgfpoint{0pt}{0pt}}
\pgfpathlineto{\pgfpoint{0pt}{1.5*\dist}}
\pgfpathmoveto{\pgfpoint{\pgfdecoratedpathlength}{0pt}}
\pgfpathlineto{\pgfpoint{(\pgfdecoratedpathlength}{1.5*\dist}}
\pgfsetarrowsstart{latex}
\pgfsetarrowsend{latex}
\pgfpathmoveto{\pgfpoint{0pt}{\dist}}
\pgfpathlineto{\pgfpoint{\pgfdecoratedpathlength}{\dist}}
\pgfusepath{stroke}
\pgfpathmoveto{\pgfpoint{0pt}{0pt}}
\pgfpathlineto{\pgfpoint{\pgfdecoratedpathlength}{0pt}}
}}
\tikzset{
dim/.style args={#1,#2,#3}{%
decoration = {add dim,distance=\ifx&0pt\else#2\fi},
decorate,
postaction = {%
decorate,
decoration={%
raise=\ifx&0pt\else#2\fi,
markings,
mark=at position .5 with {\node[inner sep=2pt,
font=\footnotesize,
fill=\ifx&none\else white\fi,
#3] at (0,0) {#1};}
}
}
},
dim/.default={,0pt,}
}
\tikzset{add reference/.style={insert path={%
coordinate [pos=0] (#1 south west)
coordinate [pos=1] (#1 north east)
coordinate [pos=.5] (#1 center)
(#1 south west |- #1 north east) coordinate (#1 north west)
(#1 center |- #1 north east) coordinate (#1 north)
(#1 center |- #1 south west) coordinate (#1 south)
(#1 south west -| #1 north east) coordinate (#1 south east)
(#1 center -| #1 south west) coordinate (#1 west)
(#1 center -| #1 north east) coordinate (#1 east)
}}}
\tikzset{pt/.style={circle,fill=#1,inner sep=0mm,minimum size=4pt}}
\begin{document}
\begin{tikzpicture}
\path (0,0) coordinate (O)
(5,8) coordinate (pt upper left);
\draw (O) rectangle (pt upper left) [add reference=R];
\draw[dashed] (R north) -- (R south)
(R west) -- (R east);
\node[circle,draw,inner sep=0pt,minimum size=6pt,outer sep=1pt] (pt center) at (R center) {};
\node[circle,fill,inner sep=0pt,minimum size=6pt,outer sep=1pt] (pt base) at (0,2) {};
\draw[dotted] (pt base) -- ++(7,0);
\path[dim={totalheight,10ex,}] (R north east) -- (R south east);
\path[dim={height,5ex,left}] (R north east) -- (pt base -| R south east);
\path[dim={depth,5ex,}] (pt base -| R south east) -- (R south east);
\path[dim={width,-4ex,}] (R south west) -- (R south east);
\node[font=\footnotesize](line base) at (1.25,1){\emph{ligne de base}};
\draw [->,>=latex'] (line base) to [bend right](2,2);
\node[font=\footnotesize,text width=2cm](pt ref) at (-1.5,.5){\emph{point de\\référence}};
\draw [->,>=latex'] (pt ref) to [bend left](pt base);
\node[font=\footnotesize](lines cent) at (1.25,6){\emph{lignes centrales}};
\draw [->,>=latex'] (lines cent) edge [bend right] (2.5,5)
edge [bend right] (1.5,4);
\node[font=\footnotesize](pt cent) at (4,3){\emph{point central}};
\draw [->,>=latex'] (pt cent) to [bend right](pt center);
\node[above] at (R north) {[\texttt{t}]};
\node[above left] at (R north west) {[\texttt{lt}]};
\node[above right] at (R north east) {[\texttt{rt}]};
\node[below] at (R south) {[\texttt{b}]};
\node[below left] at (R south west) {[\texttt{lb}]};
\node[below right] at (R south east) {[\texttt{rb}]};
\node[above right] at (R center) {[\texttt{c}]};
\node[left] at (R west) {[\texttt{lc}]};
\node[right] at (R east) {[\texttt{rc}]};
\node[above right] at ([xshift=2.5cm]pt base) {[\texttt{B}]};
\node[above left] at (pt base) {[\texttt{lB}]};
\node[above right] at ([xshift=5cm]pt base) {[\texttt{rB}]};
\end{tikzpicture}
\end{document}

\pi^2
longer than expected:).