1
2
3
4
5
6
7
8\environment interactionstyle
9
10\enabletrackers[attachments.anchors]
11
12\setupattachment
13 [location=inmargin]
14
15\startcomponent interactionattachments
16
17\startchapter[title=Attachments]
18
19Attachments are (normally) embedded files that the reader can extract. A viewer
20can decide to just show the content or call an associated program to deal with
21the file (which one depends on the operating system). As with other annotations
22they started out depicted by symbols but then browsers started showing them in
23lists next to the displayed page.
24
25\startbuffer
26\attachment
27 [attachment 1]
28 [file=interactionattached001.txt,
29 title=Just some text,
30 width=2em,
31 height=2em,
32 author=Hans,
33 subtitle=Plain text]
34
35\attachment
36 [attachment 2]
37 [file=cow.mp,
38 title=Just a graphic,
39 author=Hans,
40 subtitle=Some MetaPost,
41 method=hidden]
42\stopbuffer
43
44\typebuffer \getbuffer
45
46These two attachments differ in one aspect: the second one is hidden, i.e. it has
47no icon in the text. However, the attachment is in the file and is (often)
48visible in the side bar. The symbol for the visible one is in the margin, which
49is achieved with:
50
51\starttyping
52\setupattachment
53 [location=inmargin]
54\stoptyping
55
56You can use your own icon, for instance:
57
58\startbuffer
59\startuniqueMPgraphic{cow}{height,s:color}
60 loadfigure "cow.mp" number 1 ;
61 refill currentpicture withcolor "\MPvar{color}" ;
62 currentpicture := currentpicture ysized \MPvar{height} ;
63\stopuniqueMPgraphic
64
65\definesymbol
66 [attachmentnormal]
67 [\uniqueMPgraphic{cow}{height=4ex,color=darkblue}]
68\definesymbol
69 [attachmentdown]
70 [\uniqueMPgraphic{cow}{height=4ex,color=darkyellow}]
71\stopbuffer
72
73\typebuffer \getbuffer
74
75
76
77
78
79\attachment
80 [symbol={attachmentnormal,attachmentdown},
81 file=cow.pdf,
82 title=A cow,
83 author=Hans,
84 subtitle=graphic]
85
86This time we get a cow as icon and the cow is also embedded as image. When
87writing this manual a click in Sumatra just opens the \PDF\ file, but when I
88embed an mp3 file, a saveas window pops up.
89
90The previous examples directly injected the attachment using the \type
91{\attachment} commands with the appropriate arguments. You can add titles, define
92a name that will be used when the attachment is saved:
93
94\starttyping
95\attachment[sometag][extra specs]
96\attachment[test.tex]
97\attachment[file=test.tex]
98\attachment[file=test.tex,method=hidden]
99\attachment[name=newname,file=test.tex]
100\attachment[title=mytitle,name=newname,file=test.tex]
101\stoptyping
102
103but theres also a more indirect way, for instance here we define some
104attachments:
105
106\starttyping
107\defineattachment[whatever1][file=test.tex]
108\defineattachment[whatever2][file=test.tex,method=hidden]
109\stoptyping
110
111that later can be called up with:
112
113\starttyping
114\attachment[whatever1][method=hidden]
115\attachment[whatever2]
116\stoptyping
117
118where of course hidden is to be omitted when you want an icon. The commands that
119are used to define and tune an instance are:
120
121\showsetup{defineattachment}
122
123\showsetup{setupattachment}
124
125There is one predefined instance:
126
127\starttyping
128\defineattachment[attachment]
129\stoptyping
130
131So we have:
132
133\showsetup{startattachment:instance}
134
135\showsetup{attachment:instance}
136
137Yet another level of abstraction can be achieved with:
138
139\showsetup{registerattachment}
140
141For example:
142
143\starttyping
144\registerattachment
145 [sometag]
146 [name=fool.txt,
147 file=foo.txt,
148 title=Fool me,
149 subtitle=Not you,
150 author= Joker]
151\stoptyping
152
153This is the \MKIV\ replacement for the \MKII\ method:
154
155\starttyping
156\useattachment[test.tex]
157\useattachment[whatever][test.tex]
158\useattachment[whatever][newname][test.tex]
159\useattachment[whatever][title][newname][test.tex]
160\stoptyping
161
162or with all options:
163
164\starttyping
165\useattachment[name][file][author][title][subtitle]
166\stoptyping
167
168The \type {\use...} variant stays around for old times sake and just maps onto
169\type {\registerattachment}, you can better use that one because it frees you
170from remembering which arguments is what for.
171
172\stopchapter
173
174\stopcomponent
175 |