Fig4TeX : A few commented examples |
| Introduction | Reference Guide | Tutorial | Examples | Pdf Documentation | |
\input fig4tex.tex % % 1. Definition of characteristic points \figinit{pt} % Vertices of the triangle \figpt 1:(80.5, 120) \figpt 2:(-10, -10) \figpt 3:(130, 20) % and the barycenter \figptbary 5:c.g.[1,2,3 ; 1,1,1] % % 2. Creation of the graphical file \figdrawbegin{} % A closed line to draw the triangle \figdrawline[1,2,3,1] \figdrawend % % 3. Writing text on the figure \figvisu{\figBoxA}{Figure 1} { \figwriten 1:(4) \figwritew 2:(2) \figwritee 3:(2) \figset write(mark=$\bullet$) \figwrites 5:$G$(4) } \centerline{\box\figBoxA} \bye |
0. The first line loads the macro package. This statement needs to
appear only once in the document.
Fig4TeX uses a colon (character :)
as well as other punctuation marks as argument separators in macros
(e.g.\figpt above).
In case those characters should be redefined (for some kinds of typography, French for instance), those
(re)definitions should be made before this '\input'
line in the TeX document.
1. Definition of the three vertices of the triangle.
2. Creation of the graphical file that will contain the figure, here the three
edges of the triangle, drawn as a single closed broken line. Here, the name of the file is
internally handled by the macro package.
3. Writing text or comments on the figure.
Finally (don't forget to) show the box (command '\box').
Here, the box is centered in the page.
Nota. Generally, only one box is needed in a whole document since the box can be reused several
times. Three boxes, \figBoxA, \figBoxB
and \figBoxC, are already allocated in the macro package and are
available to the user, because several boxes may be necessary to display several figures side by side
(see the description of the macro
\figvisu in the section
Writing text on the figure
in the PDF documentation).
The system is first initialized and the unit to be used for the coordinates is set to
pt (TeX point).
Each point is assigned a number, the value of which is chosen by the user.
The text $A_i$ is implicitly associated with point number i.
Point 5 is then defined as the barycenter of the 3 vertices
(\figptbary),
with c.g. as associated text.
The macro \figvisu
builds a box whose name is given as an argument (\figBoxA here),
as well as the caption that will appear below the figure. The box \figBoxA
is preallocated in the macro package.
The last argument consists of a set of commands that deal with the appearance of the
text on the figure. The figure is stored in the graphical file created just before, and
is automatically included and "put" into the box.
The text associated with each point is printed at the location chosen by the user,
i.e. at 4pt towards the north for point 1,
at 2pt towards the west for point 2,
at 2pt towards the east for point 3,
at 4pt towards the south for point 5.
Note that the text associated with point 5 is modified at this level
($G$).
By default, the attached point of the text is not marked.
However, for point 5, it is highlighted with a TeX symbol
($\bullet$) located right at the centroid of the triangle.
\input fig4tex.tex % \figinit{0.5in} % 1. Characteristic points \figpt 1:$O$(0,0) \figpt 2:$M$(-0.9354, 0.45467) %Compute distance between O and M \figget distance=\DistOM[1,2] %Define translation vector \figvectC 10(\DistOM,0) %Define translated points \figpttra 3:$P$=1/1,10/ \figpttra 4:$Q$=3/1.5,10/ % % 2. Creation of the graphical file \figdrawbegin{} \figdrawcirc 1(\DistOM) \figget distance=\DistPQ[3,4] \figdrawcirc 4(\DistPQ) \figdrawend % % 3. Writing text on the figure \figvisu{\figBoxA}{\bf Tangent circles} { \figset write(mark=$\times$) \figwritenw 2:(0.04)\figwritee 3:(0.04) \figset write(mark=.) \figwriten 1:(0.08)\figwriten 4:(0.08) } \centerline{\box\figBoxA} \bye |
1. The unit length is set to 0.5 inch.
Point 1 ($0$) is the origin, point 2 ($M$)
is 'arbitrary'.
2. Initialize a new graphical file and then 'draw' the circle, centered at point
1 of radius \DistOM,
compute distance between P and Q, then 'draw' the circle, centered at point
4 of radius \DistPQ.
3. Fill the box \figBoxA with the drawing (the graphical file is automatically
inserted) and its legend: annotate the figure with x mark
(\figset write) at point
2 ($M$) and
3 ($P$) ; change mark to a dot (.),
then write text associated with points
1 and 4.
Finally show the box.
Get the distance (\figget distance) between those
points, 'call' it \DistOM,
define vector (number) 10 parallel to the x-axis, of length
\DistOM, giving its components
(\figvectC),
define points 3 ($P$) and
4 ($Q$) as images of point
1 ($0$) by two translations
(\figpttra) along the x-axis.
\input fig4tex.tex % % 1. Definition of characteristic points \figinit{cm} \def\rotangle{38} \figpt 1:(-3,0)\figpt 2:(3,0)\figpt 0:(0,0) \figptsrot 3=1,2/0,\rotangle/\figpt 5:(-3,1) % 2. Creation of the graphical file \figdrawbegin{} \figdrawline[1,2]\figdrawline[3,4] \figdrawarrowcirc 0;1.7(0,\rotangle) \figset arrowhead(angle=30) \figdrawarrowcircP 0;-1[2,3] \figset arrowhead(angle=default,fillmode=yes) \figset(width=2) \figdrawarrowcircP 0;1[4,1]\figdrawarrowcircP 0;-2[3,1] \figset(width=default)\figset arrowhead(length=0.3) \figdrawarrowcircP 0;-1.4[2,3]\figdrawarrowBezier[4,5,1,3] \figdrawend % 3. Writing text on the figure \figvisu{\figBoxA}{\bf Circular and curved arrows}{ \figwritew 1:(0.2)\figwritee 2:(0.2) \figwritesw 3:(0.2)\figwritene 4:(0.2)} % \centerline{\box\figBoxA} \bye |
The Earth with equator, tropic lines and meridians
\input fig4tex.tex