Next Previous Contents

3. Usage

3.1 General Usage

TODO FROM HERE TO END

EQC reads LaTeX files from the command line and writes its output to corresponding .eqc files. One output file is generated for each file given on the command line. Note that files included with \input directives are directly included in the output file. EQC keywords contained in the input files are processed, everything else is written out unchanged. The resulting .eqc files can then be processed like any regular LaTeX file (don't forget to give the .eqc file extension to latex).

An auxiliary package needs to be included with \usepackage{eqc}. It takes an optional argument english or german which defines how numbers are read (whether a comma or a point is expected as the decimal marker). English is the default.

Inside the Latex file, equations can now be defined and registered. EQC will read the equation, produce Latex output, and store it for later manipulation or evalution. For example:

\documentclass{article}
\usepackage{eqc}
\begin{document}
\input mathconstants.tex
$$\eq[eq:myequation]{x = a \sin(b)}$$
$$\eq{a = 3}$$
$$\eq{b = 3.141/2}$$
$$\printeq{"eq:myequation"} = \val{x}$$
\end{document}

This would produce the following Latex output (without the preamble created by including mathconstants.tex):

$$x = a sin(b)$$
$$a = 3$$
$$b = 1.57$$
$$x = a sin(b) = 3$$

In order to determine the value of the variable x, EQC automatically uses the three equations that were registered with the keyword \eq. Note that only equations that have in this way been explicitly registered with EQC will be used! Any other equations present in the file are ignored. To see what else is possible in EQC have a look at the example and the reference section.

3.2 Physical units

Because EQC was developed to tackle mechanical engineering problems, it supports physical units. The Latex side is handled by SIunits.sty, which needs to be present on your system (it is included, for example, in the tetex distribution). Units inside equations are designated by their Latex macro names, e.g., \mm. Variable values can take on four different forms:

  1. A numerical value, like 4 or 3.141.
  2. A unit, like \mm
  3. A physical quantity, that is, a united and a number, like 4 \mm. This form of course includes the first two ones.
  4. Any other kind of mathematical expression, like x + 4 \mm. This of course includes the other three forms.

The \val keyword used in the example above prints the fourth kind of variable value. If we had wished to ensure that a numerical value is printed, we would have used \numval. EQC will then print a warning if the value of the variable does not have this form.

3.3 Library of substitutions

The file substitutions.tex contains a growing library of equations that are useful for working with symbolic equations, for example, \sin(\alpha + \beta) = \sin\alpha \cos\beta + \cos\alpha \sin\beta or \sin(\pi - \alpha) = \sin\alpha. By substitution, they can be adapted to special cases:

$$\eq{\cos\phi = \sin(\phi + \psi)}$$
$$\eqsubst{"prev"}{"lib:trig:sina+b"}$$

which would produce the following output:

$$\cos\phi = \sin(\phi + \psi)$$
$$\cos\phi = \sin\phi \cos\psi + \cos\phi \sin\psi$$

3.4 Formatting of floating point numbers

There are several options available to control how floating point numbers are printed. The precision can be set to a specific number of digits with \eqcoptions{precision = 'num'}.Two different concepts of precision are implemented, these can be selected by \eqcoptions{precision_type = fixed_marker} or \eqcoptions{precision_type = fixed_digits}.

  1. Fixed marker: All numbers are printed with a fixed number of digits after the decimal marker. For example, let the precision be three digits. Then 1.2345 will be printed as 1.235, and 1234.5678 will be printed as 1234.568.
  2. Fixed digits: All numbers are printed with a fixed number of digits precision. For example, let the precision be three digits. Then 1.2345 will be printed as 1.23, and 1234.5678 will be printed as 1230.

Very large and very small numbers should be printed in scientific format (mantissa * 10^exponent) for the sake of readability. The limits which determine what a "very large" or "very small" number is can be set with \eqcoptions{scientific_limit_low = 'num'} and \eqcoptions{scientific_limit_high = 'num'}.

3.5 Formatting of equations

Using the command \eqcoptions{eqraw = true/false} in you Latex input file makes it possible to choose whether \eq statements should be formatted the way you typed them or whether EQC should use it's own output function to format them. Note that any equations obtained by \eqadd etc. will always have the EQC formatting, as EQC can hardly foresee what you would have typed if you had written this equation yourself.

EQC formats equations inside certain environments (eqnarray, align etc.) automatically, that is, the correct number of ampersands (&) is added before/after the equal sign. You can override the formatting by setting the eqalign option manually.


Next Previous Contents