diff options
author | Karl Berry <karl@freefriends.org> | 2019-05-21 21:03:31 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-05-21 21:03:31 +0000 |
commit | ae33300b5a7e260971065fd5c13c614351ba3754 (patch) | |
tree | 608a7cdd18b2795bfdb0e8fa769c657d2b93a184 /Master/texmf-dist/tex/latex/embedall | |
parent | 207abb781e607768591cc5d882990bb7071b2b3a (diff) |
embedall (21may19)
git-svn-id: svn://tug.org/texlive/trunk@51177 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/embedall')
-rw-r--r-- | Master/texmf-dist/tex/latex/embedall/embedall.sty | 170 |
1 files changed, 115 insertions, 55 deletions
diff --git a/Master/texmf-dist/tex/latex/embedall/embedall.sty b/Master/texmf-dist/tex/latex/embedall/embedall.sty index f5ff6313f09..ae34ada4047 100644 --- a/Master/texmf-dist/tex/latex/embedall/embedall.sty +++ b/Master/texmf-dist/tex/latex/embedall/embedall.sty @@ -9,70 +9,130 @@ %% 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.2 of this license -%% or (at your option) any later version. The latest version of this -%% license is in: +%% 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 +%% 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. +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. %% -\NeedsTeXFormat{LaTeX2e}[1994/06/01] -\ProvidesPackage{embedall} - [2013/10/10 v1.0 embed files in pdf] - +\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{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}% +\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}% + }% } - -\ifnum\embedall@all=1% - \def\embedall@graphicx{1} - \def\embedall@list{1} - \def\embedall@source{1} +\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 -\ifnum\embedall@graphicx=1% - \LetLtxMacro\includegraphics\embedall@includegraphics +\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 -\ifnum\embedall@list=1% - \LetLtxMacro\lstinputlisting\embedall@lstinputlisting +\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 - -\IfFileExists{./\jobname.tex}{% - \ifnum\embedall@source=1% - \embedfile[desc=main source file]{\jobname.tex}\fi}{} - \endinput %% %% End of file `embedall.sty'. |