412
edits
No edit summary |
No edit summary |
||
| Line 81: | Line 81: | ||
\tikzset{font={\fontsize{18pt}{10}\selectfont}} | \tikzset{font={\fontsize{18pt}{10}\selectfont}} | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Font size is an essential element and in LaTeX it is handled very much. The main concept to know is that the font used in LaTeX can vary a lot depending on its basic size. For example, a font 6 may differ from font 10 as the readability of a font changes. This fact makes a font package, such as the ORC-B, actually made up of various subpackages made according to size, but also bold, italic, etc .. | Font size is an essential element and in LaTeX it is handled very much. The main concept to know is that the font used in LaTeX can vary a lot depending on its basic size. For example, a font 6 may differ from font 10 as the readability of a font changes. This fact makes a font package, such as the ORC-B, actually made up of various subpackages made according to size, but also bold, italic, etc .. In this example, the first value {18} indicates the font size (in dot pt) that we want to display, while {10} is the size of the original font. | ||
<syntaxhighlight lang="latex"> | |||
\begin{document} ... \end{document} | |||
</syntaxhighlight> | |||
After so many things, the writing of the document begins, so what's inside the logical parentheses ''begin ... end'' will be compiled and possibly displayed. | |||
<syntaxhighlight lang="latex"> | |||
{\ocrfamily ... } | |||
</syntaxhighlight> | |||
It is another logical parenthesis that indicates that from now on you use the OCR family font, you can insert a different font family into a document. This function is certainly useful for very complex gauges that have embossed symbols or fonts with special features. | |||
<syntaxhighlight lang="latex"> | |||
\begin{tikzpicture}[xscale=0.05] | |||
</syntaxhighlight> | |||
Finally we say to the TikZ program that will start drawing a picture composed of graphic signs and characters, and that this image is on scale 0.05. If you change the value 0.05, for example with 1.0 you will see very small, but spaced signs. The X scale is that of the X axis, then obviously there is also the Y scale. This method seems complicated, but it is absolutely powerful because it allows to modify, with only one parameter, the dimensional characteristics of the figure we're going to draw. Obviously it can be used several times, changing the drawing scale even in subpages. In our case, being the dominant X scale, it is sufficient to only define the 0.05 value I found by doing some tests. This is also a parameter that can be defined once for all the gauges we want to build, it is useful because it allows to easily define the thickness of the lines in mm. | |||
<syntaxhighlight lang="latex"> | |||
\foreach \a in {0, 5,...,355} | |||
</syntaxhighlight> | |||
This is a loop, which allows you to define the variable '''\a''' various values according to a sequence we like. It is a very powerful feature that other programming languages (such as Python, Go etc ..) have inherited from LaTeX. Since variable \ a defines the position on the X axis of the dash at 5 degrees it is useful that the set in the loop is the one we want. You can further elaborate the variable \ a if we want to obtain sequences, as we will see in a later example. From a practical point of view, changing the number sequence involves changing the position of the smaller vertical lines. | |||
<syntaxhighlight lang="latex"> | |||
\draw[line width=0.5mm] (\a,0) -- (\a,1.5mm); | |||
</syntaxhighlight> | |||
Finally, now the program draws! The syntax is simple but powerful, says to draw a line ("-") of 0.5 mm thick (This is the size I actually measured for the compass) starting from '''\a''' X-coordinate (0..355 in steps of 5) and ending higher (Y axis) to 1.5 mm. | |||
Here, the power of the method becomes apparent that with a simple line of code, very readable, it can generate hundreds of rows in a completely parametric way. | |||
<syntaxhighlight lang="latex"> | |||
\draw (30,0.7) node {33}; | |||
</syntaxhighlight> | |||
This command defines a "node" and its content is defined within the braces. The node, in the TikZ language, is a box where you can insert something, such as the number ''33'', but you can do something else like lowering font ''{\small 33}'' and much more according to LaTeX syntax. | |||
==References== | ==References== | ||
<references /> | <references /> | ||
edits