Difference between revisions of "Command/ attachment"

From Wiki
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 23: Line 23:
 
   </cd:command>
 
   </cd:command>
 
</cd:variants>
 
</cd:variants>
<cd:description><!-- the long description of the command goes here -->
+
<cd:description>Additional documentation can be found in the [http://www.pragma-ade.com/general/manuals/interaction.pdf#page=29 "Interaction" manual].</cd:description>
</cd:description>
+
<cd:examples><cd:example title="Use of attachment with customized symbol (the file &quot;myattachment.txt&quot; should exists, that why the demo here does not show attachment...)">[[File:Screenshot_20201128_121950.png|800px]]
<cd:examples><cd:example title="Use of attachment with customized symbol (you need to create a file &quot;myattachment.txt&quot;), that why the demo here doesn't show attachment."><context source="yes" text="produces">
+
 
 +
<context source="yes" text="produces">
 
\setuppapersize[A6,landscape]
 
\setuppapersize[A6,landscape]
  
Line 34: Line 35:
 
%------------------------------------------------------------------------------
 
%------------------------------------------------------------------------------
  
\startuseMPgraphic{myattachmentsymbol}  % #1 - Draw a symbol, here a paperclip!                  
+
\startuseMPgraphic{myattachmentsymbol}  % #1 - Draw a symbol, here a paperclip!
path pa;
+
path pa;
 
numeric u; u=1mm;
 
numeric u; u=1mm;
 
numeric Ra; Ra=u/2;  numeric Rb; Rb=1.5Ra;  numeric Rc; Rc=1.35Rb;
 
numeric Ra; Ra=u/2;  numeric Rb; Rb=1.5Ra;  numeric Rc; Rc=1.35Rb;
Line 56: Line 57:
 
\stopuseMPgraphic
 
\stopuseMPgraphic
  
%------------------------------------------------------------------------------        
+
%------------------------------------------------------------------------------
  
 
\definesymbol                            % #2 - Define the drawing as a symbol
 
\definesymbol                            % #2 - Define the drawing as a symbol
Line 71: Line 72:
 
\starttext                                                        % #4 - Use it
 
\starttext                                                        % #4 - Use it
  
Text before  
+
Text before
 
\attachment
 
\attachment
 
   [file={myattachment.txt},
 
   [file={myattachment.txt},
Line 80: Line 81:
 
\stoptext
 
\stoptext
  
</context></cd:example></cd:examples>
+
</context>
 +
 
 +
</cd:example></cd:examples>
 
<cd:notes></cd:notes>
 
<cd:notes></cd:notes>
 
<cd:seealso>
 
<cd:seealso>

Latest revision as of 09:42, 13 December 2020


\attachment

Summary

The instances of \attachment are used for inclusion of attachment files into the PDF output.

Instances

\attachment

Settings instance

\ATTACHMENT[...][...=...,...]
[...]name
...=...,...inherits from \setupattachment

Description

Additional documentation can be found in the "Interaction" manual.

Examples

Use of attachment with customized symbol (the file "myattachment.txt" should exists, that why the demo here does not show attachment...)

Screenshot 20201128 121950.png

\setuppapersize[A6,landscape]

%------------------------------------------------------------------------------

\setupinteraction[state=start]                      % #0 - Activate interaction

%------------------------------------------------------------------------------

\startuseMPgraphic{myattachmentsymbol}  % #1 - Draw a symbol, here a paperclip!
path pa;
numeric u; u=1mm;
numeric Ra; Ra=u/2;  numeric Rb; Rb=1.5Ra;  numeric Rc; Rc=1.35Rb;
numeric La; La=3.5u; numeric Lb; Lb=-La/10; numeric Lc; Lc=1.2*La;

pair a[];
a0=(0,0);
a1=(La,0);        a2=(La+Ra,-Ra);         a3=(La,-2Ra);
a4=(Lb,-2Ra);     a5=(Lb-Rb,-2Ra+Rb);     a6=(Lb,-2Ra+2Rb);
a7=(Lc,-2Ra+2Rb); a8=(Lc+Rc,-2Ra+2Rb-Rc); a9=(Lc,-2Ra+2Rb-2Rc);
a10=(1u,-2Ra+2Rb-2Rc);

pa := (a0--a1..a2..a3--a4..a5..a6--a7..a8..a9--a10) rotated 45;

path pb;
pb := fullcircle scaled (2.2*(Lc-Lb-Rb)) shifted (center(pa)) ;
fill pb withcolor 0.5white;
pickup pencircle scaled (1.5*(Rb-Ra))   ;
draw pa  withcolor white;
\stopuseMPgraphic

%------------------------------------------------------------------------------

\definesymbol                             % #2 - Define the drawing as a symbol
  [myattachmentsym]
  [\useMPgraphic{myattachmentsymbol}]

%------------------------------------------------------------------------------

\setupattachments                          % #3 - Use the symbol for attachment
  [symbol=myattachmentsym]

%------------------------------------------------------------------------------

\starttext                                                        % #4 - Use it

Text before
\attachment
  [file={myattachment.txt},
   title={attachment title},
   location=rightmargin]
and after.

\stoptext

produces


Notes

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: