🏠 Back Home | 📚 Publications | ✉️ Contact | 📝 Blog
LaTeX Workshop
extension are recommended.- Why Inkscape?
- Workflow in a Nutshell
- Extensions for Power Users
- Installation Instructions
- Description of the Workflow
- Example
Why Inkscape?
An image is worth a thousand words. It is universally accepted that an illustrative and powerful image enhances the quality of a talk and helps convey an article’s message. However, (electrical) engineers are not graphical designers, and aesthetics leave too much behind in scientific and technical works.
When asked why not invest time in improving the quality of their renders, most (electrical) engineering professionals say “they have no time” to dedicate to TikZ, perhaps the most widespread -based library in mathematics and exact sciences for creating artworks. The scope of this blog post is to socialize my personal approach to draft vector-quality graphs using Inkscape, an open-source vector designer tool.
In this blog post, you will learn how to set up Inkscape adding vectorized circuit symbols to draw diagrams like the one shown below.
Workflow in a Nutshell
- Images are drafted using Inkscape functionality.
- Mathematical equations are embedded as text objects.
- is used to render the mathematical equation metadata into a
*.pdf
file, generated by compiling a standalone TeX document.
Extensions for Power Users
It is possible to automate the presented workflow using Vim or VSCode. I leave a couple of references below.
- Gilles Castel’s (RIP) approach relies on Vim.
- I found
sleepymalc
's instructions difficult to follow; besides, I could not replicate them fully on macOS (and the approach did not work on Windows).
Installation Instructions
- Download and install Inkscape from the official website (below). The installer is available as an
*.msi
file for Windows. - Get the
*.svg
file forcircuitikz
symbols from the following GitHub repository. - Navigate to the Inkscape local roaming directory.
- Restart Inkscape (or launch it if it is not open). Go to
Object
→Symbols
(Windows:Shift
+Ctrl
+Y
; macOS:Shift
+Cmd
+Y
) in a new document. Look for theCircuitTikZ Electrical Symbols
option in the dropdown list.
In macOS, the installation can be done via brew
(recommended).
If the repository above does not work, a (possibly outdated) copy is available below.
Windows: if the local disk is the C:\
unit, then the path to the inkscape
folder should be as follows:
C:\\Users\\%USERNAME%\\AppData\\Roaming\\inkscape
Create a new folder called symbols
(if it does not exist yet). Paste the circuitikz *.svg
file inside the new directory.
macOS: open a terminal and query the path to the Inkscape installation.
inkscape --user-data-directory
For Inkscape >1.X and macOS >12.0, the path should be as follows:
ls~/Library/Application Support/org.inkscape.Inkscape/config/inkscape/
The CircuiTikZ
symbols will be available as drag-and-drop objects that can be placed directly into the drawing canvas.
Description of the Workflow
The approach to drawing figures is as follows.
- Sketching is done with Inkscape.
- Text objects (e.g., labels, titles, and legends) are also added to the diagram on the Inkscape canvas.
- When the figure is ready, export the figure as a
*.pdf
file to the destination folder. Make sure the optionOmit text in PDF and create LaTeX file
is checked under the available options (unchecked by default). A*.pdf
and a*.pdf_tex
file will be generated on the desired output directory by clicking onExport
. The figure needs both files (i.e., the*.pdf
and the*.pdf_tex
).
If LaTeX rendering is required, it is suggested to “encapsulate” the LaTeX commands within brackets. For instance, if we want to add the legend , we would add the following text in Inkscape.
{$\left\vert V_g \right\vert = 2.0 \ \text{pu}$}
The text will not be rendered on Inkscape. However, it will be recognized by a LaTeX compiler when using the associated *.pdf_tex
file (see below).
*.pdf_tex
and the *.pdf
files are in the same directory, the *.pdf_tex
file might be treated as an “image” file and used within floating objects such as Figures.- The following template can be used to generate a
*.pdf
containing the complete figure by compiling a LaTeX file. The use of the standalone class produces a document whose size adjusts to the exact extent of the figure.
\documentclass{standalone}
\usepackage{newtxtext}
\usepackage[T1]{fontenc}
\usepackage{import}
\usepackage{xifthen}
\usepackage{pdfpages}
\begin{document}
% \def\svgwidth{\columnwidth}
\import{./Figures/}{fig_LODF-illustration.pdf_tex}
\end{document}
Example
The goal of this example is to draft the figure shown below.
For reference, a copy of the source Inkscape file is provided below.
- Create a new Inkscape document.
- Right-click the drawing canvas and go do
Document Properties
. Change the units in theFront page
menu to inches (in
). Then, set the page width to 3.5 inches (which is the column width in IEEE double-column format). Also, change theDisplay units
to inches. - Drag and drop the following components from the
CircuiTikZ Electrical Symbols
library. american_inductor
ground
oscillator
resistor
polar_capacitor
- Connect the elements as per the example image above. Note the following.
- The snapping option has been enabled in the top right corner. Below it is shown where to enable it in the graphical interface.
- All the objects are rescaled, holding
Ctrl
to preserve their individual aspect ratios. - The line width is set to 1.0 pt under Stroke style (Width property).
- The buses are created using the path tool with a line width of 2.0 pt.
- Add the text labels as shown in the image above. Use text objects to do so. Note that:
- The text alignment shall be set to center before the text content is input.
- The equations shall be included within brackets and inline delimiters (i.e.,
$$
). - The position of the text shall be set according to the object center, not the text extent as shown in Inkscape (it is misleading).
- The text color can be changed from Inkscape. The text fill corresponds to the color rendered in . It is recommended to set the text stroke to transparent.
- When the text is complete, right-click the canvas and go to
Document Properties
again. Click theResize to content
button to adjust the height and width of the objects in the canvas. Then, set the figure width to 3.5 inches. - Go to
File
→Export
(Windows:Ctrl + Shift + E
; macOS:Shift
+Cmd
+E
). In the new menu, - Change the file format to
*.pdf
. - Set the DPI size to 300 (it defaults to 96).
- Click the wheel icon.
- In the
Export Format Options
window, enable theOmit text in PDF and create LaTeX file
option (disabled by default). - Export the figure by clicking on the
Export
button. This will generate two files. A*.pdf
containing the artwork and a*.pdf_tex
file with the text objects and their relative coordinates concerning the*.pdf
. - Create a new document. Note that if placed in the same directory as the
*.pdf_tex
and*.pdf
files from step 8, the name of the file must be different than that of the*.svg
document. The contents of the*.tex
file shall be as follows. - Building and compiling the
*.tex
file in Step 9 generates a*.pdf
file containing the artwork (i.e., the graphics and the text). Such a file can be used in documents, PowerPoint presentations, and Overleaf projects.
*.pdf_tex
and *.pdf
names are the same as the Inkscape document.You might change the output directory (i.e., it need not be the same as the path where the *.svg
Inkscape file is saved).
\documentclass{standalone}
\usepackage{newtxtext}
\usepackage[T1]{fontenc}
\usepackage{import}
\usepackage{xifthen}
\usepackage{pdfpages}
\begin{document}
% \def\svgwidth{\columnwidth}
\import{./}{example_single-line-diagram.pdf_tex}
\end{document}
*.pdf_tex
and the *.pdf
files are in the same directory as the *.tex
file. Otherwise, the absolute path shall be passed as the first argument to the \import
command.LuaLaTeX
.*.pdf_tex
and *.pdf
files from step 8 are in the same directory, the command \import{}
can be used within an Overleaf project (the commented line in the code snippet above controls the width of the rendered image).2024 © Sergio A. Dorado-Rojas