# LaTeX and 2D structural mechanics diagrams

Submitted by Nicola Rainiero on 2013-09-17 (last updated on 2017-04-09)

Sometimes it's necessary to add to your reports several drawings in order to facilitate the comprehension of the calculus and data. LaTeX can solve this issue without using any external software but only through the Graphics packages. I show you how TikZ-MEC, a custom library written by Francesco Clemente, can help in the description of mechanical problems related to (internally and externaly) loaded structures.

Since I had been written my master thesis, I wanted to understand how to instruct LaTeX for drawing directly, taking all the advantages of the "TeX-approach to Typesetting" for my graphics1:

• quick creation of simple graphics;
• precise positioning, quoting and scaling.

However only writing the small project for the Structure Standing Still: The Statics of Everyday Objects course promoted by Coursera and University of Florida, I have had the chance to learn and try TikZ and TikZ-MEC. In actual fact it exists and it's more complete: pst-stru, a PSTricks package to draw structural schemes in civil engineering analysis (beams, portals, archs, piles), yet it does not work with pdftex nor with any other driver that produces anything but PostScript code1, in fact it is necessary to use latex+dvips+ps2pdf in order to generate a PDF. Also in my opinion the learning curve is steeper and the code is more logical and readable than PSTricks.

 Project instructions: determine the design, the cost and the axial forces of a statically-determinate truss structure of your own design capable of supporting a 10 kN load hangingmidway across an 8 meter span (see figure above). My final project (a simple and common Warren truss structure)

As usual I put the instruction to install it in your system (Ubuntu and derivatives only) and the possibility to try it online thanks to writeLaTeX and an edited code written by John Lees-Miller2.

Read it on-line using writeLaTeX: TikZ-MEC Test

## Installation

Typically TikZ is included in the texlive-pictures3package, but if you want to use TikZ-MEC, you have to download it and following the instructions in the README.txt in order to generate the library file tikzlibrarymec.code.tex and the documentation file tikz-mec.pdf. Thus avoiding warnings and errors, I suggest you to install these packages: texlive-science3(it contains SIunits), cm-superand cm-super-minimal3. Although I have installed all the packages, I always obtained a lot of errors and warnings while generating the documentation file, but keep calm and carry on: I put this problematic PDF file in my repository on GitHub.

## How to learn it

The first impact with TikZ and TikZ-MEC is problematic, but if you read the Part I: Tutorials and Guidelines of the manual1, you can understand quickly the code and the power of this Graphics Package.

All the files of this article are in my GitHub repository: TikZ_MEC
• 1. a. b. c. TikZ and pgf - Manual for version 1.18 - downloadable here
• 2. Because at the moment writeLaTeX removes all but the last dot in file names (in order to avoid a bug in includegraphics with files that contain multiple dots) and so it also broke custom TikZ libraries like "tikzlibrarymec.code.tex" that becomes after uploading "tikzlibrarymec_code.tex".
• 3. a. b. c. d. In Ubuntu and derivatives a faster method to install packages is writing this command in the terminal:
sudo apt-get install PACKAGE_NAME

## Related Content:

### Nicola Rainiero

A civil geotechnical engineer with the ambition to facilitate own work with free software for a knowledge and collective sharing. Also, I deal with green energy and in particular shallow geothermal energy. I have always been involved in web design and 3D modelling.