[go: up one dir, main page]

Menu

[r12]: / docs / eqc-3.html  Maximize  Restore  History

Download this file

149 lines (130 with data), 6.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.66">
<TITLE>The EQC Handbook: Usage </TITLE>
<LINK HREF="eqc-4.html" REL=next>
<LINK HREF="eqc-2.html" REL=previous>
<LINK HREF="eqc.html#toc3" REL=contents>
</HEAD>
<BODY>
<A HREF="eqc-4.html">Next</A>
<A HREF="eqc-2.html">Previous</A>
<A HREF="eqc.html#toc3">Contents</A>
<HR>
<H2><A NAME="s3">3.</A> <A HREF="eqc.html#toc3">Usage </A></H2>
<H2><A NAME="ss3.1">3.1</A> <A HREF="eqc.html#toc3.1">General Usage</A>
</H2>
<P>EQC reads LaTeX files from the command line and writes its output to corresponding <CODE>.eqc</CODE> files. One output
file is generated for each file given on the command line. Note that files included with <CODE>\input</CODE> 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 <CODE>.eqc</CODE> files can then be processed like any regular LaTeX file (don't
forget to give the <CODE>.eqc</CODE> file extension to latex).</P>
<P>An auxiliary package needs to be included with <CODE>\usepackage{eqc}</CODE>. It takes an optional argument <CODE>english</CODE> or
<CODE>german</CODE> which defines how numbers are read (whether a comma or a point is expected as the decimal marker).
English is the default.</P>
<P>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:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
\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}
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>This would produce the following Latex output (without the preamble created by including mathconstants.tex):
<BLOCKQUOTE><CODE>
<PRE>
$$x = a sin(b)$$
$$a = 3$$
$$b = 1.57$$
$$x = a sin(b) = 3$$
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>In order to determine the value of the variable <CODE>x</CODE>, EQC automatically uses the three
equations that were registered with the keyword <CODE>\eq</CODE>. 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.</P>
<H2><A NAME="ss3.2">3.2</A> <A HREF="eqc.html#toc3.2">Physical units</A>
</H2>
<P>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., <CODE>\mm</CODE>.
Variable values can take on four different forms:</P>
<P>
<OL>
<LI> A numerical value, like 4 or 3.141.</LI>
<LI> A unit, like <CODE>\mm</CODE></LI>
<LI> A physical quantity, that is, a united and a number, like <CODE>4 \mm</CODE>. This form of course
includes the first two ones.</LI>
<LI> Any other kind of mathematical expression, like <CODE>x + 4 \mm</CODE>. This of course includes the
other three forms.</LI>
</OL>
</P>
<P>The <CODE>\val</CODE> 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 <CODE>\numval</CODE>. EQC will then print a warning
if the value of the variable does not have this form.</P>
<H2><A NAME="ss3.3">3.3</A> <A HREF="eqc.html#toc3.3">Library of substitutions</A>
</H2>
<P>The file substitutions.tex contains a growing library of equations that are useful for working with
symbolic equations, for example, <CODE>\sin(\alpha + \beta) = \sin\alpha \cos\beta + \cos\alpha \sin\beta</CODE>
or <CODE>\sin(\pi - \alpha) = \sin\alpha</CODE>. By substitution, they can be adapted to special cases:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
$$\eq{\cos\phi = \sin(\phi + \psi)}$$
$$\eqsubst{"prev"}{"lib:trig:sina+b"}$$
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>which would produce the following output:</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
$$\cos\phi = \sin(\phi + \psi)$$
$$\cos\phi = \sin\phi \cos\psi + \cos\phi \sin\psi$$
</PRE>
</CODE></BLOCKQUOTE>
</P>
<H2><A NAME="ss3.4">3.4</A> <A HREF="eqc.html#toc3.4">Formatting of floating point numbers</A>
</H2>
<P>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 <CODE>\eqcoptions{precision = 'num'}</CODE>.Two different concepts of precision
are implemented, these can be selected by <CODE>\eqcoptions{precision_type = fixed_marker}</CODE> or <CODE>\eqcoptions{precision_type = fixed_digits}</CODE>.</P>
<P>
<OL>
<LI> 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.</LI>
<LI> 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.</LI>
</OL>
</P>
<P>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
<CODE>\eqcoptions{scientific_limit_low = 'num'}</CODE> and <CODE>\eqcoptions{scientific_limit_high = 'num'}</CODE>.</P>
<H2><A NAME="ss3.5">3.5</A> <A HREF="eqc.html#toc3.5">Formatting of equations</A>
</H2>
<P>Using the command <CODE>\eqcoptions{eqraw = true/false}</CODE> in you Latex input
file makes it possible to choose whether <CODE>\eq</CODE> 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 <CODE>\eqadd</CODE> etc. will always have the EQC formatting, as EQC
can hardly foresee what you would have typed if you had written this equation yourself.</P>
<P>EQC formats equations inside certain environments (<CODE>eqnarray</CODE>, <CODE>align</CODE> etc.)
automatically, that is, the correct number of ampersands (<CODE>&amp;</CODE>) is added before/after
the equal sign. You can override the formatting by setting the <CODE>eqalign</CODE> option manually.</P>
<HR>
<A HREF="eqc-4.html">Next</A>
<A HREF="eqc-2.html">Previous</A>
<A HREF="eqc.html#toc3">Contents</A>
</BODY>
</HTML>