From 3e6b25207e86f8109b30b08f8b7498e932832ca7 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 14 Jan 2013 23:33:07 +0000 Subject: tikzscale (14jan13) git-svn-id: svn://tug.org/texlive/trunk@28834 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/tikzscale/tikzscale.sty | 115 ++++++++++++--------- 1 file changed, 64 insertions(+), 51 deletions(-) (limited to 'Master/texmf-dist/tex/latex/tikzscale') diff --git a/Master/texmf-dist/tex/latex/tikzscale/tikzscale.sty b/Master/texmf-dist/tex/latex/tikzscale/tikzscale.sty index 517f35a8634..38b78365249 100644 --- a/Master/texmf-dist/tex/latex/tikzscale/tikzscale.sty +++ b/Master/texmf-dist/tex/latex/tikzscale/tikzscale.sty @@ -13,7 +13,7 @@ %% ---------------------------------------------------------------- %% \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{tikzscale}[2013/01/09 v0.2.1 tikzscale LaTeX package] +\ProvidesPackage{tikzscale}[2013/01/13 v0.2.2 tikzscale LaTeX package] \RequirePackage{graphicx} \RequirePackage{etoolbox} \RequirePackage{pgfkeys} @@ -21,35 +21,6 @@ \RequirePackage{letltxmacro} \RequirePackage{xstring} -\AtEndPreamble{% -\ifExternalizationLoaded{% -\pgfkeys{/pgf/images/external info}% -}{}% -\ProvideDocumentCommand{\tikzsetnextfilename}{m}{}% -\ProvideDocumentCommand{\tikzsetexternalprefix}{m}{}% -\ProvideDocumentCommand{\tikzexternaldisable}{}{}% -\ProvideDocumentCommand{\tikzexternalenable}{}{}% -\def\tikzscale@ifExternalizationActive#1#2{% -\ifExternalizationLoaded{% -\ifdefequal{\tikz}{\tikzexternal@tikz@replacement}{% -#1% -}{% -\ifdefequal{\tikz}{\tikzexternal@origtikz}{% -}{% -\PackageWarning{tikzscale}{Status of externalization is unknown, thus I assume it is deactivated.}% -}% -#2% -}% -}{% -#2% -}% -}% -\@ifpackageloaded{tikz}{% -\newlength{\tikzscale@accuracy}% -\setlength{\tikzscale@accuracy}{\hfuzz}% -\def\maxTestIterations{10}% -}{}% -} \def\pgfmathsetglobalmacro#1#2{% \pgfmathparse{#2}% \global\let#1\pgfmathresult% @@ -111,39 +82,59 @@ } } \ExplSyntaxOff - +\def\tikzscale@ifExternalizationActive#1#2{% +\ifExternalizationLoaded{% +\ifdefequal{\tikz}{\tikzexternal@tikz@replacement}{% +#1% +}{% +\ifdefequal{\tikz}{\tikzexternal@origtikz}{% +}{% +\PackageWarning{tikzscale}{Status of externalization is unknown, thus I assume it is deactivated.}% +}% +#2% +}% +}{% +#2% +}% +}% \AtEndPreamble{% \def\tikzscale@tikzFileExtensions{.tikz,.TIKZ,.TikZ,.pgf,.PGF}% \DeclareGraphicsExtensions{\tikzscale@tikzFileExtensions,\Gin@extensions}% \ifdef{\currfiledir}{% +\ifdef{\Ginput@path}{% +\def\tikzscale@graphicspath{\Ginput@path,\currfiledir,{}}% +}{% \def\tikzscale@graphicspath{\currfiledir,{}}% +}% }{% \def\tikzscale@graphicspath{{}}% }% \LetLtxMacro{\tikzscale@oldincludegraphics}{\includegraphics}% -\LetLtxMacro{\includegraphics}{\tikzscale@includegraphics}% -\NewDocumentCommand{\tikzscale@patchTikzpicture}{}{% -\pretocmd{\tikzpicture}{% -\LetLtxMacro{\includegraphics}{\tikzscale@oldincludegraphics}% -}{}{\PackageError{tikzscale}{Patching tikzpicture failed}}% -\apptocmd{\endtikzpicture}{% -\LetLtxMacro{\includegraphics}{\tikzscale@includegraphics}% -}{}{\PackageError{tikzscale}{Patching endtikzpicture failed}}% -\apptocmd{\tikzpicture}{% -\ifdef{\tikzscale@restoreEndLineChar}{% -\tikzscale@restoreEndLineChar +\tikzscale@useEnhancedIncludegraphics +\tikzscale@patchTikzpictureIncludegraphics +\tikzscale@patchEndtikzpictureIncludegraphics +} +\AtEndPreamble{% +\ifExternalizationLoaded{% +\pgfkeys{/pgf/images/external info}% +}{}% +\ProvideDocumentCommand{\tikzsetnextfilename}{m}{}% +\ProvideDocumentCommand{\tikzsetexternalprefix}{m}{}% +\ProvideDocumentCommand{\tikzexternaldisable}{}{}% +\ProvideDocumentCommand{\tikzexternalenable}{}{}% +\@ifpackageloaded{tikz}{% +\newlength{\tikzscale@accuracy}% +\setlength{\tikzscale@accuracy}{\hfuzz}% +\def\maxTestIterations{10}% }{}% -}{}{\PackageError{tikzscale}{Patching tikzpicture failed}}% -}% -\tikzscale@patchTikzpicture \ifExternalizationLoaded{% \apptocmd{\tikzexternaldisable}{% -\LetLtxMacro{\includegraphics}{\tikzscale@includegraphics}% -\tikzscale@patchTikzpicture +\tikzscale@useEnhancedIncludegraphics +\tikzscale@patchTikzpictureIncludegraphics }{}{\PackageError{tikzscale}{Patching tikzexternaldisable failed}}% \apptocmd{\tikzexternalenable}{% -\LetLtxMacro{\includegraphics}{\tikzscale@includegraphics}% -\tikzscale@patchTikzpicture +\tikzscale@useEnhancedIncludegraphics +\tikzscale@patchTikzpictureIncludegraphics }{}{\PackageError{tikzscale}{Patching tikzexternalenable failed}}% \LetLtxMacro{\tikzscale@externalend@storeshifts}{\pgf@externalend@storeshifts}% \def\pgf@externalend@storeshifts#1{% @@ -159,8 +150,7 @@ \NewDocumentCommand{\tikzscale@includegraphics}{O{}m}{% \begingroup \LetLtxMacro{\includegraphics}{\tikzscale@oldincludegraphics}% -\edef\tikzscale@restoreEndLineChar{\endlinechar=\the\endlinechar\relax}% -\endlinechar=-1% +\tikzscale@FixEndLine \tikzscale@findExactFileName{tikzscale@fileName}{#2}% \tikzscale@isTikzFile{tikzscale@testTikzFile}{\tikzscale@fileName}% \ifcsdef{tikzscale@testTikzFile}{% @@ -171,6 +161,29 @@ }% \endgroup }% +\def\tikzscale@useEnhancedIncludegraphics{% +\LetLtxMacro{\includegraphics}{\tikzscale@includegraphics}% +} +\def\tikzscale@FixEndLine{% +\edef\tikzscale@restoreEndLineChar{\endlinechar=\the\endlinechar\relax}% +\endlinechar=-1% +\pretocmd{\tikzpicture}{% +\tikzscale@restoreEndLineChar +}{}{\PackageError{tikzscale}{Patching tikzpicture failed}}% +\apptocmd{\endtikzpicture}{% +\endlinechar=-1% +}{}{\PackageError{tikzscale}{Patching endtikzpicture failed}}% +}% +\def\tikzscale@patchTikzpictureIncludegraphics{% +\pretocmd{\tikzpicture}{% +\LetLtxMacro{\includegraphics}{\tikzscale@oldincludegraphics}% +}{}{\PackageError{tikzscale}{Patching tikzpicture failed}}% +} +\def\tikzscale@patchEndtikzpictureIncludegraphics{% +\apptocmd{\endtikzpicture}{% +\LetLtxMacro{\includegraphics}{\tikzscale@includegraphics}% +}{}{\PackageError{tikzscale}{Patching endtikzpicture failed}}% +} \NewDocumentCommand{\tikzscale@findExactFileName}{mm}{% \csundef{#1}% \def\tikzscale@checkDirectory##1{% -- cgit v1.2.3