summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tikzscale
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-01-03 23:32:34 +0000
committerKarl Berry <karl@freefriends.org>2013-01-03 23:32:34 +0000
commit0742ba6b44d3acf70563c8d4d7611cbb209641d7 (patch)
tree56eef89f369c8a61e17887f024ad40abd696231d /Master/texmf-dist/tex/latex/tikzscale
parentc2de5f2979b063faba1573870b6b21419cb8b0fa (diff)
tikzscale (3jan13)
git-svn-id: svn://tug.org/texlive/trunk@28716 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tikzscale')
-rw-r--r--Master/texmf-dist/tex/latex/tikzscale/tikzscale.sty121
1 files changed, 84 insertions, 37 deletions
diff --git a/Master/texmf-dist/tex/latex/tikzscale/tikzscale.sty b/Master/texmf-dist/tex/latex/tikzscale/tikzscale.sty
index 9213aff24eb..7937de6b1f5 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}[2012/11/03 v0.1.3 tikzscale LaTeX package]
+\ProvidesPackage{tikzscale}[2013/01/02 v0.2 tikzscale LaTeX package]
\RequirePackage{graphicx}
\RequirePackage{etoolbox}
\RequirePackage{pgfkeys}
@@ -22,24 +22,31 @@
\RequirePackage{xstring}
\AtEndPreamble{%
-\ifdef{\tikzifexternalizing}{%
+\ifExternalizationLoaded{%
\pgfkeys{/pgf/images/external info}%
}{}%
\ProvideDocumentCommand{\tikzsetnextfilename}{m}{}%
\ProvideDocumentCommand{\tikzsetexternalprefix}{m}{}%
\ProvideDocumentCommand{\tikzexternaldisable}{}{}%
\ProvideDocumentCommand{\tikzexternalenable}{}{}%
-\ProvideDocumentCommand{\tikzexternalize@hasbeencalled}{}{0}%
-\ifboolexpr{test {\ifundef{\tikzexternalize}} or test {\ifdefstring{\tikzexternalize@hasbeencalled}{0}}}{%
-\def\tikzscale@ifDrawAndScale#1#2{#1}%
+\def\tikzscale@ifExternalizationActive#1#2{%
+\ifExternalizationLoaded{%
+\ifdefequal{\tikz}{\tikzexternal@tikz@replacement}{%
+#1%
+}{%
+\ifdefequal{\tikz}{\tikzexternal@origtikz}{%
}{%
-\def\tikzscale@ifDrawAndScale#1#2{%
-\tikzifexternalizingnext{#1}{#2}%
+\PackageWarning{tikzscale}{Status of externalization is unknown, thus I assume it is deactivated.}%
+}%
+#2%
+}%
+}{%
+#2%
}%
}%
\@ifpackageloaded{tikz}{%
\newlength{\tikzscale@accuracy}%
-\setlength{\tikzscale@accuracy}{0.01pt}%
+\setlength{\tikzscale@accuracy}{\hfuzz}%
\def\maxTestIterations{10}%
}{}%
}
@@ -47,6 +54,16 @@
\pgfmathparse{#2}%
\global\let#1\pgfmathresult%
}
+\def\ifTikzLibraryLoaded#1#2#3{%
+\ifcsdef{tikz@library@#1@loaded}{%
+#2%
+}{%
+#3%
+}%
+}
+\def\ifExternalizationLoaded#1#2{%
+\ifTikzLibraryLoaded{external}{#1}{#2}%
+}
\def\edocsvlist#1{%
\edef\tikzscale@edocsvlist{#1}%
\expandafter\docsvlist\expandafter{\tikzscale@edocsvlist}%
@@ -102,8 +119,30 @@
}%
\LetLtxMacro{\tikzscale@oldincludegraphics}{\includegraphics}%
\LetLtxMacro{\includegraphics}{\tikzscale@includegraphics}%
-\pretocmd{\tikzpicture}{\LetLtxMacro{\includegraphics}{\tikzscale@oldincludegraphics}}{}{\PackageWarning{tikzscale}{Patching tikzpicture not successful}}%
-\apptocmd{\endtikzpicture}{\LetLtxMacro{\includegraphics}{\tikzscale@includegraphics}}{}{\PackageWarning{tikzscale}{Patching endtikzpicture not successful}}%
+\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}}%
+}%
+\tikzscale@patchTikzpicture
+\ifExternalizationLoaded{%
+\apptocmd{\tikzexternaldisable}{%
+\LetLtxMacro{\includegraphics}{\tikzscale@includegraphics}%
+\tikzscale@patchTikzpicture
+}{}{\PackageError{tikzscale}{Patching tikzexternaldisable failed}}%
+\apptocmd{\tikzexternalenable}{%
+\LetLtxMacro{\includegraphics}{\tikzscale@includegraphics}%
+\tikzscale@patchTikzpicture
+}{}{\PackageError{tikzscale}{Patching tikzexternalenable failed}}%
+\LetLtxMacro{\tikzscale@externalend@storeshifts}{\pgf@externalend@storeshifts}%
+\def\pgf@externalend@storeshifts#1{%
+\tikzscale@externalend@storeshifts{#1}%
+\ifpgfexternal@info
+\ifdef{\requestedAxisRatio}{%
+\immediate\write#1{\noexpand\pgfexternal@restore{\noexpand\def\noexpand\tikzscale@oldAxisRatio{\requestedAxisRatio}}}%
+}{}%
+\fi
+}%
+}{}%
}
\NewDocumentCommand{\tikzscale@includegraphics}{O{}m}{%
\begingroup
@@ -157,12 +196,44 @@ axisratio/.value required
}
\NewDocumentCommand{\tikzscale@includetikz}{O{}m}{%
\pgfkeys{/tikzscale, #1}%
-\tikzscale@ifDrawAndScale{%
+\tikzscale@ifExternalizationActive{%
+\tikzifexternalizingnext{%
\tikzscale@includetikzUnexternalized[#1]{#2}%
}{%
-\ifboolexpr{test {\ifdef{\tikzexternalgetnextfilename}}}{%
+\tikzscale@includetikzWithExternalization{#2}%
+}%
+}{%
+\tikzscale@includetikzUnexternalized[#1]{#2}%
+}%
+}
+\NewDocumentCommand{\tikzscale@includetikzUnexternalized}{O{}m}{%
+\elseif{test {\ifundef{\requestedWidth}} and test {\ifundef{\requestedHeight}} and test {\ifundef{\requestedAxisRatio}}}{%
+\input{#2}%
+}{test {\ifdef{\requestedWidth}} and test {\ifdef{\requestedHeight}}}{%
+\tikzscale@resizePlotTo{#2}%
+}{test {\ifdef{\requestedAxisRatio}}}{%
+\tikzscale@includeAxisRatio{#2}%
+}{test {\ifundef{\requestedAxisRatio}}}{%
+\ifdef{\pgfplotsset}{%
+\def\requestedAxisRatio{1}%
+\tikzscale@includeAxisRatio{#2}%
+}{%
+\tikzscale@includeNormalTikzpicture{#2}%
+}%
+}{%
+\tikzscale@invalidKeyError{#2}%
+}%
+}
+
+\NewDocumentCommand{\tikzscale@includetikzWithExternalization}{m}{%
\tikzexternalgetnextfilename{\tikzscale@externalizationName}%
\pgfexternalreaddpth{\tikzscale@externalizationName}%
+\IfFileExists{\tikzscale@externalizationName.dpth}{%
+\tikzscale@checkRequestedSizeChanges
+}{}%
+\input{#1}%
+}
+\NewDocumentCommand{\tikzscale@checkRequestedSizeChanges}{}{%
\ifdef{\requestedWidth}{%
\ifdef{\pgfexternalwidth}{%
\tikzscale@ifSizeDifference{\requestedWidth - \pgfexternalwidth}{%
@@ -186,35 +257,11 @@ axisratio/.value required
\tikzscale@ifSizeDifference{\requestedAxisRatio - \tikzscale@oldAxisRatio}{%
\tikzset{external/remake next}%
}{}%
-\global\undef{\tikzscale@oldAxisRatio}%
+\undef{\tikzscale@oldAxisRatio}%
}{%
\tikzset{external/remake next}%
}%
}{}%
-}{%
-\tikzset{external/remake next}%
-\PackageWarning{tikzscale}{Generate \tikzscale@externalizationName \MessageBreak because no file found}%
-}%
-\input{#2}%
-}%
-}
-\NewDocumentCommand{\tikzscale@includetikzUnexternalized}{O{}m}{%
-\elseif{test {\ifundef{\requestedWidth}} and test {\ifundef{\requestedHeight}} and test {\ifundef{\requestedAxisRatio}}}{%
-\input{#2}%
-}{test {\ifdef{\requestedWidth}} and test {\ifdef{\requestedHeight}}}{%
-\tikzscale@resizePlotTo{#2}%
-}{test {\ifdef{\requestedAxisRatio}}}{%
-\tikzscale@includeAxisRatio{#2}%
-}{test {\ifundef{\requestedAxisRatio}}}{%
-\ifdef{\pgfplotsset}{%
-\def\requestedAxisRatio{1}%
-\tikzscale@includeAxisRatio{#2}%
-}{%
-\tikzscale@includeNormalTikzpicture{#2}%
-}%
-}{%
-\tikzscale@invalidKeyError{#2}%
-}%
}
\NewDocumentCommand{\tikzscale@preparePlot}{}{%
\pgfplotsset{every axis/.append style={width=\tikzscale@width,height=\tikzscale@height,every axis/.style={}}}%