summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tikzscale
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-11-02 23:36:07 +0000
committerKarl Berry <karl@freefriends.org>2012-11-02 23:36:07 +0000
commit97a3576bc906866a218e39f989e687700efceed8 (patch)
tree9af69dd6b0421d1888e7b9893fcd0bdedb63ad32 /Master/texmf-dist/tex/latex/tikzscale
parent62bda70668347cf8c7c69684d89c7907efc0106a (diff)
tikzscale (2nov12)
git-svn-id: svn://tug.org/texlive/trunk@28156 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/tikzscale')
-rw-r--r--Master/texmf-dist/tex/latex/tikzscale/tikzscale.sty44
1 files changed, 24 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/latex/tikzscale/tikzscale.sty b/Master/texmf-dist/tex/latex/tikzscale/tikzscale.sty
index 6e1f7952237..db61273c40e 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/10/31 v0.1 tikzscale LaTeX package]
+\ProvidesPackage{tikzscale}[2012/11/02 v0.1.2 tikzscale LaTeX package]
\RequirePackage{graphicx}
\RequirePackage{etoolbox}
\RequirePackage{pgfkeys}
@@ -29,7 +29,14 @@
\ProvideDocumentCommand{\tikzsetexternalprefix}{m}{}%
\ProvideDocumentCommand{\tikzexternaldisable}{}{}%
\ProvideDocumentCommand{\tikzexternalenable}{}{}%
-\ProvideDocumentCommand{\tikzifexternalizingnext}{mm}{#1}%
+\ProvideDocumentCommand{\tikzexternalize@hasbeencalled}{}{0}%
+\ifboolexpr{test {\ifundef{\tikzexternalize}} or test {\ifdefstring{\tikzexternalize@hasbeencalled}{0}}}{%
+\def\tikzscale@ifDrawAndScale#1#2{#1}%
+}{%
+\def\tikzscale@ifDrawAndScale#1#2{%
+\tikzifexternalizingnext{#1}{#2}%
+}%
+}%
\@ifpackageloaded{tikz}{%
\newlength{\tikzscale@accuracy}%
\setlength{\tikzscale@accuracy}{0.01pt}%
@@ -95,15 +102,17 @@
}%
\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@includegraphics}{O{}m}{%
\begingroup
+\LetLtxMacro{\includegraphics}{\tikzscale@oldincludegraphics}%
\edef\tikzscale@restoreEndLineChar{\endlinechar=\the\endlinechar\relax}%
\endlinechar=-1%
\tikzscale@findExactFileName{tikzscale@fileName}{#2}%
\tikzscale@isTikzFile{tikzscale@testTikzFile}{\tikzscale@fileName}%
\ifcsdef{tikzscale@testTikzFile}{%
-\LetLtxMacro{\includegraphics}{\tikzscale@oldincludegraphics}%
\tikzscale@includetikz[#1]{\tikzscale@fileName}%
}{%
\tikzscale@oldincludegraphics[#1]{\tikzscale@fileName}%
@@ -147,36 +156,27 @@ axisratio/.code = {\pgfmathsetmacro{\requestedAxisRatio}{#1}},
axisratio/.value required
}
\NewDocumentCommand{\tikzscale@includetikz}{O{}m}{%
-\ifdef{\tikzexternalgetnextfilename}{%
-\tikzexternalgetnextfilename{\tikzscale@externalizationName}%
-}{}%
\pgfkeys{/tikzscale, #1}%
-\tikzifexternalizingnext{%
+\tikzscale@ifDrawAndScale{%
\tikzscale@includetikzUnexternalized[#1]{#2}%
}{%
-\sbox{\tikzscale@measuredSize}{%
-\IfFileExists{\tikzscale@externalizationName.dpth}{%
-\input{\tikzscale@externalizationName.dpth}%
-\xdef\tikzscale@measuredWidth{\pgfexternalwidth}%
-\xdef\tikzscale@measuredHeight{\pgfexternalheight}%
-}{}%
-}%
+\ifboolexpr{test {\ifdef{\tikzexternalgetnextfilename}}}{%
+\tikzexternalgetnextfilename{\tikzscale@externalizationName}%
+\pgfexternalreaddpth{\tikzscale@externalizationName}%
\ifdef{\requestedWidth}{%
-\ifdef{\tikzscale@measuredWidth}{%
-\tikzscale@ifSizeDifference{\requestedWidth - \tikzscale@measuredWidth}{%
+\ifdef{\pgfexternalwidth}{%
+\tikzscale@ifSizeDifference{\requestedWidth - \pgfexternalwidth}{%
\tikzset{external/remake next}%
}{}%
-\global\undef{\tikzscale@measuredWidth}%
}{%
\tikzset{external/remake next}%
}%
}{}%
\ifdef{\requestedHeight}{%
-\ifdef{\tikzscale@measuredHeight}{%
-\tikzscale@ifSizeDifference{\requestedHeight - \tikzscale@measuredHeight}{%
+\ifdef{\pgfexternalheight}{%
+\tikzscale@ifSizeDifference{\requestedHeight - \pgfexternalheight}{%
\tikzset{external/remake next}%
}{}%
-\global\undef{\tikzscale@measuredHeight}%
}{%
\tikzset{external/remake next}%
}%
@@ -191,6 +191,10 @@ axisratio/.value required
\tikzset{external/remake next}%
}%
}{}%
+}{%
+\tikzset{external/remake next}%
+\PackageWarning{tikzscale}{Generate \tikzscale@externalizationName \MessageBreak because no file found}%
+}%
\input{#2}%
}%
}