A TikZ command set for structural and material mechanics drawings.
structmech turns a handful of node coordinates into the diagrams you would otherwise draw by hand: member forces, nodal forces and displacements, boundary conditions, internal force distributions, deformed shapes, and more β usually with one single command.
\documentclass{article}
\usepackage{structmech}
\begin{document}
\begin{tikzpicture}
\FixedSupport{0,0}
\BasicForce{0,0}{5,0}{M}
\UDL{0,0}{5,0}[10]
\end{tikzpicture}
\end{document}- Member forces & displacements β
\BasicForcedraws axial force, and/or end bending moments (or all three) on a member, with optional labels for each component. - Nodal forces & displacements β
\NodalForcedraws horizontal, vertical, and rotational arrow quantities at a node, rotated and scaled as needed. - Loads β
\UDLdraws uniformly distributed loads on any member, including inclined ones, with flip and scaling support. - Supports β
\HingeSupport,\FixedSupport,\RollerSupport,\SliderSupport,\SleeveSupport, and\Rigid, all rotatable and scalable. - Internal force diagrams β
\IForceAfor linear distributions and\IForceBfor parabolic ones (e.g. bending moments under a UDL). - Deformed shapes β
\BeamDeformP(perpendicular translation + rotation) and\BeamDeformR(rotation only). - Extras β
\Spring,\Dashpot, and\CoorOriginfor coordinate system frames. - Consistent styling β colours, sign convention, value labels, opacity, and line width are controlled globally via package options or
\setstructmech{...}, so a whole figure can be restyled without touching individual commands.
From CTAN or your TeX distribution:
tlmgr install structmechOr simply copy structmech.sty next to your .tex file. It depends only on standard packages: tikz, kvoptions, xkeyval, xparse, and xstring.
Load the package with optional keyβvalue settings:
\usepackage[axis=red,convention=direction,opacity=.4]{structmech}| Option | Values | Purpose |
|---|---|---|
fill |
colour | Fill patch colour (loads, rigid constraints, diagrams) |
line |
colour | Line colour |
node |
colour | Nodal force/displacement colour |
axis |
colour | Axial force/displacement colour |
rotation |
colour | Rotational force/displacement colour |
convention |
sign / direction |
Draw all quantities positively with a minus sign, or draw negatives in the negative direction with positive labels |
showvalue |
on / off |
Show values on internal force diagrams |
absvalue |
on / off |
Show absolute values on internal force diagrams |
opacity |
number (default 0.4) |
Fill patch opacity |
linewidth |
dimension (default 0.4mm) |
Line width |
Settings can be changed anywhere in the document:
\setstructmech{axis=red,linewidth=.6mm}| Command | Draws |
|---|---|
\NodalForce |
Nodal force/displacement arrows |
\BasicForce |
Member axial force and/or end moments |
\UDL |
Uniformly distributed load |
\HingeSupport, \FixedSupport, \RollerSupport, \SliderSupport |
Standard supports |
\SleeveSupport, \Rigid |
Sleeve support and rigid constraint |
\IForceA, \IForceB |
Linear and parabolic internal force diagrams |
\BeamDeformP, \BeamDeformR |
Beam deformation shapes |
\Spring, \Dashpot |
Spring and dashpot elements |
\CoorOrigin |
Coordinate system frame |
The full manual, with the syntax, every optional argument, and worked examples for each command, is included in this repository:
- structmech.pdf β compiled manual (also available on CTAN)
- structmech.tex β manual source, which doubles as a test file for every command
Note that internal forces follow the sign convention adopted in the finite element method rather than the one used in material mechanics; all quantities are defined in the local coordinate system. See the manual for details.
Contributions are welcome β feel free to redistribute, extend, or rewrite the functionality. Open an issue or a pull request at TLCFEM/structmech.
Copyright Β© 2018β2023 Theodore Chang.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.