Introduction
TikZ is LaTeX’s powerful drawing library. While dedicated CAD software handles professional architectural work, TikZ is excellent for creating clean technical diagrams, floor plan sketches, system architecture diagrams, and annotated drawings directly in your LaTeX documents โ no external tools needed.
Basic Setup
\documentclass{article}
\usepackage{tikz}
\usepackage{siunitx} % for units like \SI{5}{\meter}
\begin{document}
\begin{tikzpicture}
% your drawing here
\end{tikzpicture}
\end{document}
Drawing Walls and Rooms
\begin{tikzpicture}[scale=0.5]
% Outer walls (thick)
\draw[line width=2pt] (0,0) rectangle (20,15);
% Interior walls
\draw[line width=1.5pt] (10,0) -- (10,15); % vertical divider
\draw[line width=1.5pt] (0,8) -- (10,8); % horizontal divider
% Room labels
\node[font=\large] at (5,4) {Living Room};
\node[font=\large] at (15,7.5) {Bedroom};
\node[font=\large] at (5,11.5) {Kitchen};
\end{tikzpicture}
Adding Doors and Windows
\begin{tikzpicture}[scale=0.5]
% Room outline
\draw[line width=2pt] (0,0) rectangle (12,10);
% Door: gap in wall + arc showing swing
\draw[line width=2pt] (3,0) -- (5,0); % gap in bottom wall
\draw[dashed] (3,0) arc (180:90:2); % door swing arc
% Window: double line on wall
\draw[line width=2pt] (7,10) -- (10,10); % gap
\draw (7,10.2) -- (10,10.2); % window line
\draw (7,9.8) -- (10,9.8); % window line
\node at (6,5) {Room};
\end{tikzpicture}
Dimension Annotations
\usetikzlibrary{arrows.meta, decorations.pathreplacing}
\begin{tikzpicture}[scale=0.5]
\draw[line width=2pt] (0,0) rectangle (10,8);
% Horizontal dimension
\draw[|<->|, >=Latex] (0,-1.5) -- (10,-1.5)
node[midway, below] {\SI{5}{\meter}};
% Vertical dimension
\draw[|<->|, >=Latex] (-1.5,0) -- (-1.5,8)
node[midway, left] {\SI{4}{\meter}};
\node at (5,4) {Office};
\end{tikzpicture}
Full Floor Plan Example
\begin{tikzpicture}[scale=0.4]
% === Outer walls ===
\draw[line width=3pt] (0,0) rectangle (24,18);
% === Interior walls ===
\draw[line width=2pt] (12,0) -- (12,10); % main divider (lower)
\draw[line width=2pt] (0,10) -- (24,10); % horizontal divider
\draw[line width=2pt] (16,10) -- (16,18); % upper right divider
% === Doors (gaps + arcs) ===
% Front door
\draw[line width=3pt, white] (5,0) -- (7,0);
\draw[dashed, thin] (5,0) arc (180:90:2);
% Interior door 1
\draw[line width=2pt, white] (12,5) -- (12,7);
\draw[dashed, thin] (12,5) arc (270:360:2);
% === Windows ===
\foreach \x in {2,9,18,21} {
\draw[line width=2pt, white] (\x,18) -- (\x+2,18);
\draw (\x,18.15) -- (\x+2,18.15);
\draw (\x,17.85) -- (\x+2,17.85);
}
% === Room labels ===
\node[font=\normalsize\bfseries] at (6,5) {Living Room};
\node[font=\normalsize\bfseries] at (18,5) {Bedroom 1};
\node[font=\normalsize\bfseries] at (6,14) {Kitchen};
\node[font=\normalsize\bfseries] at (20,14) {Bedroom 2};
% === Dimensions ===
\draw[|<->|, >=latex, thin] (0,-2) -- (24,-2)
node[midway, below] {\SI{12}{\meter}};
\draw[|<->|, >=latex, thin] (-2,0) -- (-2,18)
node[midway, left, rotate=90] {\SI{9}{\meter}};
\end{tikzpicture}
System Architecture Diagrams
TikZ is also excellent for software architecture diagrams:
\usetikzlibrary{shapes.geometric, arrows.meta, positioning}
\tikzstyle{box} = [rectangle, rounded corners, draw, fill=blue!10,
minimum width=3cm, minimum height=1cm, text centered]
\tikzstyle{db} = [cylinder, draw, fill=green!10,
minimum width=2cm, minimum height=1.5cm, text centered]
\tikzstyle{arrow} = [->, >=Stealth, thick]
\begin{tikzpicture}[node distance=2cm]
% Nodes
\node[box] (client) {Web Browser};
\node[box, below of=client] (lb) {Load Balancer};
\node[box, below left of=lb] (app1) {App Server 1};
\node[box, below right of=lb] (app2) {App Server 2};
\node[db, below of=app1, xshift=1.5cm] (db) {Database};
\node[box, right of=db] (cache) {Redis Cache};
% Arrows
\draw[arrow] (client) -- (lb);
\draw[arrow] (lb) -- (app1);
\draw[arrow] (lb) -- (app2);
\draw[arrow] (app1) -- (db);
\draw[arrow] (app2) -- (db);
\draw[arrow] (app1) -- (cache);
\draw[arrow] (app2) -- (cache);
\end{tikzpicture}
Network Diagrams
\usetikzlibrary{shapes.symbols, positioning}
\begin{tikzpicture}[node distance=3cm,
server/.style={rectangle, draw, fill=gray!20, minimum size=1.2cm},
client/.style={circle, draw, fill=blue!20, minimum size=1cm}]
\node[server] (internet) {Internet};
\node[server, below of=internet] (firewall) {Firewall};
\node[server, below of=firewall] (router) {Router};
\node[client, below left of=router] (pc1) {PC 1};
\node[client, below of=router] (pc2) {PC 2};
\node[client, below right of=router] (pc3) {PC 3};
\draw[thick] (internet) -- (firewall);
\draw[thick] (firewall) -- (router);
\draw[thick] (router) -- (pc1);
\draw[thick] (router) -- (pc2);
\draw[thick] (router) -- (pc3);
\end{tikzpicture}
Useful TikZ Libraries for Technical Drawings
\usetikzlibrary{
arrows.meta, % modern arrow tips
shapes.geometric, % rectangles, circles, etc.
shapes.symbols, % cloud, cylinder, etc.
positioning, % relative positioning (above of=, right of=)
decorations.pathreplacing, % braces, etc.
calc, % coordinate calculations
fit, % fit node around other nodes
matrix, % matrix of nodes
backgrounds % draw behind nodes
}
Tips for Clean Diagrams
% Use a consistent scale
\begin{tikzpicture}[scale=0.5, every node/.style={font=\small}]
% Define styles once, reuse everywhere
\tikzset{
wall/.style={line width=2pt},
dim/.style={|<->|, >=Latex, thin, gray},
label/.style={font=\small\bfseries}
}
% Use coordinates for complex layouts
\coordinate (A) at (0,0);
\coordinate (B) at (10,0);
\draw[wall] (A) -- (B);
% Grid for alignment during development (remove for final)
\draw[gray!30, very thin] (0,0) grid (20,15);
Resources
- TikZ & PGF Manual โ comprehensive reference
- TikZ Examples โ gallery of diagrams
- TikZ for Architects โ practical examples
- PGFPlots โ for data plots and charts
Comments