Draw Block Diagrams and Use Them In LaTeX

  • Aktualisiert
  • Veröffentlicht in Technical
  • 4 Minuten zum Lesen

[latexpage]

A block diagram is to be drawn, this is to be integrated in a second step as a vector graphic in a LaTeX document and the texts in the illustration are to be replaced by other texts in the LaTeX font. These blocks should be aligned horizontally/vertrically and their distances to each other should be even.
For this purpose, the free application yEd is used, which generates an EPS file with embedded plain text after creating the figure. The LaTeX command psfrag then replaces the texts in said EPS file when translating the TEX document.

The Application yEd

The free application yEd for Windows, Linux and macOS let’s you draw block diagrams. These can be found i.e. in scientific articles on topics of control engineering:

EPS figure created by yEd , include in a LaTeX document and text replaces with psfrag

yEd allows you to align elements like blocks to each other, set their distances evenly and draw connecting lines anchored to these blocks. By this anchoring they are redrawn when a element is moved.

While moving elements with the mouse, yEd displays anchor lines when a moved element is aligned relative to another horizontally, vertically, or in its distance from other elements:

Drawing with yEd: Button for vertical connection lines and anchoring when moving blocks for alignment

When the yEd figures are exported properly as EPS files the contained text can be modified when the figures are included in a LaTeX document. By that their the text can be set in the LaTeX font and the content of the text elements can be changed without re-exporting a new EPS file.

Embedding into a LaTeX document

This section describes, how

  • text within a figure can be modified with LaTeX after a n EPS figure was exported by yEd and how
  • yEd figures are saved properly as EPS files.

Including the EPS File in LaTeX and Replacing the Text

The figures are exported by yEd (as EPS files) and included in a LaTeX document. While including them in figure containers the contained text ismodified using the psfrag command:

[/latexpage]

\psfrag{Modell}[tc][tc][0.75]{\scalebox{1}[-1]{Model}}

[latexpage]

It’s parametrs are:

  • Modell: Text, as it can be found in the EPS figure and which is to be replaced.
  • [tc][tc]: At the top-center corner of the original text box the top-center corner of the new textbox will be placed.
  • [0.75]: Scale the font size by the factor 0.75.
  • \scalebox{1}[-1]{Model}: Replace the original text with text within a text box which is rotated by 180°.

Also the package psfrag must be included:

[/latexpage]

\usepackage{psfrag}

In total this is how the figurter is included in LaTex:

\begin{figure}[htbp]
  \centering
  
  \psfrag{Inverses}[tc][tc][0.75]{\scalebox{1}[-1]{Inverses}}
  \psfrag{Modell}[tc][tc][0.75]{\scalebox{1}[-1]{Model}}
  \psfrag{DTM}[tc][tc][0.75]{\scalebox{1}[-1]{DTM}}
  \psfrag{modell}[tc][tc][0.75]{\scalebox{1}[-1]{model}}
  \psfrag{r}[tc][tc][0.75]{\scalebox{1}[-1]{\$\boldsymbol{r}_{{\rm{dgl}}}\$}}
  \psfrag{x}[tc][tc][0.75]{\scalebox{1}[-1]{\${\boldsymbol{x}}\$}}
  \psfrag{u}[tc][tc][0.75]{\scalebox{1}[-1]{\${\boldsymbol{u}}\$}}
  \psfrag{y}[tc][tc][0.75]{\scalebox{1}[-1]{\${\boldsymbol{y}_{{\rm{dgl}}}}\$}}
  \psfrag{K3}[tc][tc][0.75]{\scalebox{1}[-1]{\${\boldsymbol{K}_{{\rm{a}}}}\$}}
  \psfrag{K2}[tc][tc][0.75]{\scalebox{1}[-1]{\${\boldsymbol{K}_{{\rm{v}}}}\$}}
  \psfrag{K1}[tc][tc][0.75]{\scalebox{1}[-1]{\${\boldsymbol{K}_{{\rm{x}}}}\$}}
  \psfrag{s}[tc][tc][0.75]{\scalebox{1}[-1]{\${s}\$}}
  \psfrag{s2}[tc][tc][0.75]{\scalebox{1}[-1]{\${s^2}\$}}
  \psfrag{1s}[tc][tc][0.75]{\scalebox{1}[-1]{\${{1}/{s}}\$}}
  \psfrag{w}[tc][tc][0.75]{\scalebox{1}[-1]{\${\boldsymbol{w}}\$}}
  
  \includegraphics[scale=0.75]{../Abbildung/iFR/EALinBisis.eps}
  \label{fig:EALinBasis}
\end{figure}

[/latexpage]

Creating an EPS Properly In yEd

This is the unmodified EPS figure as it was exported by yEd:

EPS figure before applying psfrag

A location, a file name and the format EPS format is chosen for the figure:

In yEd it is exported via the menu item File -> Export:

To be able to modify the included texts using psfrag the option Text Rendering Policy -> Plain Text with embedded Fonts must be selected in the EPS tab.

20220828

Schreibe einen Kommentar