summaryrefslogtreecommitdiff
path: root/graphics/transfig-shapepatch/shapepatch.README
blob: 26e2215e802e30714f2b2fcbd892d7d922ec941b (plain)
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
ShapePatch README
==================

This file describes how to install and use the shapepar output driver for the
XWindow drawing program XFig. The current version is 3.2.4-shape-1.1. Don't use
3.2.4-shape-1, it has two bad bugs. The naming scheme is first the XFig/Transfig
version, appended shape, then the version of the patch. 

What is ShapePatch ?
====================

ShapePatch is a patch against Transfig, which adds the capability to export
XFig figures to shape definitions for shapepar. Shapepar itself is a TeX-Macro
by Donald Arsenau that allows to form a paragraph into a given shape, where the
size of the shape is automatically adjusted so that the given paragraph
completely fills the shape. There are some predefined shapes, like e.g. a heart.
So you can form any paragraph into the form of a heart by putting
\heartpar{sometext...}
inside your document. It is of course possible, to define such shapes by
oneself, but it involves that you resolve your shape into a polygon and enter
the coordinates into your TeX-Document. This is quite crucial, and this is the
point where ShapePatch comes up: It allows you to simply draw the shape you want
with XFig, and then convert it to such a shape definition either by calling
fig2dev manually, or by choosing "Export/Shape" in XFig (if you install the
additional XFig patch). 

How to install
==============

ShapePatch is distributed as a patch against transfig and xfig. So first get the
source code of transfig and xfig, and untar them. Then copy the transfig patch
into the transfig source directory, and the xfig patch respectively into the
xfig source tree. Then type

cd transfig.3.2.4
patch -p1 <transfig.3.2.4-shape-1.patch


and respectively

cd xfig.3.2.4
patch -p1 <xfig.3.2.4-shape-1.patch

Do this before you make any changes to the Imakefiles! The patches should apply
cleanly, you can then proceed as usual to compile and install XFig and transfig
(please refer to the appropriate documentation). Perhaps you have to install
additional libraries and/or change the Imakefiles in order to compile.
ShapePatch itself doesn't require any additional libraries. So before reporting
compile errors, please make sure that the clean unpatched versions of transfig
and XFig compile and work.


How to use ShapePatch
=====================

Basic shape drawing
-------------------

If you want to have a simple shape, like e.g. a circle, then construct it as
follows:

* Draw the shape (you can use rectangles, circles/ellipses, arcs, splines,
  polygons) 
* Click the "Edit" button
* Click onto the object
* In the upcoming edit panel write '+' into the comment line (without the '',
  just the plus sign)
* Save your file

Then you call fig2dev like the following:
fig2dev -L shape foo.fig foo.shape
This tells fig2dev to output the shape definition into the file "foo.shape".
Alternatively, if you have installed the xfig-shapepatch, you can just choose
"File/Export" from the XFig menu, choose "SHAPE" as the "Language" and export to
"foo.shape". Very easy, isn't it? 

Then your LaTeX file could look like the following:
\documentclass{article}
\usepackage[noheadfoot, a4paper]{geometry}
\usepackage{shapepar}
\input{foo.shape}
\begin{document}
\newshapepar{some long text that will be shaped into your foo-shape}
\end{document}

If you run this through LaTeX, you should get the proper formatting.

Complex shapes
--------------

ShapePatch uses a so called combine/subtract feature to construct more complex
shapes. For example, a shape can have holes (like the predefined \nutshape from
the shapepar package). Shapes can be combined to "melt together" forming new
shapes, and others can be cut out from this. For example, consider a cross like
this one:
   **
   **
********
********
   **
   **

You can construct it by putting two tall rectangles over each other, the one
vertically, the second horizontally, each having the comment '+'. The two
rectangles will combine to form the cross above.

If you want to construct holes, you can do this by cutting out a shape from
another, which is achieved by the comment '-'. For example, if you want to
construct the nutshape from the shapepar package, you will put a hexagon with
the comment '+' and a circle into its center with the comment '-'. 

You may have realized that the order in which the different objects are composed
is important, especially if there are holes. If you consider the nutshape
example above, if the circular hole is drawn before the hexagon, it would be
totally useless: The "hole" is cut out from nothing, and then overpainted by
the hexagon, which finally gives simply a filled hexagon. You can determine the
order of composing by setting different depths of the objects in XFig. (Use
either the edit panel or the depth button when constructing an object.) So if
you want to make sure, that the hexagon is painted first, and then the hole is
cut out, give the hexagon e.g. the depth 50 and to the hole the depth 40. You
can control this by setting the fill color of the "positive" objects to black
and to white for "negative" objects. You should then see the final shape in
XFig.  However, there is absolutely *NO WARRANTY* that this is the same, if you
have overlapping objects with the same depths. So te be sure you get what you
want, give all objects that overlap a different depth value.

Additional parameters
---------------------

You can set some additional parameters that influence the output.

  Macro name

 First, there is the macro name of the shape. If none is given, the standard
macro name is "newshapeshape" for the shape definition (i.e. the weird numbers
you should not have to care about) and "newshapepar" for the macro that calls
shapepar with the shape definition. You can change this name either by the
commandline switch -n:

fig2dev -L shape -n foo foo.fig foo.shape

gives you "fooshape" and "foopar" respectively, or by setting the comment for
the whole figure (click middle mouse button in edit mode over the drawing area).
The commandline switch overrides the figure comment.

  Centering position

The final shape will be horizontally centered on the page. Normally, the driver
should compute this quite right (it takes the center of the left+right outermost
parts of the shape), but you may want to choose this by hand. So draw a vertical
line where you want the center to be finally, and give it the comment "center".
It must be exactly this, no whitespace, no uppercase letters, no '+' or '-'
sign. This line won't appear in the shape, but tells the position that would be
in the middle of the page.

  Dimension

Because the size is adjusted automatically, you normally don't need to care
about it. But the new shapepar (>=2.0) supports a feature to use a fixed size.
The paragraph will only partly fill the shape. You can specify the dimension
used by ShapePatch by drawing a ruler line, that will become exactly the length
10 in the final output. For example, if you draw a vertical line and give it
the comment "height", then the height of this line will correspond to the
length of 10 units. Analogously, specify "width" if you want the width of a
horizontal line to become 10 units wide. You also use a rectangle for this
choice of the dimension. These lines will not show up in the final paragraph,
they are just for construction

  Construction objects

Objects that have no comment are ignored by ShapePatch. Thus if you need some
object helping you to construct the drawing (e.g. aligning objects on a circle),
you can freely draw any object you want, as long as you don't set a comment.
Objects with comments that do not comply to the requirements (starting with '+',
'-' or one of the reserved words 'width', 'height', 'center') are rejected. It
is possible to add comments, that are "real" comments, i.e. ignored by the
driver. To do this, add your comment separated with at least one blank, newline
or other non-alphanumeric character like # *after* the shape specification. So
if you have an object in the shapegroup "moon" that has the comment "full moon",
the whole string you enter looks like
+moon full moon
Only the first word "moon" counts for shapegroup. You could alse have used
+moon#full moon
or
+moon{full moon

so this is considered to be bad style, better use a blank. If your object you
want to comment is no shape, so simply start the comment with a blank character.

If you want to comment the whole drawing, then use a newline to separate the
macroname from the comment. The first line of the drawing name is taken without
further examining if it would be a valid LaTeX macro name. You would get a LaTeX
error, however. You can use the commandline switch "-n" to override the name
givan as the drawing comment. 

Independent segments
--------------------

This feature is available only in shapepar version >=2.0 
There can be separate segments of text, coupled only by the scaling factor, the
text starts in one of the shapes, after filling it jumps to the second and so
on. As an example, consider to squares situated besides each other:

***  ***
***  ***
***  ***

If you convert this figure with ShapePatch, giving both squares the comment '+',
the text will start in the left box, jump over the gap, continue in the right
box. The next line starts again in the left, and so on. If your text would be
something like "a b c d ..." you would get:

abc  def
ghi  jkl
mno  pqr

This works also with shapepar <2.0. But say, you want to have two columns, like
e.g. in a newspaper:

abc  jkl
def  mno
ghi  pqr

which is much more readible, if the gap is big. how to tell it to ShapePatch?
The solution is to use identifiers. This works only with shapepar >=2.0: If you
give the left square the comment "+1" and the right one "+2", you will get the
above result. Lets say you want the right column to be filled first:

jkl  abc
mno  def
pqr  ghi

Just give "+1" to the right box and "+2" to the left. These "1" and "2" are so
called identifiers, that say in which group of shapes this object is to put in.
It can be any alphanumeric value, and the order is determined by the
alphanumeric sort order. So we could have used "+a" and "+b" instead. Be aware,
that because of the alphanumeric sort "A" comes before "a" and "z", and numbers
may be sorted  weirdly:
1, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9 ... 

 Of course, if one of the shape is composed by severaly objects, all objects
must have the corresponding identifier. For an example, look to the chessboard
or the canadian flag.

Example files
=============

With ShapePatch there should come some example XFig drawings together wth their
translation, so you can check if the program works. There are:

moon.fig:	A moon
face.fig:	A face like a smiley
music.fig:	A line of sheet music with one notehead
canada.fig:	The canadian flag - requires shapepar>=2.0
chessboard.fig:	A chessboard -  requires shapepar>=2.0


Author
======

Written by Christian Gollwitzer <auriocus@btcips73x1.cip.uni-bayreuth.de>.
License is X/MIT (cf. to source code)