summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/tikzscale
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-01-28 22:52:25 +0000
committerKarl Berry <karl@freefriends.org>2013-01-28 22:52:25 +0000
commit61da1767c34606cb616ac7f4d5b3ae9636142d08 (patch)
tree75c12695cc787a14fe609225de6fea2ea09bfec2 /Master/texmf-dist/source/latex/tikzscale
parent6eb4e4fd92e16d8e86fe34efa288c39269e91269 (diff)
tikzscale 0.2.3 (27jan13)
git-svn-id: svn://tug.org/texlive/trunk@28967 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/tikzscale')
-rw-r--r--Master/texmf-dist/source/latex/tikzscale/tikzscale.dtx106
1 files changed, 76 insertions, 30 deletions
diff --git a/Master/texmf-dist/source/latex/tikzscale/tikzscale.dtx b/Master/texmf-dist/source/latex/tikzscale/tikzscale.dtx
index 49c6f7a0174..b42266ccbaa 100644
--- a/Master/texmf-dist/source/latex/tikzscale/tikzscale.dtx
+++ b/Master/texmf-dist/source/latex/tikzscale/tikzscale.dtx
@@ -94,7 +94,7 @@ and the derived files tikzscale.ins,
%</internal>
%<*package>
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{tikzscale}[2013/01/13 v0.2.2 tikzscale LaTeX package]
+\ProvidesPackage{tikzscale}[2013/01/23 v0.2.3 tikzscale LaTeX package]
\RequirePackage{graphicx}
\RequirePackage{etoolbox}
\RequirePackage{pgfkeys}
@@ -189,6 +189,7 @@ and the derived files tikzscale.ins,
%\changes{v0.2}{2013/01/02}{Add default axis ratio; save axis ratio; support \cmd{\externaldisable} and \cmd{\externalenable}; improve robustness; increase speed}
%\changes{v0.2.1}{2013/01/09}{Fix graphics with data from text file due to wrong line breaks; fix plain old \LaTeX support}
%\changes{v0.2.2}{2013/01/13}{Fully support plain (dvi) \LaTeX; mind graphicspath}
+%\changes{v0.2.3}{2013/01/23}{Fix graphicspath bug; fix endlinechar bug, improve compatibility with beamer}
% \section{Introduction}
% When dealing with graphics, there are different scaling demands. For \emph{absolute} scaling, a width and/or height is given. Opposed to that, for relativ scaling, a horizontal and/or vertical scaling factor is needed. This package only is about absolute scaling of tikzpicture environments. The different absolute scaling demands and their solutions are shown in table \ref{scalingDemands}.
% \begin{table}
@@ -372,7 +373,6 @@ and the derived files tikzscale.ins,
%
% \section{Further Ideas}
% \begin{itemize}
-% \item The \cmd{\tikzscale@trim} commands generates a warning in the figure log files that "Scaling of linewidth.tikz was only (tikzscale) accurate to 202.83331pt on input line 30." and other warnings, but they do not seem to have any influence.
% \item It might be a good idea to use the file names as figure names, but probably only if the name was not already set by the user. Additionally, there must be taken care to not try to write into a directory where there is no write access (e.g. reading a graphic from a system wide TeX installation)
% \item if graphic files are located in a subdirectory, the externalized files should also be in that subdirectory.
% \item allow in-file graphics by redefining the tikzpicture environment and accepting tikzscale and tikz options. The tikzscale options are evaluated using key filtering (tikz library) and the tikz options are forwarded.
@@ -413,6 +413,15 @@ and the derived files tikzscale.ins,
% \item Reported a bug when using plain old \LaTeX with an eps file, which lead to a fix.
% \item Reported another bug when using plain old \LaTeX, which lead to some rework to fully support \LaTeX without additional code.
% \item Reported a bug when using \cmd{\graphicspath}, which lead to a fix.
+% \item Reported the bug when using \cmd{\graphicspath} again, which lead to a correct fix even if currfile is not used.
+% \end{itemize}
+% \item Andreas Tharang
+% \begin{itemize}
+% \item Reported that the beamer class is incompatible with tikzscale, which lead to a change in tikzscale to fix this incompatibility.
+% \end{itemize}
+% \item Klaus Pribil
+% \begin{itemize}
+% \item Reported an incompatibility with the pdfpages package, which lead to a fix in tikzscale.
% \end{itemize}
% \end{itemize}
%
@@ -572,18 +581,6 @@ and the derived files tikzscale.ins,
% \def\tikzscale@tikzFileExtensions{.tikz,.TIKZ,.TikZ,.pgf,.PGF,.tex,.TEX}%
\DeclareGraphicsExtensions{\tikzscale@tikzFileExtensions,\Gin@extensions}%
% \end{macrocode}
- % The \cmd{graphicspath} command is used to set additional directories, which are searched for graphics. \cmd{\Ginput@path} is used to get the \href{http://tex.stackexchange.com/a/58404}{current content}.
-% \begin{macrocode}
- \ifdef{\currfiledir}{%
- \ifdef{\Ginput@path}{%
- \def\tikzscale@graphicspath{\Ginput@path,\currfiledir,{}}%
- }{%
- \def\tikzscale@graphicspath{\currfiledir,{}}%
- }%
- }{%
- \def\tikzscale@graphicspath{{}}%
- }%
-% \end{macrocode}
% Save the \cmd{\includegraphics} \href{ftp://ftp.tu-chemnitz.de/pub/tex/macros/latex/required/graphics/grfguide.pdf}{command}.
% \begin{macrocode}
\LetLtxMacro{\tikzscale@oldincludegraphics}{\includegraphics}%
@@ -640,7 +637,7 @@ and the derived files tikzscale.ins,
% \begin{macrocode}
\ifExternalizationLoaded{%
% \end{macrocode}
-% \cmd{\tikzexternaldisable} and \cmd{\tikzexternalenable} normally unintentionally deactivate the tikzscale commands (as they restore the original TikZ commands), so let them restore the tikzscale commands instead. The idea is to get the tikzscale's includegraphics command being called and then redefine tikzpicture and do the rest of the work there.
+% \cmd{\tikzexternaldisable} and \cmd{\tikzexternalenable} normally unintentionally deactivate the tikzscale commands (as they restore the original TikZ commands), so let them restore the tikzscale commands instead. The idea is to get the tikzscale's includegraphics command being called and then redefine tikzpicture and do the rest of the work there. Do the patching always when \cmd{\tikzexternaldisable} or \cmd{\tikzexternalenable} is called, as the patching should also be done when \cmd{\includegraphics} is not used, but \cmd{\tikzpicture} is called directly.
% \begin{macrocode}
\apptocmd{\tikzexternaldisable}{%
\tikzscale@useEnhancedIncludegraphics
@@ -737,16 +734,14 @@ and the derived files tikzscale.ins,
% \begin{macrocode}
\def\tikzscale@FixEndLine{%
% \end{macrocode}
- % There is a leading space character introduced by the externalization library, if the file is input directly. Thus use a trick to avoid that space. Furthermore, TikZ introduces with a specific version a trailing space character. To get rid of all space character issues, just solve the problem here once an for all. Note, that the redefinition of \cmd{\endlinechar} is local to the current group, so it does not have to be restored at the end of the group.
+ % There is a leading space character introduced by the externalization library, if the file is input directly. Thus use a trick to avoid that space. Furthermore, TikZ introduces with a specific version a trailing space character. To get rid of all space character issues, just solve the problem here once an for all. Note, that the redefinition of \cmd{\endlinechar} is local to the current group, so it does not have to be restored at the end of the group.
% \begin{macrocode}
- \edef\tikzscale@restoreEndLineChar{\endlinechar=\the\endlinechar\relax}%
- \endlinechar=-1%
+ \edef\tikzscale@restoreEndLineChar{\endlinechar=\the\endlinechar\relax}%
+ \endlinechar=-1%
% \end{macrocode}
% Restore the \cmd{\endlinechar} during the execution of the tikzpicture environment. This is necessary, for example, if data is read from a table and the data entries are separated by newline characters. Not restoring the \cmd{\endlinechar} would \href{http://tex.stackexchange.com/q/89053/7323}{distort the data}. Use \cmd{\apptocmd} to call the command inside the group opened by tikzpicture. Thus, nothing has to be done in \cmd{\endtikzpicture} regarding \cmd{\endlinechar}.
% \begin{macrocode}
- \pretocmd{\tikzpicture}{%
- \tikzscale@restoreEndLineChar
- }{}{\PackageError{tikzscale}{Patching tikzpicture failed}}%
+ \tikzscale@addRestoreEndLineCharToTikzpicture
%
\apptocmd{\endtikzpicture}{%
\endlinechar=-1%
@@ -755,10 +750,20 @@ and the derived files tikzscale.ins,
% \end{macrocode}
%\end{macro}
%
+%\begin{macro}{\tikzscale@addRestoreEndLineCharToTikzpicture}
+% \begin{macrocode}
+\def\tikzscale@addRestoreEndLineCharToTikzpicture{%
+ \pretocmd{\tikzpicture}{%
+ \tikzscale@restoreEndLineChar
+ }{}{\PackageError{tikzscale}{Patching tikzpicture failed}}%
+}
+% \end{macrocode}
+%\end{macro}
+%
%\begin{macro}{\tikzscale@patchTikzpictureIncludegraphics}
% \begin{macrocode}
\def\tikzscale@patchTikzpictureIncludegraphics{%
- % Deactivate the new includegraphics command inside of tikzpictures, as a tikzpicture might load a PNG graphic or something and this should not be scaled by tikzscale but by TikZ or PGFPlots. Besides, the current implementation is not reentrant, so its not a good idea to call the macro recursively. The deactivation must be inside of tikzpicture, as a tikzpicture can be loaded without using includegraphics, thus it cannot be done there. Using \cmd{\apptocmd} to do a local definition inside of the group started by \cmd{\tikzpicture} does not work. The includegraphics commands really has to be deactivated here, as a tikzpicture including a PNG file might be called directly without calling includegraphics
+ % Deactivate the new includegraphics command inside of tikzpictures, as a tikzpicture might load a PNG graphic or something and this should not be scaled by tikzscale but by TikZ or PGFPlots. Besides, the current implementation is not reentrant, so its not a good idea to call the macro recursively. The deactivation must be inside of tikzpicture, as a tikzpicture can be loaded without using includegraphics, thus it cannot be done there. Using \cmd{\apptocmd} to do a local definition inside of the group started by \cmd{\tikzpicture} does not work. The \cmd{\includegraphics} command really has to be deactivated here, as a tikzpicture including a PNG file might be called directly without calling includegraphics.
% \begin{macrocode}
\pretocmd{\tikzpicture}{%
\LetLtxMacro{\includegraphics}{\tikzscale@oldincludegraphics}%
@@ -782,17 +787,20 @@ and the derived files tikzscale.ins,
% Find the exact file name of a graphic file by testing several paths and file endings if there are degrees of freedom. The file name is saved in the command sequence name given by the first argument.
% \begin{macrocode}
\NewDocumentCommand{\tikzscale@findExactFileName}{mm}{%
- % \end{macrocode}
+% \end{macrocode}
% Delete the return variable if it already exists to allow checking if a file has been found.
- % \begin{macrocode}
+% \begin{macrocode}
\csundef{#1}%
- % \end{macrocode}
+% \end{macrocode}
% Create a helper function used inside the file ending evaluation.
- % \begin{macrocode}
+% \begin{macrocode}
\def\tikzscale@checkDirectory##1{%
\def\tikzscale@checkExtension####1{%
\IfFileExists{##1#2####1}{%
- \csdef{#1}{##1#2####1}%
+% \end{macrocode}
+ % Use \cmd{\csedef} instead of \cmd{\csdef} here, to be completely sure to only have a string left. This avoids problems when using tikzscale together with the pdfpages package and should generally be the right thing.
+% \begin{macrocode}
+ \csedef{#1}{##1#2####1}%
\listbreak
}{}%
}%
@@ -801,6 +809,10 @@ and the derived files tikzscale.ins,
% \begin{macrocode}
\eforcsvlist{\tikzscale@checkExtension}{{},\Gin@extensions}%
}%
+% \end{macrocode}
+ % Set the graphics path, to also find graphics in the last (current) input directory or in completely separate paths. Set it here to get updates if the user uses the \cmd{graphicspath} command inside of the document body.
+% \begin{macrocode}
+ \tikzscale@setGraphicsPath
\eforcsvlist{\tikzscale@checkDirectory}{\tikzscale@graphicspath}%
% \end{macrocode}
% If no file has been found, return the given file name, as includegraphics should try its best.
@@ -812,7 +824,28 @@ and the derived files tikzscale.ins,
% \end{macrocode}
%\end{macro}
%
-% \begin{macro}{\tikzscale@findExactFileName}
+% \begin{macro}{\tikzscale@setGraphicsPath}
+ % The \cmd{graphicspath} command is used to set additional directories, which are searched for graphics. \cmd{\Ginput@path} is used to get the \href{http://tex.stackexchange.com/a/58404}{current content}.
+% \begin{macrocode}
+\NewDocumentCommand{\tikzscale@setGraphicsPath}{}{%
+ \ifdef{\currfiledir}{%
+ \ifdef{\Ginput@path}{%
+ \def\tikzscale@graphicspath{\currfiledir,\Ginput@path,{}}%
+ }{%
+ \def\tikzscale@graphicspath{\currfiledir,{}}%
+ }%
+ }{%
+ \ifdef{\Ginput@path}{%
+ \def\tikzscale@graphicspath{\Ginput@path,{}}%
+ }{%
+ \def\tikzscale@graphicspath{{}}%
+ }%
+ }%
+}%
+% \end{macrocode}
+%\end{macro}
+%
+% \begin{macro}{\tikzscale@isTikzFile}
% The first argument is the macro name (without backslash), which gets defined if the file is a tikzfile.
% The second argument is the file name.
% \begin{macrocode}
@@ -860,9 +893,10 @@ and the derived files tikzscale.ins,
% \cmd{\includegraphics}[width=\cmd{\linewidth}]{fileWithoutEnding}
% write
% \cmd{\tikzscale@includetikz}[width=\cmd{\linewidth}]{fileWithoutEnding}
-% If only one of width or height are given, scale proportionally to fulfill the requirement. If both are given, scale non-proportionally to required width and height. Therefore, for normal tikzpictures only give either width or height, as the aspect ratio is already determined by the coordinate limits in the tikzpicture, but give width and height for PGFPlots, as the aspect ratio is unknown for these plots. \cmd{\NewEnviron} could be used to handle something like verbose in a tikzpicture, but at the moment, this is unsupported.
+% If only one of width or height are given, scale proportionally to fulfill the requirement. If both are given, scale non-proportionally to required width and height. Therefore, for normal tikzpictures only give either width or height, as the aspect ratio is already determined by the coordinate limits in the tikzpicture, but give width and height for PGFPlots, as the aspect ratio is unknown for these plots. \cmd{\NewEnviron} could be used to handle something like verbose in a tikzpicture, but at the moment, this is unsupported. The used code is the same as the uncommented code, but also \href{http://tex.stackexchange.com/q/94781/7323}{compatible with class beamer}.
% \begin{macrocode}
-\NewDocumentCommand{\tikzscale@includetikz}{O{}m}{%
+% \NewDocumentCommand{\tikzscale@includetikz}{O{}m}{%
+\newcommand{\tikzscale@includetikz}[2][]{%
% \end{macrocode}
% Check the keys here already, as they are needed both to see if already externalized files fulfill their requirements and to handle unexternalized files.
% \begin{macrocode}
@@ -1311,6 +1345,12 @@ and the derived files tikzscale.ins,
% \begin{macrocode}
\NewDocumentCommand{\tikzscale@conditionalDisableExternalization}{}{%
\tikzexternaldisable
+% \end{macrocode}
+ % Restore the endlinechar here and not in the general \cmd{\tikzexternaldisable} code, as it should only be restored if \cmd{\includegraphics} had been called and not if a tikzpicture was called directly without using \cmd{\includegraphics}. If the externalization has not been loaded, the endlinechar would be redefined twice (which would probably also do not much harm).
+% \begin{macrocode}
+ \ifExternalizationLoaded{%
+ \tikzscale@addRestoreEndLineCharToTikzpicture
+ }{}%
}
% \end{macrocode}
%\end{macro}
@@ -1329,6 +1369,12 @@ and the derived files tikzscale.ins,
% \expandafter\tikzsetexternalprefix\expandafter{\tikzscale@pwd}%
% \expandnext{\tikzsetexternalprefix}{\tikzscale@pwd}%
\tikzexternalenable
+% \end{macrocode}
+ % Restore the endlinechar here and not in the general \cmd{\tikzexternalenable} code, as it should only be restored if \cmd{\includegraphics} had been called and not if a tikzpicture was called directly without using \cmd{\includegraphics}. If the externalization has not been loaded, the endlinechar would be redefined twice (which would probably also do not much harm).
+% \begin{macrocode}
+ \ifExternalizationLoaded{%
+ \tikzscale@addRestoreEndLineCharToTikzpicture
+ }{}%
}
% \end{macrocode}
%\end{macro}