-- New -- Horizontal and vertical cotations.
\documentclass{article}
\usepackage{xparse,tikz}
\usetikzlibrary{calc}
\RequirePackage{pdftexcmds}
\makeatletter
\let\pdfstrcmp\pdf@strcmp
\let\pdffilemoddate\pdf@filemoddate
\tikzset{%
Cote node/.style={%
midway,
%sloped,
fill=white,
inner sep=1.5pt,
outer sep=2pt
},
Cote arrow/.style={%
<->,
>=latex,
very thin
}
}
\makeatletter
\NewDocumentCommand{\Cote}{%
s % cotation avec les flèches à l'extérieur
D<>{1.5pt} % offset des traits
O{.75cm} % offset de cotation
m % premier point
m % second point
m % étiquette
D<>{o} % () coordonnées -> angle
% h -> horizontal,
% v -> vertical
% o or what ever -> oblique
O{} % parametre du tikzset
}{%
{\tikzset{#8}
\coordinate (@1) at #4 ;
\coordinate (@2) at #5 ;
\if #7H % Cotation traits horizontaux
\coordinate (@0) at ($($#4!.5!#5$) + (#3,0)$) ;
\coordinate (@5) at ($#5+(#3,0)$) ;
\coordinate (@4) at ($#4+(#3,0)$) ;
\else
\if #7V % Cotation traits verticaux
\coordinate (@0) at ($($#4!.5!#5$) + (#3,0)$) ;
\coordinate (@5) at ($#5+(0,#3)$) ;
\coordinate (@4) at ($#4+(0,#3)$) ;
\else
\if #7v % Cotation verticale
\coordinate (@0) at ($($#4!.5!#5$) + (#3,0)$) ;
\coordinate (@4) at (@0|-@1) ;
\coordinate (@5) at (@0|-@2) ;
\else
\if #7h % Cotation horizontale
\coordinate (@0) at ($($#4!.5!#5$) + (0,#3)$) ;
\coordinate (@4) at (@0-|@1) ;
\coordinate (@5) at (@0-|@2) ;
\else % cotation encoche
\ifnum\pdfstrcmp{\unexpanded\expandafter{\@car#7\@nil}}{(}=\z@
\coordinate (@5) at ($#7!#3!#5$) ;
\coordinate (@4) at ($#7!#3!#4$) ;
\else % cotation oblique
\coordinate (@5) at ($#5!#3!90:#4$) ;
\coordinate (@4) at ($#4!#3!-90:#5$) ;
\fi\fi\fi\fi\fi
\draw[very thin,shorten >= #2,shorten <= -2*#2] (@4) -- #4 ;
\draw[very thin,shorten >= #2,shorten <= -2*#2] (@5) -- #5 ;
\IfBooleanTF #1 {% avec étoile
\draw[Cote arrow,-] (@4) -- (@5)
node[Cote node] {#6\strut};
\draw[Cote arrow,<-] (@4) -- ($(@4)!-6pt!(@5)$) ;
\draw[Cote arrow,<-] (@5) -- ($(@5)!-6pt!(@4)$) ;
}{% sans étoile
\ifnum\pdfstrcmp{\unexpanded\expandafter{\@car#7\@nil}}{(}=\z@
\draw[Cote arrow] (@5) to[bend right]
node[Cote node] {#6\strut} (@4) ;
\else
\draw[Cote arrow] (@4) -- (@5)
node[Cote node] {#6\strut};
\fi
}}
}
\makeatother
\begin{document}
\begin{tikzpicture}
\small
\draw[thick,blue,fill=blue!25]
(0,1) coordinate (A)
-- (3,1) coordinate (B)
-- (5,2) coordinate (C)
-- (5,4) coordinate (D)
-- (3,4) coordinate (E)
-- (2.5,3) coordinate (F)
-- (2,4) coordinate (G)
-- (0,4) coordinate (H)
--cycle ;
\draw[red,fill=red!25] (2.5,3.9) circle (.39) ;
\Cote{(A)}{(B)}{1}
\Cote{(B)}{(C)}{2}[red]
\Cote[.3cm]{(B)}{(C)}{2}[%
red,Cote node/.append style={sloped}]]
\Cote{(B)}{(C)}{2 bis}<h>[Cote node/.append style={fill=blue!25}]
\Cote[.3cm]{(C)}{(D)}{3 bis}[%
Cote node/.append style={rotate=-90}]
\Cote[.7cm]{(C)}{(D)}{3}
\Cote[1.1cm]{(C)}{(D)}{3 ter}[%
Cote node/.append style={right}]
\Cote[2cm]{(G)}{(E)}{?$^\circ$}<(F)>
\Cote*[1.2cm]{(2.11,3.9)}{(2.89,3.9)}{4}[%
Cote node/.append style={left=.6cm,fill=blue!25}]
\Cote[-2cm]{(A)}{(2.5,4.29)}{5}<v>
\end{tikzpicture}
\bigskip
\begin{tikzpicture}
\draw[thick,blue,fill=blue!25]
(0,0) coordinate (A)
-- (2,2) coordinate (B)
-- (2,4) coordinate (C)
-- (0,2) coordinate (D)
--cycle ;
\Cote[.5]{(A)}{(B)}{5}<H>
\Cote[.5]{(D)}{(C)}{5}<V>
\end{tikzpicture}
\end{document}
\documentclass{article}
\usepackage{graphics}
\begin{document}
\fbox{\begin{picture}(200,200)
\thicklines
\put(100,10){\line(0,1){180}}
\put(10,100){\line(1,0){180}}
\put(100,190){\makebox(0,0)[b]{\textsc{TiKZ}}}
\put(100,10){\makebox(0,0)[t]{\textsc{PsTricks}}}
\put(10,100){\makebox(0,0)[r]{\rotatebox{90}{\textsc{Picture Mode}}}}
\put(190,100){\makebox(0,0)[l]{\rotatebox{-90}{\textsc{MetaPost}}}}
\put(50,150){\makebox(0,0){Easy}}
\put(150,150){\makebox(0,0){Hard}}
\put(50,50){\makebox(0,0){Clear}}
\put(150,50){\makebox(0,0){Obscure}}
\end{picture}}
\end{document}
Best Answer
I doubt that there is a special solution for your CAD-files. I include technical drawing in my documents rather often and use
\includepdf[options]{file}
together with PDF-files. They will give you vectorized drawings. You will need thepdfpages
-package.Here is a short example for this:
Please note that this will only work using
pdflatex
. If you insist on usinglatex
you will have to convert the PDFs to EPS-files and include them via\includegraphics[...]{...}
. Nevertheless this will give you vectorized graphics as well.You could also use
media9
-package, but this will force the reader to use Adobe. This might not be intended (thanks AlexG for the suggestion).