summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/embedall/embedall.sty
blob: f5ff6313f09f4505704a03069e322c1611ad81f0 (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
%%
%% This is file `embedall.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% embedall.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2013 by Alberto Sartori
%% 
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 of this license
%% or (at your option) any later version.  The latest version of this
%% license is in:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% and version 1.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{embedall}
    [2013/10/10 v1.0 embed files in pdf]

\RequirePackage{embedfile}
\RequirePackage{graphicx}
\RequirePackage{listings}
\RequirePackage{letltxmacro}

\newcommand\embedall@all{1}
\newcommand\embedall@graphicx{0}
\newcommand\embedall@list{0}
\newcommand\embedall@source{0}

\DeclareOption{graphicx}{\def\embedall@graphicx{1}\def\embedall@all{0}}
\DeclareOption{listings}{\def\embedall@list{1}\def\embedall@all{0}}
\DeclareOption{source}{\def\embedall@source{1}\def\embedall@all{0}}

\ProcessOptions

\LetLtxMacro\embedall@latex@includegraphics\includegraphics
\newcommand\embedall@includegraphics[2][]{%
    \embedfile[desc=image]{#2}
    \embedall@latex@includegraphics[#1]{#2}%
}

\LetLtxMacro\embedall@latex@lstinputlisting\lstinputlisting
\newcommand\embedall@lstinputlisting[2][]{%
    \embedfile[desc=listing file]{#2}
    \embedall@latex@lstinputlisting[#1]{#2}%
}

\DeclareRobustCommand\embedinput[2][input file]{%
    \input{#2}%
    \embedfile[desc={#1}]{#2}%
}

\ifnum\embedall@all=1%
    \def\embedall@graphicx{1}
    \def\embedall@list{1}
    \def\embedall@source{1}
\fi
\ifnum\embedall@graphicx=1%
    \LetLtxMacro\includegraphics\embedall@includegraphics
\fi
\ifnum\embedall@list=1%
    \LetLtxMacro\lstinputlisting\embedall@lstinputlisting
\fi

\IfFileExists{./\jobname.tex}{%
    \ifnum\embedall@source=1%
        \embedfile[desc=main source file]{\jobname.tex}\fi}{}

\endinput
%%
%% End of file `embedall.sty'.