Debian Codegraph @

texmf-dist/doc/generic/insbox/demo.tex

raw
1 % This file contains description of \InsertBoxL, \InsertBoxR, \InsertBoxC
2 % and \MoveBelowBox macros that are defined in the INSBOX package.
3 % Compile it and check this source file to see how that all was done.
4
5 \nopagenumbers
6
7 \input insbox
8 \input epsf
9
10
11 % a macro for building a box with a frame around it
12 \def\Frame#1{%
13 \vbox{
14 \hrule
15 \hbox{%
16 \vrule
17 \vbox{\vskip 4mm \hbox{\hskip 4mm #1 \hskip 4mm} \vskip 4mm}%
18 \vrule
19 }
20 \hrule
21 }
22 }
23
24
25
26 % Put an \epsfbox in the right after two lines of text:
27 \InsertBoxR{2}{\epsfbox{pic1.eps}}
28 Creating documents like this is quite easy. Just four easy macros
29 can do all the stuff required to put pictures on the page and
30 format all the neighbouring paragraphs so that they do not interfere
31 with pictures. The picture you see in the right was inserted using
32 the following command put just before the beginning of this paragraph:
33 \hfil\break
34 {\tt\string\InsertBoxR\char123 2\char125\char123\string\epsfbox\char123
35 pic1.eps\char125\char125}
36
37
38 The meaning of the macro's arguments is very easy. The first
39 argument should be the number of lines to be typeset ``normally'',
40 that is using the whole width of the page. The second argument
41 is {\it any\/} box that is to be put on the page beside the text.
42 The letter {\tt R} at the end of the macro's name indicates
43 that the picture should be put in the right. Of course, there is
44 also a macro named {\tt\string\InsertBoxL} which works similarly,
45 but puts the picture in the left. Further in this document you will
46 find a description of the {\tt\string\InsertBoxC} macro. As you
47 probably guessed, it inserts a picture centered in the page.
48
49
50 \def\somebox{\vbox{
51 \hsize = 5cm
52 \noindent Some simple text. Some simple text. Some simple text.
53 Some\break simple text. Some simple text.
54 $$ a^2 + b^2 = c^2 $$
55 That was a simple formula. Let's put more text here to make
56 this box bigger... Some simple text. Some simple text.
57 }}
58
59 % as you see, you can supply the third optional parameter to
60 % \InsertBoxL and \InsertBoxR macros; it may help if they
61 % calculate the space for the frame incorrectly
62 \InsertBoxL{2}{\Frame{\somebox}}[-2]
63 I mentioned earlier that almost {\it anything\/} can be inserted
64 in the document --- not only {\tt\string\epsfbox}es. You can create
65 {\it any\/} box containing graphics, text, math formulas and put it
66 beside your text using {\tt\string\InsertBox} macros. The simple
67 example in the left should be a good proof.
68
69
70 The macros are quite reliable, but you may experience some problems
71 if you put displayed math formulas beside pictures. The space reserved
72 for the frame may appear too little or too big. But there is an
73 easy way to make neccessary correction. Check the source file
74 to see how it was done in this particular situation.
75 $$ \sum_{i=1}^{n} i^3 = \left( {n(n+1) \over 2} \right)^2 $$
76 Also, I do not guarrantee correct behaviour of these macros in other
77 extreme conditions. It is not possible to put two {\tt\string\InsertBox}
78 commands before a paragraph --- in that case you should not expect
79 a paragraph squeezed between two frames.
80
81
82 \def\somebox{\vbox{
83 \epsfxsize=4cm
84 \hbox{\epsfbox{pic2.eps}}
85 \hbox to 4cm{\hss Figure 2.\hss}
86 }}
87
88 There is also a macro for inserting boxes centered in the page. Its name
89 is {\tt\string\InsertBoxC} and it requires only one argument --- the
90 box to be inserted. The macro should be called from {\it inside\/}
91 a paragraph (not put {\it before\/} a paragraph). The box will be put
92 just below the line containing the macro. For example the picture below
93 was inserted by putting
94 {\tt\string\InsertBoxC\char123 \string\somebox\char125}
95 after {\it this\/}\InsertBoxC{\somebox} word. The line was completed,
96 the picture was inserted and the paragraph continues below the picture.
97 The usage seems very simple and intuitive.
98
99
100 \InsertBoxR{0}{\somebox}
101 I recommend that you see the source of this document and check how
102 changes to arguments of {\tt\string\InsertBox} macros affect paragraphs.
103 But before I end, let me give you one more hint. Sometimes you may wish
104 to generate a vertical skip like this:
105
106
107 \MoveBelowBox
108 In such situation you should use the {\tt\string\MoveBelowBox} command.
109 It starts the next paragraph just below the current picture.
110
111
112 \bigskip
113 \noindent
114 Micha\l{} Gulczy\'nski \hfil\break
115 {\tt [email protected]}
116
117
118 \bye