<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>A program for generating tex source files producing graphic output</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Victor N. Fomenko</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Victor V. Garbaruk</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Nina V. Popova</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Emperor Alexander I State Transport University</institution>
          ,
          <addr-line>Moscow avenue 9, Saint-Petersburg, 190031</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>LLC "New Technologies and Service" St. Bolshaya Raznochinnaya</institution>
          ,
          <addr-line>house 14, lit. A, room 101, Saint-Petersburg, 197110</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Peter the Great St. Petersburg Polytechnic University</institution>
          ,
          <addr-line>Polytechnicheskaya st., 29, St. Petersburg, 195251</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
      </contrib-group>
      <fpage>166</fpage>
      <lpage>171</lpage>
      <abstract>
        <p>In this work a package of applications is described that is aimed to enhance graphic facilities of the Latex typesetting system [1, 2]. The package is built up by the fusion of the Latex formatting and graphic tools, on the one hand, and flexibility and computational aids of FORTRAN 95 [2], on the other. As a result, the program allows to easily create pictures containing many repeating elements or elements varying in a regular manner, automatically hatching a selected domain, inserting formatted objects (a formula, for instance) at any point of the image. The package enables us to create 3D object images as seen along a certain direction. An automatic drawing of their plane sections may be also done.</p>
      </abstract>
      <kwd-group>
        <kwd>1 computer graphics</kwd>
        <kwd>Latex</kwd>
        <kwd>3D graphics</kwd>
        <kwd>Fortran</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Creating pictures, using WORD also, is not
a simple task. LaTeX [
        <xref ref-type="bibr" rid="ref1 ref2 ref3">1, 2, 3</xref>
        ] is a popular TeX
typesetting package that makes it easy to type
complex documents. The package allows you to
automate many tasks of typing books,
educational materials, scientific articles. In
distance learning LaTeX is actively used to
create multivariate assignments in various
disciplines [
        <xref ref-type="bibr" rid="ref4 ref5">4, 5</xref>
        ]. Most documents created by
means of LaTeX also contain graphics and
illustrations for better understanding of the text.
Adding visual elements to text can be done in
different ways.
      </p>
      <p>
        There are many different charting and data
visualization systems that can be saved in PDF
format. These objects are then included in the
text of the document prepared by LaTeX [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
      </p>
      <p>
        Another approach is to convert images and
graphs from powerful mathematical software
packages Matlab [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], Mathematica [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ],
GeoGebra [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] and many others into
"LaTeXcode".
      </p>
      <p>
        There are a number of packages working
well with LaTeX. We list some of these
packages, but a detailed discussion of their
merits and demerits is beyond the scope of this
article. MetaPost [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] is a graphical drawing
editor for LaTeX. The package is based on the
METAFONT [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ] program created by Donald
Knuth for the development of vector fonts for
TeX. The Asymptote package [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ] overcomes
some of the MetaPost limitations. The
LaTeXDraw package [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ] can be used to
generate PSTricks code or directly create PDF
pictures. PGF / TikZ is a tandem of languages
for producing vector graphics from geometric
and algebraic descriptions. PGF is a lower-level
language, while TikZ is a set of higher-level
macros that use PGF [
        <xref ref-type="bibr" rid="ref13 ref14 ref15 ref16 ref17 ref18 ref19 ref20">13-20</xref>
        ]. The close
relationship between TikZ and PGFPlots
allows, firstly, to effectively integrate charts
into various drawings made in TikZ, as well as
to use the TikZ capabilities when working with
charts [
        <xref ref-type="bibr" rid="ref20">20</xref>
        ].
      </p>
      <p>
        In this work software is described which is
aimed to make it easier (or, in many situations,
even possible at all) to produce complicated
images for those who use Latex system.
Because of this reason the graphic tool under
consideration can prove to be very useful. In
this package, the user should write a program in
the Fortran 95 language [
        <xref ref-type="bibr" rid="ref21">21</xref>
        ]. If the figure is
inserted into the text, then the Fortran 95
program ends with subroutine final, and
subroutine prep (fn, dims, hrange, vrange, nh,
nv, margin) listing the insert parameters begins.
Otherwise, the result is obtained in the PDF
form.
      </p>
      <p>An important feature of the present way to
explore the Latex graphics is performed using
facilities of the flexible and well-developed
language FORTRAN 95, rather than within the
Latex system itself. This language has a library
of numerous built-in functions, in particular
those which deal with strings, what is important
for making files of the tex type. In contrast to
this, the graphic applications developed
recently are often based on programming
within the Latex system which is less capable
of implementing algorithms, especially
computational ones.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Brief description of graphics utilities</title>
      <p>We will give a brief description of the
utilities (their total number is more than 80)
that can be used to create drawings. First of
all, the size of the picture is set, then the
ranges for the auxiliary coordinates along
the horizontal and vertical axes are
indicated, the coordinate axes are
displayed, they can be provided by
numbered divisions and additional marks.
Note that the coordinates of the points in the
displayed image are set in arbitrary units.
The horizontal and vertical scale is
determined basing on the size of the picture
and the range of coordinates in arbitrary
units along the horizontal and vertical lines.
In most cases, the lines forming the picture
can be solid or dashed, and the dash-size
parameters can be set by the user. Line
width can also be user-defined.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Creation of drawings</title>
      <p>In this package, the user has to write a
Fortran 95 program. The input file created for
the LaTeX system is processed by the LaTeX
translator into the PDF file shown in the figures
below. We note the following features of the
figures constructed using the described
software package:
 automatic hatching over a domain with
the boundary defined parametrically (fig.
1);
 images of flat pictures with
repeating elements, for example,
electrical circuits (fig. 2, 3).</p>
    </sec>
    <sec id="sec-4">
      <title>4. Imaging of 3D objects</title>
      <p>The algorithm implemented in this work
corresponds to the photographic process of a
removed object if the size of the latter is much
less than the distance between it and the
camera.</p>
      <p>In particular, it is possible to display spatial
curves and convex polyhedrons. The direction
in which the object is viewed is set by vector
(, , ) defining the position of the screen. To
obtain, for example, an isometric projection,
you may take  = 1/3,  = 1/3,  = 1/3.</p>
      <p>The position of the camera with respect to
its axis is chosen so that vertical elements are
depicted vertically as well.</p>
      <p>To picture convex polytopes one should
indicate the Descartes, cylindrical or spherical
coordinates of the vertices. Besides one should
specify for each face the vertices which lie in it.
The program determines which vertices are
connected with edges. Also the edges are found
out which are non-visible for the given viewing
direction. Such edges are imaged by dash lines.
An automatic denotation of vertices is available
too. Given the equation of a plane, the program
builds the cut of the polytope by this plane.</p>
      <p>Note some features of the images produced
by described software:
 authenticity, i.e., exact reproduction of
geometrical properties up to the size of
pixels depicting the image;
 imaging of 3D objects and their plane
sections in strict accordance with the rules
of orthographic projection.
 image and shading of flat sections of a
spatial figure;
 rendering of features after rotation
about any spatial axis.</p>
      <p>The constructed spatial figure can be viewed
from various sides by changing the vector that
determines the direction of observation. Fig. 5,
6 show top and side views of the previously
built Polytope. The parameters of the
observation vectors SCREEN = (/0.,0.,-1./) and
SCREEN = (/-1.,0.,0./) correspond to these
figures.
 β1   2(λ0λ3  λ1λ2 ) 
β2    λ02  λ12  λ22  λ 2  ;
3 
 β3   2(λ0λ1  λ2λ3 ) 
 γ1   2(λ0λ2  λ1λ3 )
 γ2    2(λ0λ1  λ2λ3 )
 γ3   λ02  λ12  λ22  λ32 

 .
</p>
      <p>Rodrigo-Hamilton parameters
0 , 1, 2 , 3 are calculated by the formulas:.
λ0  cos(θ / 2), λ1  cx sin(θ / 2), .
λ2  cy sin(θ / 2), λ3  cx sin(θ / 2) .</p>
      <p>This subroutine is useful for analyzing
spatial curves. Figure 7 shows different types of
a conical helix defined by the following
parametric equations:
x(t)  t  cos t;

 y(t)  t  sin t;
 z(t)  t.</p>
    </sec>
    <sec id="sec-5">
      <title>5. Plotting functions</title>
      <p>The main disadvantage of the PICTURE
graphic package and its EPIC and EEPIC
extensions used in the LaTeX system is their
orientation towards manual work. For example,
they allow you to display a graph, but it is
assumed that the coordinates of the points will
be entered by the programmer as command
arguments. In this package, the user only has to
write a Fortran 95 program that defines the
curve parametrically. To construct a curve, call
the corresponding subroutine of the package,
and the names of the procedure defining the
curve are included as parameters of this
subroutine. It is possible, if necessary, to
display a large number of illustrating elements
(arrows, lines, etc.).</p>
    </sec>
    <sec id="sec-6">
      <title>6. Conclusion</title>
      <p>An important difference of this approach
from using Latex graphics is its hybrid nature.
Programming is carried out not within the
framework of the Latex system, but by means
of the flexible and well-developed language
FORTRAN 95. This language has a rich library
of built-in functions, in particular, functions for
working with strings, which is especially
important for creating tex source files. On the
contrary, currently developed graphical
applications usually focus on programming in
the Latex system itself, which has fewer
facilities for implementing algorithms,
especially computational ones.</p>
      <p>A significant advantage of this approach is
its ability to extend itself by creating new
procedures based on those already written in
Fortran.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>Goossens</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Mittelbach</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rahtz</surname>
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Voss</surname>
            ,
            <given-names>H.</given-names>
          </string-name>
          <string-name>
            <surname>The LaTeX Graphics Companion</surname>
          </string-name>
          ,
          <string-name>
            <surname>Second Edition</surname>
          </string-name>
          , New York, Addison-Wesley,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <surname>Spivak</surname>
            <given-names>M.</given-names>
          </string-name>
          <article-title>The Joy of TEX. A gourmet guide to typesetting with the AMSTEXmacro package</article-title>
          .
          <source>American Mathematical Society</source>
          , Provi-dence,
          <source>RI</source>
          ,
          <year>1990</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <surname>Rozhenko</surname>
            <given-names>A. I.</given-names>
          </string-name>
          <article-title>Art of text composition in LATEX, Printing house of the State University</article-title>
          , Novosibirsk,
          <year>2005</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <surname>V.M. Karnaukhov</surname>
          </string-name>
          <article-title>LATEX application</article-title>
          .
          <article-title>Generator of test options</article-title>
          . Saarbrücken, Germany, Lap lambert Academic Publishing,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <surname>Lubyagina</surname>
            <given-names>E.N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Yurlova</surname>
            <given-names>E.S.</given-names>
          </string-name>
          <article-title>Preparation of educational assignments in LATEX</article-title>
          . (
          <year>2014</year>
          )
          <article-title>Mathematical bulletin of pedagogical universities and universities of the Volga-Vyatka region</article-title>
          . No.
          <volume>16</volume>
          .
          <fpage>289</fpage>
          -
          <lpage>295</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <surname>Baldin</surname>
            <given-names>E. M.</given-names>
          </string-name>
          <article-title>LaTeX computer printing house</article-title>
          , BHV- Petersburg, St.Petersburg,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <surname>Gilat</surname>
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Subramaniam</surname>
            <given-names>V</given-names>
          </string-name>
          .
          <article-title>Numerical methods for engineers and scientists: an introduction with applications using MATLAB. 3rd edition</article-title>
          . John Wiley &amp; Sons, Inc. New York,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <surname>Taranchuk</surname>
            <given-names>V. B.</given-names>
          </string-name>
          <article-title>Introduction to graphics of the Mathematica system</article-title>
          ,
          <source>BSU</source>
          , Minsk:
          <year>2017</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <surname>Kovács</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Parisse</surname>
            <given-names>B.</given-names>
          </string-name>
          <string-name>
            <surname>Giac</surname>
          </string-name>
          and
          <article-title>GeoGebra: improved Grоbner basis computations</article-title>
          , RICAM Institute, Linz,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <surname>Hobby</surname>
            <given-names>J.D.</given-names>
          </string-name>
          <article-title>A user's manual for METAPOST</article-title>
          .
          <source>Technical Report 162</source>
          , AT&amp;T Bell Laboratories, Murray Hill, New Jersey,
          <year>1992</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <surname>Knuth</surname>
            <given-names>D.</given-names>
          </string-name>
          <article-title>The METAFONTbook</article-title>
          . Addison Wesley, Boston,
          <year>1986</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <article-title>Asymptote: The Vector Graphics Language</article-title>
          . URL: http://asymptote.sourceforge.net.
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>[13] http://latexdraw.sourceforge.net</mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <string-name>
            <surname>Kuretenko</surname>
            <given-names>U. A.</given-names>
          </string-name>
          <article-title>TikZ &amp; PGF. Grafiics of Document LaTeX</article-title>
          . Rostov-Don,
          <year>2014</year>
          . URL:http://elib.ict.nsc.ru/jspui/ handle/ICT/1488.
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <surname>Tantau</surname>
            <given-names>T.</given-names>
          </string-name>
          <article-title>TikZ and pgf manual</article-title>
          .
          <source>Version</source>
          <volume>1</volume>
          .01. URL: http://sourceforge.net/projects/pgf/.
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <surname>Mertz</surname>
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Slough</surname>
            <given-names>W.</given-names>
          </string-name>
          <article-title>Graphics with PGF and TikZ</article-title>
          .
          <source>TUGboat</source>
          , Volume
          <volume>28</volume>
          , No.
          <volume>1</volume>
          (
          <year>2007</year>
          )
          <fpage>91</fpage>
          -
          <lpage>99</lpage>
          , Proceedings of the Practical TEX 2006 Conference. URL: http:// works.bepress.com/william_slough/5/.
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <surname>Feuersanger</surname>
            <given-names>C.</given-names>
          </string-name>
          <article-title>Manual for Package pgfplots - 2D/3D Plots in LATEX</article-title>
          .
          <source>Vers. 1</source>
          . URL: http://sourceforge.net/projects/pgfplotsDr.
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <string-name>
            <surname>Esajan</surname>
            <given-names>А. R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Chubarikov</surname>
            <given-names>V. N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Djbrovolski</surname>
            <given-names>N. М.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Jakushin А</surname>
          </string-name>
          . V.
          <article-title>Plotting using LaTeX-package pgfplots, izd-</article-title>
          <string-name>
            <surname>vo</surname>
            <given-names>TGPU</given-names>
          </string-name>
          , Tula,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [19]
          <article-title>Plotting with TikZ and LaTeX</article-title>
          . URL: http://pgfplots.net.
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          [20]
          <string-name>
            <surname>Getreuer</surname>
            <given-names>P.</given-names>
          </string-name>
          <article-title>TikZ for High-Quality LaTeX Pictures</article-title>
          . URL: http://www.sciweavers.org/tutorials/tikzhigh
          <article-title>-quality-latex-pictures.</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref21">
        <mixed-citation>
          [21]
          <string-name>
            <surname>Chapman</surname>
            ,
            <given-names>S.J.</given-names>
          </string-name>
          <string-name>
            <surname>Fortran</surname>
          </string-name>
          90
          <article-title>-95 for Scientists and Engineers</article-title>
          , WCB/
          <string-name>
            <surname>McGraw-Hill Higher</surname>
            <given-names>Education</given-names>
          </string-name>
          , New York,
          <year>1998</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref22">
        <mixed-citation>
          [22]
          <string-name>
            <surname>Lurie</surname>
            <given-names>A.I. Analytical Mechanics</given-names>
          </string-name>
          , Springer, Berlin,
          <year>2002</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>