summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/embedall/embedall.sty
blob: ae34ada404743453711dffde5b444f0eb295148b (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
%%
%% 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
%% Copyright (C) 2019 by David Lichti
%% 
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 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.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{embedall}[2019/05/18 v2.0 Automatically embed source files in PDF]
\newif\ifembedall@all
\embedall@alltrue
\newif\ifembedall@main
\embedall@mainfalse
\newif\ifembedall@input
\embedall@inputfalse
\newif\ifembedall@include
\embedall@includefalse
\newif\ifembedall@graphicx
\embedall@graphicxfalse
\newif\ifembedall@csvsimple
\embedall@csvsimplefalse
\newif\ifembedall@compat
\embedall@compatfalse
\DeclareOption{all}{\embedall@alltrue}
\DeclareOption{notall}{\embedall@allfalse}
\DeclareOption{main}{\embedall@maintrue\embedall@allfalse}
\DeclareOption{input}{\embedall@inputtrue\embedall@allfalse}
\DeclareOption{include}{\embedall@includetrue\embedall@allfalse}
\DeclareOption{graphicx}{\embedall@graphicxtrue\embedall@allfalse}
\DeclareOption{csvsimple}{\embedall@csvsimpletrue\embedall@allfalse}
\DeclareOption{compat}{\embedall@compattrue}
\ProcessOptions\relax
\ifembedall@all
    \embedall@maintrue
    \embedall@inputtrue
    \embedall@includetrue
    \embedall@graphicxtrue
    \embedall@csvsimpletrue
\fi
\RequirePackage{embedfile}
\RequirePackage{filehook}
\RequirePackage{currfile}
\RequirePackage{etoolbox}
\ifembedall@compat
    \RequirePackage{letltxmacro}
\fi
\newcommand\embedsource[1][]{\embedall@embed[#1]{\currfilename}}
\def\embedall@filelist{}
\newcommand{\embedall@embed}[2][]{%
    \xifinlist{#2}{\embedall@filelist}{}{%
        \newlinechar=`\^^J%
        \message{^^J^^Jembedall: Attaching file '#2'.^^J^^J}%
        \embedfile[#1]{#2}%
        \listxadd{\embedall@filelist}{#2}%
    }%
}
\ifembedall@compat
    \LetLtxMacro\embedall@latex@includegraphics\includegraphics
    \newcommand\embedall@includegraphics[2][]{%
        \embedall@embed[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}%
    }
    \ifembedall@input
        \DeclareRobustCommand\embedinput[2][]{%
            \input{#2}%
        }
    \else
        \DeclareRobustCommand\embedinput[2][input file]{%
            \input{#2}%
            \embedall@embed[desc={#1}]{#2}%
        }
    \fi
\fi
\ifembedall@main
    \ifembedall@compat
        \IfFileExists{./\jobname.tex}{%
            \embedall@embed[desc=main source file]{\jobname.tex}
        }{}
    \else
        \AtBeginDocument{\embedsource[desc=main source file]}
    \fi
\fi
\ifembedall@input
    \AtBeginOfInputs{\embedsource[desc=input file]}
\fi
\ifembedall@include
    \AtBeginOfIncludes{\embedsource[desc=include file]}
\fi
\ifembedall@graphicx
    \ifcsname Gin@setfile\endcsname
        \let\embedall@Gin@setfile\Gin@setfile
        \def\Gin@setfile#1#2#3{%
            \embedall@Gin@setfile{#1}{#2}{#3}%
            \embedall@embed[image file]{#3}%
        }
    \else
        \ifembedall@all\else
            \PackageWarning{embedall}{Patching of graphicx requested, but package not loaded. Consider removing the 'graphicx' option.}
        \fi
    \fi
\fi
\ifembedall@csvsimple
    \ifcsname csvloop\endcsname
        \let\embedall@csvloop\csvloop
        \def\csvloop#1{%
            \embedall@csvloop{#1}%
            \embedall@embed[CSV file]{\csv@input@filename}%
        }
    \else
        \ifembedall@all\else
            \PackageWarning{embedall}{Patching of csvsimple requested explicitly, but package not loaded. Consider removing the 'csvsimple' option.}
        \fi
    \fi
\fi
\endinput
%%
%% End of file `embedall.sty'.