summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/svg/svg.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/svg/svg.dtx')
-rw-r--r--Master/texmf-dist/source/latex/svg/svg.dtx1215
1 files changed, 824 insertions, 391 deletions
diff --git a/Master/texmf-dist/source/latex/svg/svg.dtx b/Master/texmf-dist/source/latex/svg/svg.dtx
index 46e17750e28..08d4cf59405 100644
--- a/Master/texmf-dist/source/latex/svg/svg.dtx
+++ b/Master/texmf-dist/source/latex/svg/svg.dtx
@@ -1,4 +1,4 @@
-% \CheckSum{3514}
+% \CheckSum{3809}
% \iffalse meta-comment
%
% svg and svg-extract -- Include and extract SVG pictures in LaTeX documents
@@ -115,7 +115,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
%<package&option&base>\ProvidesPackage{svg}[%
%<package&option&extract>\ProvidesPackage{svg-extract}[%
%<*driver|package&option>
- 2017/11/29 v2.01\space%
+ 2018/09/08 v2.02\space%
%<package&option&base> (include SVG pictures)%
%<package&option&extract> (extract independent graphics from SVG pictures)%
]
@@ -123,7 +123,6 @@ svg-extract -- Extract independent graphic files from SVG pictures
%<*driver>
\documentclass[english,xindy]{tudscrdoc}[2017/03/27]
\usepackage[T1]{fontenc}
-\usepackage{selinput}\SelectInputMappings{adieresis={ä},germandbls={ß}}
\usepackage{babel}
\KOMAoptions{parskip=half-}
\usepackage{marginnote}
@@ -239,6 +238,16 @@ svg-extract -- Extract independent graphic files from SVG pictures
% usage of \cs{input}\marg{tex filename} within \app{Inkscape}~graphics
% locates files in all declared searched folders
% }^^A
+% \changes{v2.02}{2018/09/07}{package \pkg{trimspaces} required}^^A
+% \changes{v2.02}{2018/09/07}{multiple dots within file names possible}^^A
+% \changes{v2.02}{2018/09/07}{%
+% fixed errors with active double qoutes from \pkg{babel} in path arguments%
+% }^^A
+% \changes{v2.02}{2018/09/07}{%
+% distortion of included and extracted graphics supported with options
+% \opt{distort} (or \opt{keepaspectratio}) and \opt{extractdistort}
+% as well as rotation for extractions (\opt{extractangle})
+% }^^A
%
%
%
@@ -273,16 +282,18 @@ svg-extract -- Extract independent graphic files from SVG pictures
% known to the operating system. This can be checked on shell by typing
% \file{inkscape -V}. Moreover, there are some required packages which are
% loaded by packages \pkg{svg} and \pkg{svg-extract} to provide the
-% functionallity. These packages are:
+% functionallity. These are:
% \begin{description}[parsep=.5\smallskipamount]
% \item[\pkg{scrbase}]
% for the definition and handling of options in key-value-syntax
-% \item[\pkg{ifluatex}, \pkg{ifpdf}, \pkg{ifxetex}]
+% \item[\pkg{ifpdf}, \pkg{ifluatex}, \pkg{ifxetex}]
% for flow control depending on the used \LaTeX~engine
% \item[\pkg{pdftexcmds}, \pkg{shellesc}]
% to allocate the same primitives independent of the used \LaTeX~engine
% \item[\pkg{ifplatform}]
% to control the file~access depending on the operating system
+% \item[\pkg{trimspaces}]
+% to remove unwanted spaces in file paths
% \item[\pkg{graphicx}]
% for including the graphic~files after the \app{Inkscape}~export
% \item[\pkg{xcolor},\pkg{transparent}]
@@ -369,7 +380,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% directories given with \cs{graphicspath} are searched too. Please keep in
% mind that the current working directory is browsed first in any case. It's
% recommended to avoid any spaces and/or quotes respectively \cs{dq} both in
-% paths and file~names, espacially when DVI~output is active.
+% paths and file~names, especially when DVI~output is active.
%
%
%
@@ -377,7 +388,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
%
% \DescribeOption{inkscape}
% This option controls, when the export with \app{Inkscape} is invoked and is
-% set to \val{true} by default.
+% \val{true} by default.
% \begin{DescribeValues}
% \item[false/off/no]
% \app{Inkscape} won't be invoked in any case, no export is done.
@@ -432,9 +443,16 @@ svg-extract -- Extract independent graphic files from SVG pictures
% working directory (\file{./relative/path/}) or as an absolute path.
% \end{DescribeValues}
%
+% \DescribeOption{inkscapename}
+% The file names of the \app{Inkscape}~export are derived from the name of the
+% base SVG~file and can be modified with \opt{inkscapename}|=|\meta{filename}.
+% It's possible to use counters for specifying the name of the exported file.
+% Repeatedly specifying the same file name will overwrite previously created
+% files.
+%
% \DescribeOption{inkscapeexe}
-% For the inclusion of a SVG~file, \app{Inkscape} is used to separate the text
-% and image from the SVG~file itself. In order to execute the command line tool
+% For including a SVG~file, \app{Inkscape} is used to separate the text and
+% image from the SVG~file itself. In order to execute the command line tool
% from shell, the path where the executable is located has to be known to the
% operating system. You can check this by typing \file{inkscape -V} into the
% shell. If this check fails and you don't want to change environment variable
@@ -494,16 +512,19 @@ svg-extract -- Extract independent graphic files from SVG pictures
%
% \subsection{Options for the graphic inclusion}
%
-% \DescribeOptions{width,height,scale}
+% \DescribeOptions{width,height,distort,scale}
% The width of the included graphic~file can be specified via the \opt{width}
% option and the height by the \opt{height} option. If both the width and
-% height are specified, the figure won't be distort but scaled such that
-% neither of the specified dimensions is exceeded. If \opt{width} and/or
-% \opt{height} once have been set, this can be reversed by setting them to
-% \val{0pt} or \cs{relax}.
-%
-% If neither \opt{width} nor \opt{height} are set, the included graphic~file
-% can also be scaled by setting \opt{scale} to a positive real number.
+% height are specified, the figure will be scaled such that neither of the
+% specified dimensions is exceeded, unless option \opt{distort}|=|\val{true} is
+% given.\footnote{\ignorespaces%
+% to provide compatibility for package \pkg{graphicx}, it's possible to use
+% \prm{keepaspectratio}|=|\val{true} as alias for \opt{distort}|=|\val{false}
+% and the other way round
+% } If \opt{width} and/or \opt{height} once have been set, this can be undone
+% by setting them to \val{0pt} or \cs{relax}. If neither \opt{width} nor
+% \opt{height} are set, the included graphic~file can also be scaled by setting
+% \opt{scale} to a positive real number.
%
% \DescribeOptions{pretex,apptex}
% Commands prior and post to the inclusion of the graphic~file may be desired,
@@ -523,9 +544,9 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \DescribeOption{lastpage}
% A \hrfn{https://bugs.launchpad.net/ubuntu/+source/inkscape/+bug/1417470}{bug}
% concerning the \LaTeX~export has been reported for \app{Inkscape}~0.91. It
-% may happen that within the \LaTeX~file exported by \app{Inkscape}, it is
-% attempted to include more pages of the PDF~graphics than actually exist. The
-% \pkg{svg} package attempts to bypass the resulting error.
+% may happen that within the exported \LaTeX~file, it's attempted to include
+% more pages of the PDF~graphics than actually exist. The \pkg{svg} package
+% attempts to bypass the resulting error.
%
% Consequently, the total number of pages is read and only existing PDF~pages
% are included, if both options \opt{inkscapeformat}|=|\val{pdf} and
@@ -549,7 +570,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{DescribeParameterParent}{Macro}{\includesvg}
% \DescribeParameters{%
% inkscape,inkscapeformat,inkscapelatex,inkscapearea,inkscapedpi,inkscapeopt,%
-% svgextension,width,height,scale,pretex,apptex,draft,%
+% svgextension,width,height,distort,scale,pretex,apptex,draft,%
% }
% It is used right in the same way but where \marg{svg filename} is the
% file~name of the SVG~file, where any given file~extension will be replaced
@@ -589,10 +610,10 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \DescribeParameters{angle,origin}
% Both parameters correlate to the identically named parameters of the
% \cs{includegraphics} command provided by the \pkg{graphicx} package. However,
-% unlike to \cs{includegraphics}, parameters \prm{angle} and \prm{origin} are
-% \emph{always evaluated after} the parameters \prm{widht}, \prm{height} and
+% unlike to \cs{includegraphics}, they \prm{angle} and \prm{origin} are
+% \emph{always evaluated after} \prm{widht}, \prm{height}, \prm{distort} and
% \prm{scale} by \cs{includesvg}, regardless of the used order of the given
-% parameters. This is mainly due to the inclusion of the \LaTeX~files
+% parameters. This is mainly due to the inclusion of the \LaTeX~files
% corresponding to the graphic~files generated by \app{Inkscape}.
% \end{DescribeParameterParent}
%
@@ -611,7 +632,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{DescribeParameterParent}{Macro}{\includeinkscape}
% \DescribeParameters{%
% inkscapeformat,inkscapelatex,%
-% width,height,scale,pretex,apptex,draft,lastpage,angle,origin,%
+% width,height,distort,scale,pretex,apptex,draft,lastpage,angle,origin,%
% }
% You can use it similar to \cs{includesvg} but \marg{graphic filename} has to
% be the filename of the already exported graphic file. If a valid
@@ -683,6 +704,22 @@ svg-extract -- Extract independent graphic files from SVG pictures
% using \opt{extract}|=|\val{true}/\val{false}.
%
% \DescribeMacros{\svgsetup,\includesvg,\includeinkscape}
+% With package \pkg{svg-extract} the applicable options for
+% \cs{svgsetup}\marg{options} as well as parameters for the already described
+% macros \cs{includesvg}\oarg{parameters}\marg{filename} and
+% \cs{includeinkscape}\oarg{parameters}\marg{filename} are extended. They can
+% be used to control the process of graphic extraction and converting.
+%
+% \begin{DescribeParameterParent}{Macro}{\includesvg}
+% \DescribeParameters{extractangle}
+% With this parameter the graphic is rotated during the extraction process. The
+% value is not inherited from \prm{angle} if it was given by default. this can
+% be achieved by setting:
+% \begin{svgexample}
+% \includesvg[angle=§\meta{angle}§,extractangle=inherit]§\marg{filename}§
+% \end{svgexample}
+% \end{DescribeParameterParent}
+%
% All option described below can be used togehter with \cs{svgsetup} and are
% then valid in the current scope. There also exist identically named
% parameters for the optional arguments of
@@ -690,29 +727,42 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \includesvg§\oarg{parameters}\marg{svg filename}§
% \includeinkscape§\oarg{parameters}\marg{graphic filename}§
% \end{svgexample}
-% These parameters have an effect only once when the commands are executed and
-% remain unchanged afterwards.
-% \begingroup
-% \renewcommand*\marginpar[2][]{}%
-% \begin{DescribeParameterParent}{Macro}{\includesvg}
-% \DescribeParameters{%
-% extract,extractpreamble,extractformat,extractruns,latexopt,%
-% extractwidth,extractheight,extractscale,extractpretex,extractapptex,%
-% convert,convertformat,convertdpi,%
-% magicksetting,magickoperator,gsopt,gsdevice,%
-% clean,exclude,%
-% }%
-% \end{DescribeParameterParent}
-% \begin{DescribeParameterParent}{Macro}{\includeinkscape}
-% \DescribeParameters{%
-% extract,extractpreamble,extractformat,extractruns,latexopt,%
-% extractwidth,extractheight,extractscale,extractpretex,extractapptex,%
-% convert,convertformat,convertdpi,%
-% magicksetting,magickoperator,gsopt,gsdevice,%
-% clean,exclude,%
-% }%
-% \end{DescribeParameterParent}
-% \endgroup
+% These parameters have an effect only once when the specific command is
+% executed and remain unchanged afterwards.
+% \begingroup\ignorespaces%
+% \newcommand*\parameterlist{}\ignorespaces%
+% \listadd\parameterlist{extract}\ignorespaces%
+% \listadd\parameterlist{extractpreamble}\ignorespaces%
+% \listadd\parameterlist{extractformat}\ignorespaces%
+% \listadd\parameterlist{extractruns}\ignorespaces%
+% \listadd\parameterlist{latexopt}\ignorespaces%
+% \listadd\parameterlist{extractwidth}\ignorespaces%
+% \listadd\parameterlist{extractheight}\ignorespaces%
+% \listadd\parameterlist{extractdistort}\ignorespaces%
+% \listadd\parameterlist{extractscale}\ignorespaces%
+% \listadd\parameterlist{extractangle}\ignorespaces%
+% \listadd\parameterlist{extractpretex}\ignorespaces%
+% \listadd\parameterlist{extractapptex}\ignorespaces%
+% \listadd\parameterlist{convert}\ignorespaces%
+% \listadd\parameterlist{convertformat}\ignorespaces%
+% \listadd\parameterlist{convertdpi}\ignorespaces%
+% \listadd\parameterlist{magicksetting}\ignorespaces%
+% \listadd\parameterlist{magickoperator}\ignorespaces%
+% \listadd\parameterlist{gsopt}\ignorespaces%
+% \listadd\parameterlist{gsdevice}\ignorespaces%
+% \listadd\parameterlist{clean}\ignorespaces%
+% \listadd\parameterlist{exclude}\ignorespaces%
+% \def\buffer{}\def\do#1{\buffer\prm{#1}\def\buffer{, }}\ignorespaces%
+% These parameters are: \dolistloop{\parameterlist}.
+% \renewcommand*\marginpar[2][]{}\ignorespaces%
+% \def\do#1{\DescribeParameter{#1}}\ignorespaces%
+% \begin{DescribeParameterParent}{Macro}{\includesvg}%
+% \dolistloop{\parameterlist}%
+% \end{DescribeParameterParent}%
+% \begin{DescribeParameterParent}{Macro}{\includeinkscape}%
+% \dolistloop{\parameterlist}%
+% \end{DescribeParameterParent}%
+% \endgroup%
%
%
%
@@ -758,8 +808,10 @@ svg-extract -- Extract independent graphic files from SVG pictures
% The file name is composed by the number of extracted files and the current
% outline numbering.
% \item[\meta{filename}]
-% You can use any file name, a given file extension is ignored. Repeatedly
-% specifying the same file name will overwrite previously created files.
+% You can use any file name, the file extension is derived from option
+% \opt{extractformat}. It's possible to use counters for specifying the
+% name of the extracted file. Repeatedly specifying the same file name will
+% overwrite previously created files.
% \end{DescribeValues}
%
% \DescribeOption{extractformat}
@@ -776,7 +828,8 @@ svg-extract -- Extract independent graphic files from SVG pictures
% is the default setting.
%
% \DescribeOptions{%
-% extractwidth,extractheight,extractscale,extractpretex,extractapptex,%
+% extractwidth,extractheight,extractdistort,extractscale,
+% extractpretex,extractapptex,%
% }
% These options can be used to overwrite the settings given for the appearance
% of a SVG~file within the document. For example, a SVG~file should cover the
@@ -789,7 +842,8 @@ svg-extract -- Extract independent graphic files from SVG pictures
% default---leads to the usage of the corresponding option of package \pkg{svg}
% (\opt{width}/\opt{height}/\opt{scale}/\opt{pretex}/\opt{apptex}), whereas
% \opt{extract\dots}|=|\val{\cs{relax}} can be used to ignore a parent option
-% utterly.
+% utterly. Only option \opt{extractdistort} is initialized to \val{false} and
+% does not inherit from \opt{distort} by default.
%
% \DescribeOptions{extractpreamble,extractpreambleend}
% Within the included and extracted SVG~files any \LaTeX~macro can be used
@@ -1018,7 +1072,6 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{svgexample}
% \documentclass{article}
% \usepackage[T1]{fontenc}
-% \usepackage{selinput}\SelectInputMappings{adieresis={ä},germandbls={ß}}
% \usepackage{svg}
% \usepackage[off]{svg-extract}
% \svgsetup{clean=true}
@@ -1224,7 +1277,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% converts this to a PNG~image~(\file{root.png}) by using \app{ImageMagick}.
% Enjoy plots from \app{ROOT} with natively rendered \LaTeX!
%
-% \StopEventually{\PrintIndex\PrintChanges\PrintToDos}
+% \StopEventually{\clearpage\PrintIndex\PrintChanges\PrintToDos}
%
% \iffalse
%<*package&option>
@@ -1236,6 +1289,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \appendix
% \part{Implementation}
% \section{Initialization}
+% \subsection{Packages}
%
% The package \pkg{svg} requires \pkg{scrbase} for options processing, the
% packages \pkg{ifluatex}, \pkg{ifpdf} and \pkg{ifxetex} for detecting the
@@ -1248,33 +1302,76 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{macrocode}
%<*base>
\RequirePackage{scrbase}[2016/06/14]
-\RequirePackage{ifxetex}[2010/09/12]
-\RequirePackage{ifluatex}[2016/05/16]
\RequirePackage{ifpdf}[2016/05/14]
+\RequirePackage{ifluatex}[2016/05/16]
+\RequirePackage{ifxetex}[2010/09/12]
\RequirePackage{pdftexcmds}[2016/05/21]
\RequirePackage{shellesc}[2016/06/07]
+\RequirePackage{trimspaces}[2009/09/17]
\RequirePackage{graphicx}[1999/02/16]
%</base>
%<*extract>
\RequirePackage{svg}[2017/03/27]
%</extract>
% \end{macrocode}
-% With the interface provided by package \pkg{scrbase} all options, which can
-% be set either as package options or with \cs{svgsetup}, as well as the
-% optional parameters for both user commands
+%
+% \iffalse
+%<*base>
+% \fi
+%
+% \subsection{Helper macros}
+%
+% \begin{macro}{\svg@tempa}
+% \begin{macro}{\svg@tempb}
+% \begin{macro}{\svg@box}
+% \begin{macro}{\if@svg@tempswa}
+% Internal temporary macros. The catcode for double quotes are also temporarily
+% changed.
+% \begin{macrocode}
+\newcommand*\svg@tempa{}
+\newcommand*\svg@tempb{}
+\newbox\svg@box
+\newif\if@svg@tempswa
+\edef\svg@catcodecodes@restore{%
+ \catcode`\noexpand\"\the\catcode`\"\relax%
+}
+\@makeother\"%
+% \end{macrocode}
+% \end{macro}^^A \if@svg@tempswa
+% \end{macro}^^A \svg@box
+% \end{macro}^^A \svg@tempb
+% \end{macro}^^A \svg@tempa
+%
+% \iffalse
+%</base>
+% \fi
+%
+%
+% \section{Including SVG files with package \pkg{svg}}
+% \subsection{Options}
+%
+% All options, which can be set either as package options or with
+% \cs{svgsetup}, as well as the optional parameters for both user commands
% \cs{includesvg}\oarg{parameters}\marg{svg filename} and
-% \cs{includeinkscape}\oarg{parameters}\marg{graphic filename} are defined.
+% \cs{includeinkscape}\oarg{parameters}\marg{graphic filename} are defined with
+% the interface provided by package \pkg{scrbase}.
% \begin{macrocode}
\DefineFamily{SVG}
\DefineFamilyMember{SVG}
% \end{macrocode}
+%
+% \iffalse
+%</package&option>
+%<*package&base>
+%<*option>
+% \fi
+%
% \begin{macro}{\svg@deprecated@key}
% With version v2.00 the whole user interface was renewed. For reasons of
% compatibility, outdated options and parameters from version~v1.0 are also
% provided. If an old key was given, a warning is issued and the valid key is
% used.
% \begin{macrocode}
-%<*base>
\newcommand*\svg@deprecated@key[3][svg]{%
\PackageWarning{#1}{%
The option key `#2' is deprecated.\MessageBreak%
@@ -1283,34 +1380,8 @@ svg-extract -- Extract independent graphic files from SVG pictures
}%
\FamilyOptions{SVG}{#3}%
}
-%</base>
% \end{macrocode}
% \end{macro}^^A \svg@deprecated@key
-% \begin{macro}{\svg@tempa}
-% \begin{macro}{\svg@tempb}
-% \begin{macro}{\if@svg@tempswa}
-% Internal temporary macros.
-% \begin{macrocode}
-%<*base>
-\newcommand*\svg@tempa{}
-\newcommand*\svg@tempb{}
-\newif\if@svg@tempswa
-%</base>
-% \end{macrocode}
-% \end{macro}^^A \if@svg@tempswa
-% \end{macro}^^A \svg@tempb
-% \end{macro}^^A \svg@tempa
-%
-% \iffalse
-%</package&option>
-%<*package&base>
-%<*option>
-% \fi
-%
-%
-%
-% \section{Including SVG files with package \pkg{svg}}
-% \subsection{Options}
%
% Within the exported \LaTeX~files of \app{Inkscape}, some commands are used
% out of additional packages. But maybe the user doesn't want to load this
@@ -1374,6 +1445,8 @@ svg-extract -- Extract independent graphic files from SVG pictures
%
% \begin{option}{inkscape}
% \changes{v2.00}{2017/02/17}{changed/extended}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@sanitize@dq}}^^A
+% \changes{v2.01}{2017/11/28}{using \cs{trim@spaces}}^^A
% \begin{macro}{\svg@ink@mode}
% The intension of option \opt{inkscape} is to control the running behaviour of
% \app{Inkscape}. It can be switched off at all (\opt{inkscape}|=|\val{false})
@@ -1385,7 +1458,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{macrocode}
\newcommand*\svg@ink@mode{}
\DefineFamilyKey{SVG}{inkscape}[true]{%
- \lowercase{\def\svg@tempa{#1}}%
+ \lowercase{\svg@sanitize@dq\svg@tempb{#1}}%
\FamilySetNumerical{SVG}{inkscape}{svg@tempa}{%
{false}{0},{off}{0},{no}{0},%
{true}{1},{on}{1},{yes}{1},{onlynewer}{1},{newer}{1},%
@@ -1396,7 +1469,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
{tex}{9},{latex}{9},{exportlatex}{9},{latexexport}{9},%
{notex}{10},{nolatex}{10},{noexportlatex}{10},{nolatexexport}{10},%
{latexnoexport}{10},{raw}{10},{plain}{10},{simple}{10}%
- }{\svg@tempa}%
+ }{\svg@tempb}%
\ifx\FamilyKeyState\FamilyKeyStateProcessed%
% \end{macrocode}
% Setting the mode for invoking \app{Inkscape}\dots
@@ -1433,7 +1506,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\def\svg@tempa##1dpi##2\@nil{%
\ifstr{##2}{dpi}{\FamilyOptions{SVG}{inkscapedpi=##1}}{}%
}%
- \lowercase{\svg@tempa#1dpi\@nil}%
+ \lowercase{\expandafter\svg@tempa\svg@tempb dpi\@nil}%
% \end{macrocode}
% In version~v1.0 the option \opt{inkscape} was used to set both the executable
% and options for \app{Inkscape}. This is taken into account here.
@@ -1445,14 +1518,21 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \cs{svg@tempa} and the option part---which is recognized by the first |-|
% character--- in \cs{svg@tempb}.
% \begin{macrocode}
+ \svg@quotes@remove[{#1}]{\svg@tempb}%
\def\svg@tempa##1-##2\@nil{%
\IfArgIsEmpty{##2}{\def\svg@tempb{}}{%
- \def\svg@tempa##1####1\@nil{\def\svg@tempb{####1}}%
- \svg@tempa#1\@nil%
+ \def\svg@tempa####1-\@nil{\def\svg@tempb{-####1}}%
+ \svg@tempa##2\@nil%
}%
- \def\svg@tempa{##1}%
+ \edef\svg@tempa{\trim@spaces{##1}}%
}%
- \svg@tempa#1-\@nil%
+ \edef\svg@tempb{%
+ \noexpand\svg@tempa\svg@tempb-\noexpand\@nil%
+ }%
+ \svg@tempb%
+ \if@svg@quotes@found%
+ \edef\svg@tempa{"\svg@tempa"}%
+ \fi%
\PackageWarning{svg}{%
Setting the executable%
\ifx\svg@tempb\@empty\else%
@@ -1642,6 +1722,8 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{option}^^A svgpath
% \begin{option}{svgextension}
% \changes{v2.01}{2017/11/27}{new due to user request}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@quotes@remove}}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@remove@leadingchar}}^^A
% \begin{option}{extension}
% \begin{option}{ext}
% \begin{macro}{\svg@file@ext}
@@ -1651,19 +1733,13 @@ svg-extract -- Extract independent graphic files from SVG pictures
\newcommand*\svg@file@ext{svg}
\DefineFamilyKey{SVG}{svgextension}{%
% \end{macrocode}
-% Remove leading dots from the extension.
+% The extension should be in lower case letters.
% \begin{macrocode}
- \def\svg@tempa##1.##2.##3\relax{%
- \IfArgIsEmpty{##1}{%
- \def\svg@file@ext{##2}%
- }{%
- \def\svg@file@ext{##1}%
- }%
- }%
+ \lowercase{\svg@quotes@remove[{#1}]{\svg@file@ext}}%
% \end{macrocode}
-% The extension should be in lower case letters.
+% Remove leading dots from the extension.
% \begin{macrocode}
- \lowercase{\svg@tempa#1..\relax}%
+ \svg@remove@leadingchar.\svg@file@ext%
}
\DefineFamilyKey{SVG}{extension}{\FamilyOptions{SVG}{svgextension=#1}}
\DefineFamilyKey{SVG}{ext}{\FamilyOptions{SVG}{svgextension=#1}}
@@ -1679,6 +1755,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
%
% \begin{option}{inkscapepath}
% \changes{v2.00}{2017/02/17}{new}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@sanitize@dq}}^^A
% \begin{option}{inkscapename}
% \changes{v2.00}{2017/02/17}{new}^^A
% \begin{macro}{\svg@out@path}
@@ -1692,12 +1769,13 @@ svg-extract -- Extract independent graphic files from SVG pictures
\newcommand*\svg@out@name{\svg@file@name\svg@file@suffix}
\newcommand*\svg@out@base{\svg@out@path\svg@out@name.\svg@ink@format}
\DefineFamilyKey{SVG}{inkscapepath}{%
+ \svg@sanitize@dq\svg@tempb{#1}%
\FamilySetNumerical{SVG}{inkscapepath}{svg@tempa}{%
{svgpath}{0},{svgdir}{0},%
{svgsubpath}{1},{svgsubdir}{1},%
{basepath}{2},{basedir}{2},{jobpath}{2},{jobdir}{2},%
{basesubpath}{3},{basesubdir}{3},{jobsubpath}{3},{jobsubdir}{3}%
- }{#1}%
+ }{\svg@tempb}%
\ifx\FamilyKeyState\FamilyKeyStateProcessed%
\ifcase\svg@tempa\relax% svgpath
\renewcommand*\svg@out@path{\svg@file@path}%
@@ -1709,7 +1787,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\renewcommand*\svg@out@path{./svg-inkscape/}%
\fi%
\else%
- \renewcommand*\svg@out@path{#1}%
+ \edef\svg@out@path{\svg@tempb}%
\svg@normalize@path{\svg@out@path}%
\FamilyKeyStateProcessed%
\fi%
@@ -1737,6 +1815,11 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{option}{height}
% \changes{v2.00}{2017/02/17}{new}^^A
% \begin{macro}{\svg@param@width}
+% \begin{option}{distort}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% \begin{option}{keepaspectratio}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% \begin{macro}{\if@svg@param@distort}
% \begin{option}{scale}
% \changes{v2.00}{2017/02/17}{new}^^A
% \begin{macro}{\svg@param@scale}
@@ -1752,8 +1835,10 @@ svg-extract -- Extract independent graphic files from SVG pictures
\FamilyKeyStateProcessed%
}{%
\FamilySetLengthMacro{SVG}{width}{\svg@param@width}{#1}%
- \ifdim\svg@param@width<\z@\relax%
- \FamilyKeyStateUnknownValue%
+ \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+ \ifdim\svg@param@width<\z@\relax%
+ \FamilyKeyStateUnknownValue%
+ \fi%
\fi%
}%
}
@@ -1765,11 +1850,25 @@ svg-extract -- Extract independent graphic files from SVG pictures
\FamilyKeyStateProcessed%
}{%
\FamilySetLengthMacro{SVG}{height}{\svg@param@height}{#1}%
- \ifdim\svg@param@height<\z@\relax%
- \FamilyKeyStateUnknownValue%
+ \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+ \ifdim\svg@param@height<\z@\relax%
+ \FamilyKeyStateUnknownValue%
+ \fi%
\fi%
}%
}
+\newif\if@svg@param@distort
+\FamilyBoolKey{SVG}{distort}{@svg@param@distort}
+\DefineFamilyKey{SVG}{keepaspectratio}[true]{%
+ \FamilySetBool{SVG}{keepaspectratio}{@svg@tempswa}{#1}%
+ \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+ \if@svg@tempswa%
+ \FamilyOptions{SVG}{distort=false}%
+ \else
+ \FamilyOptions{SVG}{distort=true}%
+ \fi%
+ \fi%
+}
\newcommand*\svg@param@scale{1}
\DefineFamilyKey{SVG}{scale}{%
\FamilyKeyStateUnknownValue%
@@ -1788,6 +1887,9 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{macrocode}
% \end{macro}^^A \svg@param@scale
% \end{option}^^A scale
+% \end{macro}^^A \if@svg@param@distort
+% \end{option}^^A keepaspectratio
+% \end{option}^^A distort
% \end{macro}^^A \svg@param@height
% \end{option}^^A height
% \end{macro}^^A \svg@param@width
@@ -1878,19 +1980,52 @@ svg-extract -- Extract independent graphic files from SVG pictures
% user-defined input and output paths. As there is the possibility for users to
% provide paths with or without quotes to \LaTeX, this is taken into account.
%
+% \begin{macro}{\svg@deactivate@dq}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% In order to avoid errors concerning file names with package \pkg{babel} and
+% it's active double quotes, this command is defined.
+% \begin{macrocode}
+\newcommand*\svg@deactivate@dq{}
+\AfterPackage*{babel}{%
+ \renewcommand*\svg@deactivate@dq{\bbl@deactivate{"}}%
+}
+% \end{macrocode}
+% \end{macro}^^A \svg@deactivate@dq
+% \begin{macro}{\svg@sanitize@dq}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% Save expansion of the second argument in the macro from teh first argument
+% with deactivated double quotes.
+% \begin{macrocode}
+\newcommand*\svg@sanitize@dq[2]{%
+ \begingroup%
+ \svg@deactivate@dq%
+ \edef\svg@tempa{\endgroup\def\noexpand#1{#2}}%
+ \svg@tempa%
+}
+% \end{macrocode}
+% \end{macro}^^A \svg@sanitize@dq
% \begin{macro}{\svg@quotes@remove}
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@sanitize@dq}}^^A
+% \changes{v2.02}{2018/09/07}{calling \cs{svg@quotes@check}}^^A
% \begin{macro}{\svg@quotes@@remove}
% These two commands are used to remove all occurring quotes within a string.
% The only argument passed to \cs{svg@quotes@remove} is not the string itself
% but a macro in which a string is stored.
% \begin{macrocode}
-\newcommand*\svg@quotes@remove[1]{%
+\newcommand*\svg@quotes@remove[2][]{%
\begingroup%
- \edef\svg@tempa{#1}%
+ \IfArgIsEmpty{#1}{\def\svg@tempb{#2}}{\def\svg@tempb{#1}}%
+ \svg@sanitize@dq\svg@tempa{\svg@tempb}%
+ \expandafter\svg@quotes@check\expandafter{\svg@tempa}%
\expandafter\svg@quotes@@remove\svg@tempa""\@nil%
\edef\svg@tempb{%
\endgroup%
- \noexpand\def\noexpand#1{\unexpanded\expandafter{\svg@tempa}}%
+ \def\noexpand#2{\svg@tempa}%
+ \if@svg@quotes@found%
+ \noexpand\@svg@quotes@foundtrue%
+ \else%
+ \noexpand\@svg@quotes@foundfalse%
+ \fi%
}%
\svg@tempb%
}
@@ -1926,10 +2061,35 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{macro}^^A \if@svg@quotes@found
% \end{macro}^^A \svg@quotes@@check
% \end{macro}^^A \svg@quotes@check
+% \begin{macro}{\svg@remove@leadingchar}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% This command removes the single character in given with the first argument
+% from the expanded macro in the second argument.
+% \begin{macrocode}
+\newcommand*\svg@remove@leadingchar[2]{%
+ \begingroup%
+ \svg@sanitize@dq\svg@tempa{#2}%
+ \def\svg@tempb{%
+ \def\svg@tempa####1\@nil{\def\svg@tempa{####1}}%
+ \kernel@ifnextchar#1%
+ {\expandafter\svg@tempa\@gobble}%
+ {\svg@tempa}%
+ }%
+ \expandafter\svg@tempb\svg@tempa\@nil%
+ \edef\svg@tempb{%
+ \endgroup%
+ \def\noexpand#2{\svg@tempa}%
+ }%
+ \svg@tempb%
+}
+% \end{macrocode}
+% \end{macro}^^A \svg@remove@leadingchar%
% \begin{macro}{\svg@set@input@path}
-% \changes{v2.01}{2017/11/28}{new}%
+% \changes{v2.01}{2017/11/28}{new}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@deactivate@dq}}^^A
% \begin{macro}{\svg@append@input@path}
-% \changes{v2.01}{2017/11/28}{new}%
+% \changes{v2.01}{2017/11/28}{new}^^A
+% \changes{v2.02}{2018/09/07}{avoid duplicates in \cs{input@path}}^^A
% In order to import SVG~files from different folders, \cs{svg@set@input@path}
% evaluates several macros, which are supposed to be used for holding different
% search folders. Any given path will be handled by \cs{svg@normalize@path}.
@@ -1937,12 +2097,14 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{macrocode}
\newcommand*\svg@set@input@path[1][]{%
\begingroup%
+ \svg@deactivate@dq%
% \end{macrocode}
% If a path was already found and stored within \cs{svg@file@path}, it is
% searched first and wrapped in curly braces. This is necessary for using
% commands like \cs{input}\marg{tex filename} within SVG~files.
% \begin{macrocode}
\ifx\svg@file@path\@empty\else%
+ \svg@normalize@path{\svg@file@path}%
\edef\svg@file@path{{\svg@file@path}}%
\fi%
% \end{macrocode}
@@ -1953,44 +2115,55 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{macrocode}
\svg@append@input@path{\svg@file@path}{\svg@input@path}%
\svg@append@input@path{\svg@file@path}{\Ginput@path}%
- \svg@append@input@path{\svg@file@path}{{#1}}%
+ \IfArgIsEmpty{#1}{}{\svg@append@input@path{\svg@file@path}{{#1}}}%
\svg@append@input@path{\svg@file@path}{\input@path}%
% \end{macrocode}
-% Passing each path to \cs{svg@normalize@path}.
-% \begin{macrocode}
- \def\svg@tempb{}%
- \expandafter\@tfor\expandafter\svg@tempa\expandafter:\expandafter=%
- \svg@file@path\do{%
- \ifx\svg@tempa\@empty\else%
- \svg@normalize@path{\svg@tempa}%
- \edef\svg@tempb{%
- \unexpanded\expandafter{\svg@tempb}{\svg@tempa}%
- }%
- \fi%
- }%
-% \end{macrocode}
% Finally, \cs{input@path} is set.
% \begin{macrocode}
\edef\svg@tempa{%
\endgroup%
- \ifx\svg@tempb\@empty\else%
- \noexpand\def\noexpand\input@path{\unexpanded\expandafter{\svg@tempb}}%
+ \ifx\svg@file@path\@empty\else%
+ \def\noexpand\input@path{\svg@file@path}%
\fi%
}%
\svg@tempa%
}
% \end{macrocode}
-% Only, if a certain search path is defined, it is added.
+% Only, if a certain search path is defined, it is added. The paths given in
+% the first argument are compared to each path in the second argument and only
+% new ones are added.
% \begin{macrocode}
\newcommand*\svg@append@input@path[2]{%
\ifx#2\@undefined\else%
- \edef#1{\unexpanded\expandafter{#1}#2}%
+ \edef\svg@tempb{#2}%
+ \expandafter\@tfor\expandafter\svg@tempa\expandafter:\expandafter=%
+ \svg@tempb\do{%
+% \end{macrocode}
+% Passing each new path to \cs{svg@normalize@path}. If a path already exists,
+% switch \cs{if@svg@tempswa} is set to \val{false}.
+% \begin{macrocode}
+ \ifx\svg@tempa\@empty\else%
+ \@svg@tempswatrue%
+ \svg@normalize@path{\svg@tempa}%
+ \expandafter\@tfor\expandafter\svg@tempb\expandafter:\expandafter=%
+ #1\do{%
+ \ifx\svg@tempa\svg@tempb%
+ \@svg@tempswafalse%
+ \@break@tfor%
+ \fi%
+ }%
+ \if@svg@tempswa%
+ \edef#1{#1{\svg@tempa}}%
+ \fi%
+ \fi%
+ }%
\fi%
}
% \end{macrocode}
% \end{macro}^^A \svg@append@input@path
% \end{macro}^^A \svg@set@input@path
% \begin{macro}{\svg@normalize@path}
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@deactivate@dq}}^^A
% \begin{macro}{\svg@normalize@@path}
% If any path is given, a trailing slash is needed. These two macros ensure
% that this condition is fulfilled in any case, even if this is not considered
@@ -1999,9 +2172,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{macrocode}
\newcommand*\svg@normalize@path[1]{%
\begingroup%
- \edef\svg@tempa{#1}%
- \svg@quotes@check{\svg@tempa}%
- \svg@quotes@remove{\svg@tempa}%
+ \svg@quotes@remove[{#1}]{\svg@tempa}%
\ifx\svg@tempa\@empty\relax%
\def\svg@tempa{./}%
\fi%
@@ -2009,9 +2180,9 @@ svg-extract -- Extract independent graphic files from SVG pictures
\edef\svg@tempb{%
\endgroup%
\if@svg@quotes@found%
- \noexpand\def\noexpand#1{"\unexpanded\expandafter{\svg@tempa}"}%
+ \def\noexpand#1{"\svg@tempa"}%
\else%
- \noexpand\def\noexpand#1{\unexpanded\expandafter{\svg@tempa}}%
+ \def\noexpand#1{\svg@tempa}%
\fi%
}%
\svg@tempb%
@@ -2022,7 +2193,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\IfArgIsEmpty{#1}{\def\svg@tempa{}}{\def\svg@tempa{#1/}}%
}{%
\svg@normalize@@path#2/\@nil%
- \edef\svg@tempa{#1/\unexpanded\expandafter{\svg@tempa}}%
+ \edef\svg@tempa{#1/\svg@tempa}%
}%
}
% \end{macrocode}
@@ -2054,7 +2225,8 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \fi
%
% \begin{macro}{\svg@get@path}
-% \changes{v2.01}{2017/11/28}{using \cs{svg@set@input@path}}%
+% \changes{v2.01}{2017/11/28}{using \cs{svg@set@input@path}}^^A
+% \changes{v2.01}{2017/11/28}{using \cs{trim@spaces}}^^A
% \begin{macro}{\if@svg@file@found}
% \begin{macro}{\svg@file@path}
% \begin{macro}{\svg@file@name}
@@ -2078,24 +2250,18 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{macrocode}
% A maybe given, unneeded file extension is removed.
% \begin{macrocode}
- \edef\svg@tempa{#2}%
- \svg@quotes@check{\svg@tempa}%
- \svg@quotes@remove{\svg@tempa}%
- \expandafter\svg@filename@parse\expandafter{\svg@tempa}%
+ \svg@filename@parse[{#1}]{#2}%
\IfArgIsEmpty{#1}{%
\edef\svg@tempa{\filename@area\filename@base.\filename@ext}%
}{%
\edef\svg@tempa{\filename@area\filename@base.#1}%
}%
- \if@svg@quotes@found%
- \edef\svg@tempa{"\svg@tempa"}%
- \fi%
% \end{macrocode}
% After calling \cs{svg@set@input@path}, all search paths are stored in
% \cs{input@path}, a single path given in the third argument will also be
% considered.
% \begin{macrocode}
- \svg@set@input@path[#3]%
+ \svg@set@input@path[{#3}]%
% \end{macrocode}
% The specified file is searched with \cs{IfFileExists}. If the file search was
% succesful, the macro \cs{svg@filename@parse} is called with the result.
@@ -2103,20 +2269,21 @@ svg-extract -- Extract independent graphic files from SVG pictures
\@svg@tempswafalse%
\expandafter\IfFileExists\expandafter{\svg@tempa}{%
\@svg@tempswatrue%
- \expandafter\svg@filename@parse\expandafter{\@filef@und}%
+ \edef\@filef@und{\expandafter\trim@spaces\expandafter{\@filef@und}}%
+ \svg@filename@parse[{#1}]{\@filef@und}%
}{}%
\edef\svg@tempa{%
\endgroup%
\if@svg@tempswa%
\noexpand\@svg@file@foundtrue%
- \noexpand\def\noexpand\svg@file@path{\filename@area}%
- \noexpand\def\noexpand\svg@file@name{\filename@base}%
- \noexpand\def\noexpand\svg@file@base{\filename@area\filename@base}%
+ \def\noexpand\svg@file@path{\filename@area}%
+ \def\noexpand\svg@file@name{\filename@base}%
+ \def\noexpand\svg@file@base{\filename@area\filename@base}%
\else%
\noexpand\@svg@file@foundfalse%
- \noexpand\def\noexpand\svg@file@path{}%
- \noexpand\def\noexpand\svg@file@name{#2}%
- \noexpand\def\noexpand\svg@file@base{#2}%
+ \def\noexpand\svg@file@path{}%
+ \def\noexpand\svg@file@name{#2}%
+ \def\noexpand\svg@file@base{#2}%
\fi%
}%
\svg@tempa%
@@ -2129,88 +2296,148 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{macro}^^A \if@svg@file@found
% \end{macro}^^A \svg@get@path
% \begin{macro}{\svg@filename@parse}
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@sanitize@dq}}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@remove@leadingchar}}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@extension@parse}}^^A
% As the internal \LaTeXe{} command \cs{filename@parse} is not able to split a
% given file name containing quotes, \cs{svg@filename@parse} is defined to
-% resolve this problem.
+% resolve this problem. The optional argument can be used to give a specific
+% file extension, which should be searched within \cs{filename@ext}. If found
+% at the very end, the previous part is appended to \cs{filename@base}.
% \begin{macrocode}
-\newcommand*\svg@filename@parse[1]{%
+\newcommand*\svg@filename@parse[2][]{%
\begingroup%
- \def\svg@tempa##1{%
- \def\svg@tempb####1####2\@nil{%
- \ifstr{####1}{"}{\def\svg@tempb{####2}}{\def\svg@tempb{####1####2}}%
- }%
- \expandafter\svg@tempb##1\@nil%
- \edef##1{\svg@tempb}%
- }%
% \end{macrocode}
-% The given path and file is parsed with \cs{filename@parse}. If an extension
-% was found, it is appended to the file name for a second parsing run.
+% The given path and file is parsed with \cs{filename@parse}.
% \begin{macrocode}
- \filename@parse{#1}%
- \ifx\filename@ext\relax\else%
- \edef\filename@base{\filename@base.\filename@ext}%
- \fi%
-% \end{macrocode}
+ \svg@sanitize@dq\svg@tempa{#2}%
+ \expandafter\filename@parse\expandafter{\svg@tempa}%
% If there are quotes in the file path, the closing one will be found as first
% character in \cs{filename@base} as \cs{filename@area} is splitted at the last
% slash. This leading quote is removed from \cs{filename@base} with
-% \cs{svg@tempa}.
+% \cs{svg@remove@leadingchar}.
% \begin{macrocode}
- \svg@quotes@check{\filename@area}%
+ \svg@quotes@remove{\filename@area}%
\if@svg@quotes@found%
- \svg@quotes@remove{\filename@area}%
\edef\filename@area{"\filename@area"}%
- \svg@tempa{\filename@base}%
+ \svg@remove@leadingchar"\filename@base%
\fi%
% \end{macrocode}
-% Before the second call of \cs{filename@parse} remaining quotes are removed
-% and the path in \cs{filename@area} is temporary stored in \cs{svg@tempa}.
+% The found extension is parsed against the optional argument. If a double quote
+% was found within the extension, it actually belongs to \cs{filename@base}.
% \begin{macrocode}
- \svg@quotes@check{\filename@base}%
- \if@svg@quotes@found%
- \svg@quotes@remove{\filename@base}%
+ \ifx\filename@ext\relax\else%
+ \svg@quotes@remove{\filename@ext}%
+ \svg@extension@parse{#1}%
+ \if@svg@quotes@found%
+ \edef\filename@base{\filename@base"}%
+ \fi%
\fi%
- \let\svg@tempa\filename@area%
- \expandafter\filename@parse\expandafter{\filename@base}%
- \let\filename@area\svg@tempa%
+% \end{macrocode}
+% Quotes within \cs{filename@base} are normalized.
+% \begin{macrocode}
+ \svg@quotes@remove{\filename@base}%
\if@svg@quotes@found%
- \edef\filename@base{"\filename@base"}%
+ \edef\filename@base{"\filename@base"}%
\fi%
% \end{macrocode}
% With \cs{svg@tempa} the group is closed and the results are saved in the
% macros \cs{filename@\dots}.
% \begin{macrocode}
\edef\svg@tempa{%
- \noexpand\endgroup%
- \noexpand\def\noexpand\filename@area{\filename@area}%
- \noexpand\def\noexpand\filename@base{\filename@base}%
+ \endgroup%
+ \def\noexpand\filename@area{\filename@area}%
+ \def\noexpand\filename@base{\filename@base}%
\ifx\filename@ext\relax%
- \noexpand\let\noexpand\filename@ext\noexpand\relax%
+ \let\noexpand\filename@ext\noexpand\relax%
\else%
- \noexpand\def\noexpand\filename@ext{\filename@ext}%
+ \def\noexpand\filename@ext{\filename@ext}%
\fi%
}%
\svg@tempa%
}
% \end{macrocode}
% \end{macro}^^A \svg@filename@parse
+% \begin{macro}{\svg@extension@parse}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% \begin{macro}{\svg@extension@@parse}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% These macros are used to permit multiple dots in file names. The content of
+% \cs{filename@ext} is split at each occurence of \val{.} and the trailing part
+% is compared against the content of the argument of \cs{svg@extension@parse},
+% which is probably \cs{svg@file@ext}. If they are equal, the previous part is
+% appended to \cs{filename@base} and \cs{filename@ext} is set to the content of
+% the first argument.
+% \begin{macrocode}
+\newcommand*\svg@extension@parse[1]{%
+ \IfArgIsEmpty{#1}{}{%
+ \ifstr{#1}{\filename@ext}{}{%
+ \begingroup%
+% \end{macrocode}
+% Macro \cs{svg@tempa} is used to temporarily store anything before the
+% searched extension at the end of \cs{filename@ext} and \cs{svg@tempb} is set
+% to the actual searched extension if found.
+% \begin{macrocode}
+ \edef\svg@tempa{%
+ \def\noexpand\svg@tempa{}%
+ \let\noexpand\svg@tempb\relax%
+ \noexpand\svg@extension@@parse%
+ \filename@ext.\noexpand\@nil#1\noexpand\@nil%
+ }%
+ \svg@tempa%
+ \edef\svg@tempa{%
+ \endgroup%
+% \end{macrocode}
+% If the trailing extension was found, \cs{filename@base} and \cs{filename@ext}
+% are adopted.
+% \begin{macrocode}
+ \def\noexpand\filename@base{\filename@base\svg@tempa}%
+ \ifx\svg@tempb\relax%
+ \let\noexpand\filename@ext\relax%
+ \else%
+ \def\noexpand\filename@ext{\svg@tempb}%
+ \fi%
+ }%
+ \svg@tempa%
+ }%
+ }%
+}
+% \end{macrocode}
+% Macro \cs{svg@extension@@parse} is recursively called as long as there are
+% any dots or the searched extension is found.
+% \begin{macrocode}
+\newcommand*\svg@extension@@parse{}
+\def\svg@extension@@parse#1.#2\@nil#3\@nil{%
+ \edef\svg@tempa{\svg@tempa.#1}%
+ \IfArgIsEmpty{#2}{}{%
+ \ifstr{#2}{#3.}{%
+% \end{macrocode}
+% If the trailing extension is found, \cs{svg@tempb} is definied.
+% \begin{macrocode}
+ \edef\svg@tempb{#3}%
+ }{%
+ \svg@extension@@parse#2\@nil#3\@nil%
+ }%
+ }%
+}
+% \end{macrocode}
+% \end{macro}^^A \svg@extension@@parse
+% \end{macro}^^A \svg@extension@parse
% \begin{macro}{\svg@file@missing}
+% \changes{v2.02}{2018/09/07}{notify svg file when missing exported files}^^A
% The error message, which is raised, if a file is missing either after the
% export with \app{Inkscape} or in general.
% \begin{macrocode}
\newcommand*\svg@file@missing[3][]{%
\begingroup%
- \edef\svg@tempa{#2}%
- \expandafter\svg@filename@parse\expandafter{\svg@tempa}%
- \svg@quotes@remove{\filename@area}%
- \svg@quotes@remove{\filename@base}%
- \ifx\filename@ext\relax\else%
- \svg@quotes@remove{\filename@ext}%
- \fi%
+ \svg@quotes@remove[{#2}]{\svg@tempa}%
+ \svg@filename@parse[{#1}]{\svg@tempa}%
\IfArgIsEmpty{#1}{%
+ \svg@quotes@remove[{#3}]{\svg@tempb}%
\def\svg@tempa{%
Did you run the export with Inkscape? There's no file\MessageBreak%
- `\filename@area\filename@base.\filename@ext'%
+ `\filename@area\filename@base.\filename@ext'\MessageBreak%
+ although `\svg@tempb' was found.%
}%
}{%
\edef\filename@ext{#1}%
@@ -2228,7 +2455,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\ifx\input@path\@undefined%
\def\svg@tempb{No additional path was given.}%
\else%
- \def\svg@tempb{Following folders have been searched:}%
+ \def\svg@tempb{Following folders have additionally been searched:}%
\expandafter\@tfor\expandafter\svg@tempa\expandafter:\expandafter=%
\input@path\do{%
\edef\svg@tempb{\svg@tempb\noexpand\MessageBreak\svg@tempa}%
@@ -2279,11 +2506,10 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{macrocode}
% \end{macro}^^A \svg@iffilenewer
%
-%
-%
% \subsection{Optional Parameters for user commands}
%
% \begin{macro}{\svg@local@param@set}
+% \changes{v2.02}{2018/09/07}{reasonable value for key \opt{distort}}^^A
% \begin{macro}{\svg@local@param@use}
% \begin{macro}{\svg@local@param@def}
% Most of the package options can also be used as optional parameters for
@@ -2302,6 +2528,17 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \val{png} with option \opt{inkscapeformat}.
% \begin{macrocode}
\ifstr{\svg@ink@format}{png}{\FamilyOptions{SVG}{inkscapelatex=false}}{}%
+% \end{macrocode}
+% Using \opt{distort=true} is only reasonable, if \opt{height} and \opt{width}
+% are given.
+% \begin{macrocode}
+ \@svg@tempswafalse%
+ \ifdim\svg@param@width>\z@\relax\ifdim\svg@param@height>\z@\relax%
+ \@svg@tempswatrue%
+ \fi\fi%
+ \if@svg@tempswa\else%
+ \FamilyOptions{SVG}{distort=false}%
+ \fi%
}
\newcommand*\svg@local@param@use{}
\newcommand*\svg@local@param@def[1]{%
@@ -2309,14 +2546,29 @@ svg-extract -- Extract independent graphic files from SVG pictures
\unexpanded\expandafter{\svg@local@param@use}\unexpanded{#1}%
}%
}
-\DefineFamilyMember[.param]{SVG}
% \end{macrocode}
% \end{macro}^^A \svg@local@param@def
% \end{macro}^^A \svg@local@param@use
% \end{macro}^^A \svg@local@param@set
%
+% \iffalse
+%</body>
+%</package&base>
+% \fi
+%
+% The family member is defined for both \pkg{svg} and \pkg{svg-extract}.
+% \begin{macrocode}
+%<*body>
+\DefineFamilyMember[.param]{SVG}
+%</body>
+% \end{macrocode}
%
%
+% \iffalse
+%<*package&base>
+%<*body>
+% \fi
+%
% \subsection{User commands}
%
% \begin{macro}{\svgsetup}
@@ -2334,6 +2586,9 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{macro}^^A \svgsetup
% \begin{macro}{\svgpath}
% \changes{v2.00}{2017/02/12}{new}^^A
+% \changes{v2.02}{2018/09/07}{%
+% parse argument for enclosing braces and provide if necessary%
+% }^^A
% \begin{macro}{\svg@input@path}
% With \cs{svgpath} the user can give several root paths to SVG~files in the
% same way as \cs{graphicspath} is used. The only difference is that a missing
@@ -2342,16 +2597,24 @@ svg-extract -- Extract independent graphic files from SVG pictures
\newcommand*\svg@input@path{}
\let\svg@input@path\input@path
\newcommand*\svgpath[1]{%
- \def\svg@input@path{#1}%
+ \def\svg@tempa##1\@nil{%
+ \ifx\svg@tempb\bgroup%
+ \def\svg@input@path{#1}%
+ \else%
+ \def\svg@input@path{{#1}}%
+ \fi%
+ }%
+ \futurelet\svg@tempb\svg@tempa#1\@nil%
}
% \end{macrocode}
% \end{macro}^^A \svg@input@path
% \end{macro}^^A \svgpath
% \begin{macro}{\includesvg}
% \changes{v2.00}{2017/02/17}{changes, especially to optional parameters}^^A
+% \changes{v2.02}{2018/09/07}{switched to \cs{svg@filename@parse}}^^A
% For the inclusion of SVG~files the command \cs{includesvg} is defined.
% \begin{macrocode}
-\newcommand*{\includesvg}[2][]{%
+\newcommand*\includesvg[2][]{%
\begingroup%
% \end{macrocode}
% Checking for deprecated commands \cs{svgwidth} and \cs{svgscale}.
@@ -2370,34 +2633,19 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \changes{v2.00}{2017/02/17}{new}^^A
% \begin{parameter}{inkscapeopt}
% \changes{v2.00}{2017/02/17}{new}^^A
+% \begin{parameter}{svgextension}
+% \changes{v2.01}{2017/11/27}{new}^^A
% \begin{parameter}{width}
% \begin{parameter}{height}
% \changes{v2.00}{2017/02/17}{new}^^A
+% \begin{parameter}{distort}
+% \changes{v2.02}{2018/07/09}{new}^^A
% \begin{parameter}{scale}
% \changes{v2.00}{2017/02/17}{new}^^A
% \begin{parameter}{pretex}
% \begin{parameter}{apptex}
% \begin{parameter}{draft}
% \changes{v2.00}{2017/02/17}{new}^^A
-% \begin{parameter}{extract}
-% \begin{parameter}{extractpreamble}
-% \begin{parameter}{extractformat}
-% \begin{parameter}{extractwidth}
-% \begin{parameter}{extractheight}
-% \begin{parameter}{extractscale}
-% \begin{parameter}{extractpretex}
-% \begin{parameter}{extractapptex}
-% \begin{parameter}{extractruns}
-% \begin{parameter}{latexopt}
-% \begin{parameter}{convert}
-% \begin{parameter}{convertformat}
-% \begin{parameter}{convertdpi}
-% \begin{parameter}{magicksetting}
-% \begin{parameter}{magickoperator}
-% \begin{parameter}{gsopt}
-% \begin{parameter}{gsdevice}
-% \begin{parameter}{clean}
-% \begin{parameter}{exclude}
% Most of the optional parameters have the same effect as the identically named
% options. Only parameter \prm{lastpage} is extended (see below). Moreover,
% there are some additional parameters, which can only be used as optional
@@ -2406,31 +2654,14 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{macrocode}
\svg@local@param@set{#1}%
% \end{macrocode}
-% \end{parameter}^^A exclude
-% \end{parameter}^^A clean
-% \end{parameter}^^A gsdevice
-% \end{parameter}^^A gsopt
-% \end{parameter}^^A magickoperator
-% \end{parameter}^^A magicksetting
-% \end{parameter}^^A convertdpi
-% \end{parameter}^^A convertformat
-% \end{parameter}^^A convert
-% \end{parameter}^^A latexopt
-% \end{parameter}^^A extractruns
-% \end{parameter}^^A extractapptex
-% \end{parameter}^^A extractpretex
-% \end{parameter}^^A extractscale
-% \end{parameter}^^A extractheight
-% \end{parameter}^^A extractwidth
-% \end{parameter}^^A extractformat
-% \end{parameter}^^A extractpreamble
-% \end{parameter}^^A extract
% \end{parameter}^^A draft
% \end{parameter}^^A apptex
% \end{parameter}^^A pretex
% \end{parameter}^^A scale
+% \end{parameter}^^A distort
% \end{parameter}^^A height
% \end{parameter}^^A width
+% \end{parameter}^^A svgextension
% \end{parameter}^^A inkscapeopt
% \end{parameter}^^A inkscapedpi
% \end{parameter}^^A inkscapearea
@@ -2457,12 +2688,12 @@ svg-extract -- Extract independent graphic files from SVG pictures
\svg@ink@run%
\IfFileExists{\svg@out@base}{}{%
\@svg@file@foundfalse%
- \svg@file@missing{\svg@out@base}{}%
+ \svg@file@missing{\svg@out@base}{\svg@file@base.\svg@file@ext}%
}%
\if@svg@ink@latex%
\IfFileExists{\svg@out@base_tex}{}{%
\@svg@file@foundfalse%
- \svg@file@missing{\svg@out@base_tex}{}%
+ \svg@file@missing{\svg@out@base_tex}{\svg@file@base.\svg@file@ext}%
}%
\fi%
% \end{macrocode}
@@ -2493,6 +2724,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{parameter}^^A lastpage
% \begin{parameter}{angle}
% \changes{v2.00}{2017/02/17}{new}^^A
+% \changes{v2.02}{2018/09/07}{validation of argument}^^A
% \begin{parameter}{origin}
% \changes{v2.00}{2017/02/17}{new}^^A
% The parameters \prm{angle} and \prm{origin} are definied as pendants to the
@@ -2501,8 +2733,10 @@ svg-extract -- Extract independent graphic files from SVG pictures
\newcommand*\svg@param@angle{0}
\svg@local@param@def{%
\DefineFamilyKey[.param]{SVG}{angle}{%
- \renewcommand*\svg@param@angle{#1}%
- \FamilyKeyStateProcessed%
+ \ifisdimension{#1\p@}{%
+ \renewcommand*\svg@param@angle{#1}%
+ \FamilyKeyStateProcessed%
+ }{}%
}%
}
\newcommand*\svg@param@origin{c}
@@ -2518,10 +2752,11 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{macro}^^A \includesvg
% \begin{macro}{\includeinkscape}
% \changes{v2.00}{2017/02/23}{new}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@extension@parse}}^^A
% The command \cs{includeinkscape} can be used for including the export results
% of \app{Inkscape}, if this part of the job was done in another way.
% \begin{macrocode}
-\newcommand*{\includeinkscape}[2][]{%
+\newcommand*\includeinkscape[2][]{%
\begingroup%
% \end{macrocode}
% Checking for deprecated commands \cs{svgwidth} and \cs{svgscale}.
@@ -2532,32 +2767,57 @@ svg-extract -- Extract independent graphic files from SVG pictures
% current setting for \opt{inkscapeformat}. If there's a suffix \file{\_tex},
% the option \opt{inkscapelatex} is set to \val{true} by default.
% \begin{macrocode}
- \filename@parse{#2}%
+ \svg@filename@parse{#2}%
\ifx\filename@ext\relax\else%
\svg@quotes@remove{\filename@ext}%
\expandafter\lowercase\expandafter{%
\expandafter\def\expandafter\filename@ext\expandafter{\filename@ext}%
}%
- \let\svg@tempb\filename@ext%
- \def\svg@tempa##1_tex##2\@nil{\def\svg@tempb{##1}}%
- \expandafter\svg@tempa\svg@tempb_tex\@nil%
- \@for\svg@tempa:={pdf,eps,ps,png}\do{%
- \ifstr{\svg@tempb}{\svg@tempa}{%
- \edef\svg@tempa{%
- \noexpand\FamilyOptions{SVG}{inkscapeformat=\svg@tempb}%
- }%
- \svg@tempa%
- }{}%
+ \def\svg@tempb##1_tex##2\@nil{%
+ \IfArgIsEmpty{##1}{}{\def\filename@ext{##1}}%
+ \ifstr{##2}{_tex}{\@svg@tempswatrue}{\@svg@tempswafalse}%
}%
- \ifstr{\filename@ext}{\svg@ink@format_tex}{%
- \FamilyOptions{SVG}{inkscapelatex=true}%
- }{}%
+ \@svg@tempswafalse%
+ \@tfor\svg@tempa:={pdf}{eps}{ps}{png}\do{%
+ \begingroup%
+ \expandafter\svg@tempb\filename@ext_tex\@nil%
+ \svg@extension@parse{\svg@tempa}%
+ \ifx\filename@ext\relax%
+ \def\svg@tempb{\endgroup}%
+ \else%
+ \edef\svg@tempb{%
+ \endgroup%
+ \noexpand\FamilyOptions{SVG}{inkscapeformat=\svg@tempa}%
+ \if@svg@tempswa%
+ \noexpand\FamilyOptions{SVG}{inkscapelatex=true}%
+ \fi%
+ \def\noexpand\filename@base{\filename@base}%
+ \def\noexpand\filename@ext{\filename@ext}%
+ \noexpand\@svg@tempswatrue%
+ }%
+ \fi%
+ \svg@tempb%
+% \end{macrocode}
+% Break for loop, if valid extension was found.
+% \begin{macrocode}
+ \if@svg@tempswa%
+ \@break@tfor%
+ \fi%
+ }%
+% \end{macrocode}
+% If no valid extension was found, it is set to the specified format and the
+% actual found one is appended to cs{\filename@base}.
+% \begin{macrocode}
+ \if@svg@tempswa\else%
+ \svg@extension@parse{\svg@ink@format}%
+ \fi%
\fi%
% \end{macrocode}
% \begin{parameter}{inkscapeformat}
% \begin{parameter}{inkscapelatex}
% \begin{parameter}{width}
% \begin{parameter}{height}
+% \begin{parameter}{distort}
% \begin{parameter}{scale}
% \begin{parameter}{pretex}
% \begin{parameter}{apptex}
@@ -2565,51 +2825,13 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{parameter}{lastpage}
% \begin{parameter}{angle}
% \begin{parameter}{origin}
-% \begin{parameter}{extract}
-% \begin{parameter}{extractpreamble}
-% \begin{parameter}{extractformat}
-% \begin{parameter}{extractwidth}
-% \begin{parameter}{extractheight}
-% \begin{parameter}{extractscale}
-% \begin{parameter}{extractpretex}
-% \begin{parameter}{extractapptex}
-% \begin{parameter}{extractruns}
-% \begin{parameter}{latexopt}
-% \begin{parameter}{convert}
-% \begin{parameter}{convertformat}
-% \begin{parameter}{convertdpi}
-% \begin{parameter}{magicksetting}
-% \begin{parameter}{magickoperator}
-% \begin{parameter}{gsopt}
-% \begin{parameter}{gsdevice}
-% \begin{parameter}{clean}
-% \begin{parameter}{exclude}
-% All parameters which are supported by \cs{includesvg} can also be used with
+% Parameters, which are supported by \cs{includesvg}, can also be used with
% \cs{includeinkscape} even if some of them---more precisely those that control
% the export with \app{Inkscape}---don't have an effect at all. Nevertheless,
% they are set right now in local context (within a group).
% \begin{macrocode}
\svg@local@param@set{#1}%
% \end{macrocode}
-% \end{parameter}^^A exclude
-% \end{parameter}^^A clean
-% \end{parameter}^^A gsdevice
-% \end{parameter}^^A gsopt
-% \end{parameter}^^A magickoperator
-% \end{parameter}^^A magicksetting
-% \end{parameter}^^A convertdpi
-% \end{parameter}^^A convertformat
-% \end{parameter}^^A convert
-% \end{parameter}^^A latexopt
-% \end{parameter}^^A extractruns
-% \end{parameter}^^A extractapptex
-% \end{parameter}^^A extractpretex
-% \end{parameter}^^A extractscale
-% \end{parameter}^^A extractheight
-% \end{parameter}^^A extractwidth
-% \end{parameter}^^A extractformat
-% \end{parameter}^^A extractpreamble
-% \end{parameter}^^A extract
% \end{parameter}^^A origin
% \end{parameter}^^A angle
% \end{parameter}^^A lastpage
@@ -2617,13 +2839,14 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{parameter}^^A apptex
% \end{parameter}^^A pretex
% \end{parameter}^^A scale
+% \end{parameter}^^A distort
% \end{parameter}^^A height
% \end{parameter}^^A width
% \end{parameter}^^A inkscapelatex
% \end{parameter}^^A inkscapeformat
% Searching all given paths for the relevant PDF/EPS~file.
% \begin{macrocode}
- \expandafter\svg@get@path\expandafter[\svg@ink@format]{#2}{\svg@out@path}%
+ \svg@get@path[\svg@ink@format]{\filename@area\filename@base}{\svg@out@path}%
\if@svg@file@found%
% \end{macrocode}
% Checking the required files for graphic inclusion.
@@ -2633,7 +2856,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\if@svg@ink@latex%
\IfFileExists{\svg@out@base_tex}{}{%
\@svg@file@foundfalse%
- \svg@file@missing{\svg@out@base_tex}{}%
+ \svg@file@missing{\svg@out@base_tex}{\svg@out@base}%
}%
\fi%
% \end{macrocode}
@@ -2719,8 +2942,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\ifnum\pdf@shellescape=\@ne\relax\if@svg@ink@run%
\svg@iffilenewer{\svg@out@base_tex}{\svg@out@base}{%
\@svg@ink@runfalse%
- \edef\svg@tempa{\svg@out@base}%
- \svg@quotes@remove{\svg@tempa}%
+ \svg@quotes@remove[\svg@out@base]{\svg@tempa}%
\PackageWarning{svg}{%
Since the encountered filedate of file\MessageBreak%
`\svg@tempa_tex' is newer than \MessageBreak%
@@ -2761,10 +2983,8 @@ svg-extract -- Extract independent graphic files from SVG pictures
% Executing \app{Inkscape} on command line. Afterwards, the export results are
% moved into the given output path.
% \begin{macrocode}
- \edef\svg@tempa{\svg@file@base}%
- \edef\svg@tempb{\svg@out@name}%
- \svg@quotes@remove{\svg@tempa}%
- \svg@quotes@remove{\svg@tempb}%
+ \svg@quotes@remove[\svg@file@base]{\svg@tempa}%
+ \svg@quotes@remove[\svg@out@name]{\svg@tempb}%
\ShellEscape{\svg@ink@cmd{\svg@tempa}{\svg@tempb}}%
\IfFileExists{\svg@out@name.\svg@ink@format}{%
\edef\svg@tempb{\svg@tempb.\svg@ink@format}%
@@ -2787,8 +3007,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% If \file{-{}-shell-escape} wasn't enabled, a warning is issued.
% \begin{macrocode}
\else%
- \edef\svg@tempa{\svg@file@base}%
- \svg@quotes@remove{\svg@tempa}%
+ \svg@quotes@remove[\svg@file@base]{\svg@tempa}%
\PackageWarning{svg}{%
You didn't enable `shell escape' (or `write18')\MessageBreak%
so it wasn't possible to launch the Inkscape export\MessageBreak%
@@ -2848,7 +3067,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\PackageInfo{svg}{Last page of `#1' is \the\@tempcnta}%
\fi%
\edef\svg@tempa{%
- \noexpand\endgroup%
+ \endgroup%
\noexpand\FamilyOptions{SVG}{lastpage=\the\@tempcnta}%
}%
\svg@tempa%
@@ -2894,44 +3113,82 @@ svg-extract -- Extract independent graphic files from SVG pictures
\@svg@ink@latexfalse%
\fi%
% \end{macrocode}
+% In order to support file names with multiple dots, the second argument is
+% parsed and only the part after the last dot is stroed in \cs{svg@tempb} as
+% extension. Everything before is stored in \cs{svg@tempa}.
+% \begin{macrocode}
+ \def\svg@tempb##1.##2\@nil{%
+ \IfArgIsEmpty{##2}{%
+ \def\svg@tempb{##1}%
+ }{%
+ \edef\svg@tempa{\svg@tempa.##1}%
+ \svg@tempb##2\@nil%
+ }%
+ }%
+ \edef\svg@tempa{%
+ \def\noexpand\svg@tempa{}%
+ \noexpand\svg@tempb#2.\noexpand\@nil%
+ }%
+ \svg@tempa%
+% \end{macrocode}
+% Afterwards \cs{svg@tempa} is defined with the file name itself within
+% enclosing braces followed by the extension and \cs{svg@tempb} holds the
+% original file name plus extension without enclosing braces.
+% \begin{macrocode}
+ \svg@remove@leadingchar.\svg@tempa%
+ \edef\svg@tempa{{\svg@tempa}.\svg@tempb}%
+ \edef\svg@tempb{#2}%
+% \end{macrocode}
% If the export with \app{Inkscape} was done with \LaTeX~support enabled, the
% corresponding file will be used together with \cs{input}. The necessary
% patches to environment \env{picture} as well as command \cs{includegraphics}
% are made beforehand with \cs{svg@patches}.
% \begin{macrocode}
- \edef\svg@tempa{#2}%
\if@svg@ink@latex%
\svg@patches{\svg@tempa}%
\ifnum\value{svg@param@lastpage}=\z@\relax%
- \expandafter\svg@get@lastpage\expandafter{\svg@tempa}%
+ \expandafter\svg@get@lastpage\expandafter{\svg@tempb}%
\fi%
\edef\svg@tempa{%
\ifx\svg@param@pretex\relax\else%
\noexpand\svg@param@pretex%
\fi%
- \noexpand\input{\svg@tempa_tex}%
+ \noexpand\input{\svg@tempb_tex}%
\ifx\svg@param@apptex\relax\else%
\noexpand\svg@param@apptex%
\fi%
}%
% \end{macrocode}
+% If \opt{distort=true} is desired, the input is resized with \cs{resizebox*}.
+% \begin{macrocode}
+ \if@svg@param@distort%
+ \def\svg@tempb{\resizebox*{\svg@param@width}{\svg@param@height}}%
+ \else%
+ \let\svg@tempb\@firstofone%
+ \fi%
+ \sbox\svg@box{\svg@tempb{\svg@tempa}}%
+% \end{macrocode}
% If a rotation angle was given, the input is done within \cs{rotatebox}.
% \begin{macrocode}
\ifdim\dimexpr\svg@param@angle\p@\relax=\z@\relax%
- \svg@tempa%
+ \let\svg@tempb\@firstofone%
\else%
- \edef\svg@tempb{origin=\svg@param@origin}%
- \expandafter\rotatebox\expandafter[\svg@tempb]{\svg@param@angle}{%
- \svg@tempa%
+ \edef\svg@tempb{%
+ \noexpand\rotatebox[origin=\svg@param@origin]{\svg@param@angle}%
}%
\fi%
+ \svg@tempb{\usebox\svg@box}%
\else%
% \end{macrocode}
% If the export with \app{Inkscape} was done without \LaTeX~support, the
% resulting graphic file will be included with \cs{includegraphics}.
% \begin{macrocode}
\svg@wrn@scale%
- \edef\svg@tempb{keepaspectratio,scale=\svg@param@scale}%
+ \edef\svg@tempb{%
+ draft\if@svg@draft\else=false\fi,%
+ scale=\svg@param@scale,%
+ keepaspectratio\if@svg@param@distort=false\fi%
+ }%
\ifdim\svg@param@height>\z@\relax%
\edef\svg@tempb{\svg@tempb,height=\svg@param@height}%
\fi%
@@ -2943,11 +3200,6 @@ svg-extract -- Extract independent graphic files from SVG pictures
\svg@tempb,origin=\svg@param@origin,angle=\svg@param@angle%
}%
\fi%
- \if@svg@draft%
- \edef\svg@tempb{\svg@tempb,draft}%
- \else%
- \edef\svg@tempb{\svg@tempb,draft=false}%
- \fi%
\expandafter\includegraphics\expandafter[\svg@tempb]{\svg@tempa}%
\fi%
}
@@ -3050,10 +3302,10 @@ svg-extract -- Extract independent graphic files from SVG pictures
}%
\fi%
% \end{macrocode}
-% Pages are only included, if counter \cnt{svg@param@lastpage} is smaller than
-% \cnt{svg@param@currpage}, where \cnt{svg@param@lastpage} was either given as
-% a number with parameter \prm{lastpage} or was automatically calculated with
-% \cs{svg@get@lastpage}.
+% Only if counter \cnt{svg@param@lastpage} is smaller than
+% \cnt{svg@param@currpage}, pages are included, where \cnt{svg@param@lastpage}
+% was either given as a number with parameter \prm{lastpage} or was
+% automatically calculated with \cs{svg@get@lastpage}.
% \begin{macrocode}
\ifnum\value{svg@param@currpage}>\value{svg@param@lastpage}\relax\else%
% \end{macrocode}
@@ -3076,7 +3328,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
%
%
%
-% \section{Extracting independent graphic files with package \pkg{svg-extract}}
+% \section{Extracting independent graphic files with \pkg{svg-extract}}
% \subsection{Options}
%
% For package \pkg{svg-extract} the user interface is extended. The following
@@ -3211,7 +3463,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
}%
\svg@deprecated@key{pdf}{extractformat={\svgx@format}}%
\else%
- \FamilyKeyStateUnknownValue
+ \FamilyKeyStateUnknownValue%
\fi%
\fi%
}
@@ -3224,7 +3476,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
}%
\svg@deprecated@key{eps}{extractformat={\svgx@format}}%
\else%
- \FamilyKeyStateUnknownValue
+ \FamilyKeyStateUnknownValue%
\fi%
\fi%
}
@@ -3441,7 +3693,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
`pdftopsopt' instead. See the manual for\MessageBreak%
more. Nothing was done%
}%
- \FamilyKeyStateProcessed
+ \FamilyKeyStateProcessed%
}
%</extract>
% \end{macrocode}
@@ -3594,7 +3846,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
}%
\svg@deprecated@key{png}{convertformat={\svgx@cnv@format}}%
\else%
- \FamilyKeyStateUnknownValue
+ \FamilyKeyStateUnknownValue%
\fi%
\fi%
}
@@ -3739,10 +3991,12 @@ svg-extract -- Extract independent graphic files from SVG pictures
%
% \begin{option}{extractpath}
% \changes{v2.00}{2017/02/24}{new}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@sanitize@dq}}^^A
% \begin{option}{path}
% \changes{v2.00}{2017/02/24}{deprecated}^^A
% \begin{option}{extractname}
% \changes{v2.00}{2017/02/24}{new}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg@quotes@remove}}^^A
% \begin{option}{name}
% \changes{v2.00}{2017/02/24}{deprecated}^^A
% \changes{v2.00}{2017/02/24}{support of \pkg{subfig} removed}^^A
@@ -3764,12 +4018,13 @@ svg-extract -- Extract independent graphic files from SVG pictures
%<*extract>
\newcommand*\svgx@out@path{}
\DefineFamilyKey{SVG}{extractpath}{%
+ \svg@sanitize@dq\svg@tempb{#1}%
\FamilySetNumerical{SVG}{extractpath}{svg@tempa}{%
{svgpath}{0},{svgdir}{0},%
{svgsubpath}{1},{svgsubdir}{1},%
{basepath}{2},{basedir}{2},{jobpath}{2},{jobdir}{2},%
{basesubpath}{3},{basesubdir}{3},{jobsubpath}{3},{jobsubdir}{3}%
- }{#1}%
+ }{\svg@tempb}%
\ifx\FamilyKeyState\FamilyKeyStateProcessed%
\ifcase\svg@tempa\relax% svgpath
\renewcommand*\svgx@out@path{\svg@file@path}%
@@ -3781,7 +4036,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\renewcommand*\svgx@out@path{./svg-extract/}%
\fi%
\else%
- \renewcommand*\svgx@out@path{#1}%
+ \edef\svgx@out@path{\svg@tempb}%
\svg@normalize@path{\svgx@out@path}%
\FamilyKeyStateProcessed%
\fi%
@@ -3793,12 +4048,13 @@ svg-extract -- Extract independent graphic files from SVG pictures
\newcommand*\svgx@out@name{}
\newif\if@svgx@out@sec
\DefineFamilyKey{SVG}{extractname}{%
+ \svg@quotes@remove[{#1}]{\svg@tempb}%
\FamilySetNumerical{SVG}{extractname}{svg@tempa}{%
{filename}{0},{name}{0},%
{filenamenumbered}{1},{namenumbered}{1},%
{numberedfilename}{1},{numberedname}{1},%
{numbered}{2},{section}{2},{numberedsection}{2},{sectionnumbered}{2}%
- }{#1}%
+ }{\svg@tempb}%
\@svgx@out@secfalse%
\ifx\FamilyKeyState\FamilyKeyStateProcessed%
\ifcase\svg@tempa\relax% filename
@@ -3810,10 +4066,11 @@ svg-extract -- Extract independent graphic files from SVG pictures
\@svgx@out@sectrue%
\fi%
\else%
- \def\svg@tempa##1.##2\@nil{%
- \IfArgIsEmpty{##1}{}{\renewcommand*\svgx@out@name{##1}}%
- }%
- \svg@tempa#1.\@nil%
+ \if@svg@quotes@found%
+ \edef\svgx@out@name{"\svg@tempb"}%
+ \else%
+ \edef\svgx@out@name{\svg@tempb}%
+ \fi%
\FamilyKeyStateProcessed%
\fi%
}
@@ -3841,6 +4098,10 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{option}{extractheight}
% \changes{v2.00}{2017/02/20}{new}^^A
% \begin{macro}{\svgx@param@width}
+% \begin{option}{extractdistort}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% \begin{option}{extractkeepaspectratio}
+% \begin{macro}{\svgx@param@distort}
% \begin{option}{extractscale}
% \changes{v2.00}{2017/02/20}{new}^^A
% \begin{macro}{\svgx@param@scale}
@@ -3853,6 +4114,8 @@ svg-extract -- Extract independent graphic files from SVG pictures
%<*base>
\svg@dummy@key{extractwidth}
\svg@dummy@key{extractheight}
+\svg@dummy@key{extractdistort}
+\svg@dummy@key{extractkeepaspectratio}
\svg@dummy@key{extractscale}
%</base>
%<*extract>
@@ -3868,8 +4131,10 @@ svg-extract -- Extract independent graphic files from SVG pictures
\FamilyKeyStateProcessed%
}{%
\FamilySetLengthMacro{SVG}{extractwidth}{\svgx@param@width}{#1}%
- \ifdim\svgx@param@width<\z@\relax%
- \FamilyKeyStateUnknownValue%
+ \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+ \ifdim\svgx@param@width<\z@\relax%
+ \FamilyKeyStateUnknownValue%
+ \fi%
\fi%
}%
}%
@@ -3886,12 +4151,41 @@ svg-extract -- Extract independent graphic files from SVG pictures
\FamilyKeyStateProcessed%
}{%
\FamilySetLengthMacro{SVG}{extractheight}{\svgx@param@height}{#1}%
- \ifdim\svgx@param@height<\z@\relax%
- \FamilyKeyStateUnknownValue%
+ \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+ \ifdim\svgx@param@height<\z@\relax%
+ \FamilyKeyStateUnknownValue%
+ \fi%
\fi%
}%
}%
}
+\newif\if@svgx@param@distort
+\DefineFamilyKey{SVG}{extractdistort}[true]{%
+ \FamilyKeyStateUnknownValue%
+ \svg@ifvalueisrelax{#1}{%
+ \@svgx@param@distortfalse%
+ \FamilyKeyStateProcessed%
+ }{%
+ \ifstr{#1}{inherit}{%
+ \renewcommand*\if@svgx@param@distort{\if@svg@param@distort}%
+ \FamilyKeyStateProcessed%
+ }{%
+ \FamilySetBool{SVG}{extractdistort}{@svgx@param@distort}{#1}%
+ }%
+ }%
+}
+\DefineFamilyKey{SVG}{extractkeepaspectratio}[true]{%
+ \FamilySetBool{SVG}{extractkeepaspectratio}{@svg@tempswa}{#1}%
+ \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+ \if@svg@tempswa%
+ \FamilyOptions{SVG}{extractdistort=false}%
+ \else
+ \FamilyOptions{SVG}{extractdistort=true}%
+ \fi%
+ \else%
+ \FamilyOptions{SVG}{extractdistort=#1}%
+ \fi%
+}
\newcommand*\svgx@param@scale{\svg@param@scale}
\DefineFamilyKey{SVG}{extractscale}{%
\FamilyKeyStateUnknownValue%
@@ -3916,6 +4210,9 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{macrocode}
% \end{macro}^^A \svgx@param@scale
% \end{option}^^A extractscale
+% \end{macro}^^A \svgx@param@distort
+% \end{option}^^A extractkeepaspectratio
+% \end{option}^^A extractdistort
% \end{macro}^^A \svgx@param@height
% \end{option}^^A extractheight
% \end{macro}^^A \svgx@param@width
@@ -3942,9 +4239,9 @@ svg-extract -- Extract independent graphic files from SVG pictures
\let\svgx@param@pretex\relax%
}{%
\ifstr{#1}{inherit}{%
- \def\svgx@param@pretex{\svg@param@pretex}%
+ \renewcommand*\svgx@param@pretex{\svg@param@pretex}%
}{%
- \def\svgx@param@pretex{#1}%
+ \renewcommand*\svgx@param@pretex{#1}%
}%
}%
\FamilyKeyStateProcessed%
@@ -3955,9 +4252,9 @@ svg-extract -- Extract independent graphic files from SVG pictures
\let\svgx@param@apptex\relax%
}{%
\ifstr{#1}{inherit}{%
- \def\svgx@param@apptex{\svg@param@apptex}%
+ \renewcommand*\svgx@param@apptex{\svg@param@apptex}%
}{%
- \def\svgx@param@apptex{#1}%
+ \renewcommand*\svgx@param@apptex{#1}%
}%
}%
\FamilyKeyStateProcessed%
@@ -4048,6 +4345,123 @@ svg-extract -- Extract independent graphic files from SVG pictures
%
% \subsection{User commands}
%
+% \begin{macro}{\includesvg}
+% \begin{parameter}{extract}
+% \begin{parameter}{extractpreamble}
+% \begin{parameter}{extractformat}
+% \begin{parameter}{extractwidth}
+% \begin{parameter}{extractheight}
+% \begin{parameter}{extractdistort}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% \begin{parameter}{extractscale}
+% \begin{parameter}{extractangle}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% \begin{parameter}{extractpretex}
+% \begin{parameter}{extractapptex}
+% \begin{parameter}{extractruns}
+% \begin{parameter}{latexopt}
+% \begin{parameter}{convert}
+% \begin{parameter}{convertformat}
+% \begin{parameter}{convertdpi}
+% \begin{parameter}{magicksetting}
+% \begin{parameter}{magickoperator}
+% \begin{parameter}{gsopt}
+% \begin{parameter}{gsdevice}
+% \begin{parameter}{clean}
+% \begin{parameter}{exclude}
+% \begin{macro}{\includeinkscape}
+% \begin{parameter}{extract}
+% \begin{parameter}{extractpreamble}
+% \begin{parameter}{extractformat}
+% \begin{parameter}{extractwidth}
+% \begin{parameter}{extractheight}
+% \begin{parameter}{extractdistort}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% \begin{parameter}{extractscale}
+% \begin{parameter}{extractangle}
+% \begin{parameter}{extractpretex}
+% \begin{parameter}{extractapptex}
+% \begin{parameter}{extractruns}
+% \begin{parameter}{latexopt}
+% \begin{parameter}{convert}
+% \begin{parameter}{convertformat}
+% \begin{parameter}{convertdpi}
+% \begin{parameter}{magicksetting}
+% \begin{parameter}{magickoperator}
+% \begin{parameter}{gsopt}
+% \begin{parameter}{gsdevice}
+% \begin{parameter}{clean}
+% \begin{parameter}{exclude}
+% The parameters \prm{angle} and \prm{origin} are definied as pendants to the
+% keys provided by \cs{includegraphics}.
+% \begin{macrocode}
+%<*extract>
+\newcommand*\svgx@param@angle{0}
+\svg@local@param@def{%
+ \DefineFamilyKey[.param]{SVG}{extractangle}{%
+ \FamilyKeyStateUnknownValue%
+ \svg@ifvalueisrelax{#1}{%
+ \renewcommand*\svgx@param@angle{0}%
+ \FamilyKeyStateProcessed%
+ }{%
+ \ifstr{#1}{inherit}{%
+ \renewcommand*\svgx@param@angle{\svg@param@angle}%
+ \FamilyKeyStateProcessed%
+ }{%
+ \ifisdimension{#1\p@}{%
+ \renewcommand*\svgx@param@angle{#1}%
+ \FamilyKeyStateProcessed%
+ }{}%
+ }%
+ }%
+ }%
+}
+%</extract>
+% \end{macrocode}
+% \end{parameter}^^A exclude
+% \end{parameter}^^A clean
+% \end{parameter}^^A gsdevice
+% \end{parameter}^^A gsopt
+% \end{parameter}^^A magickoperator
+% \end{parameter}^^A magicksetting
+% \end{parameter}^^A convertdpi
+% \end{parameter}^^A convertformat
+% \end{parameter}^^A convert
+% \end{parameter}^^A latexopt
+% \end{parameter}^^A extractruns
+% \end{parameter}^^A extractapptex
+% \end{parameter}^^A extractpretex
+% \end{parameter}^^A extractangle
+% \end{parameter}^^A extractscale
+% \end{parameter}^^A extractdistort
+% \end{parameter}^^A extractheight
+% \end{parameter}^^A extractwidth
+% \end{parameter}^^A extractformat
+% \end{parameter}^^A extractpreamble
+% \end{parameter}^^A extract
+% \end{macro}^^A \includeinkscape
+% \end{parameter}^^A exclude
+% \end{parameter}^^A clean
+% \end{parameter}^^A gsdevice
+% \end{parameter}^^A gsopt
+% \end{parameter}^^A magickoperator
+% \end{parameter}^^A magicksetting
+% \end{parameter}^^A convertdpi
+% \end{parameter}^^A convertformat
+% \end{parameter}^^A convert
+% \end{parameter}^^A latexopt
+% \end{parameter}^^A extractruns
+% \end{parameter}^^A extractapptex
+% \end{parameter}^^A extractpretex
+% \end{parameter}^^A extractangle
+% \end{parameter}^^A extractscale
+% \end{parameter}^^A extractdistort
+% \end{parameter}^^A extractheight
+% \end{parameter}^^A extractwidth
+% \end{parameter}^^A extractformat
+% \end{parameter}^^A extractpreamble
+% \end{parameter}^^A extract
+% \end{macro}^^A \includesvg
% \begin{macro}{\svghidepreamblestart}
% \changes{v2.00}{2017/02/24}{new}^^A
% \begin{macro}{\svghidepreambleend}
@@ -4109,7 +4523,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\PackageWarning{svg-extract}{%
You didn't enable `shell escape' (or `write18')\MessageBreak%
so it wasn't possible to run the extraction for\MessageBreak%
- file `\svg@tempa'%
+ file `\svg@tempa'\MessageBreak%
}%
\endgroup%
\fi%
@@ -4330,6 +4744,9 @@ svg-extract -- Extract independent graphic files from SVG pictures
\ifdim\svgx@param@height>\z@\relax%
\svg@tempa{height=\svgx@param@height}%
\fi%
+ \if@svgx@param@distort%
+ \svg@tempa{distort=true}%
+ \fi%
\ifdim\dimexpr\svgx@param@scale\p@\relax=\p@\relax\else%
\svg@tempa{scale=\svgx@param@scale}%
\fi%
@@ -4366,6 +4783,14 @@ svg-extract -- Extract independent graphic files from SVG pictures
}{}%
\fi%
% \end{macrocode}
+% The rotation angle, if given.
+% \begin{macrocode}
+ \ifdim\dimexpr\svgx@param@angle\p@\relax=\z@\relax\else%
+ \edef\svg@tempa{%
+ angle=\svgx@param@angle\ifx\svg@tempa\@empty\else,\svg@tempa\fi%
+ }%
+ \fi%
+% \end{macrocode}
% As we are now at the end of the preamble and just before the beginning of the
% document, the paper dimension are set again to make sure, that these settings
% are active at the end of the preamble. Additionally, it is executed again at
@@ -4391,9 +4816,6 @@ svg-extract -- Extract independent graphic files from SVG pictures
}{}%
\fi%
\immediate\write\svgx@stream@out{%
- \string\svgxdelayed{\@percentchar^^J%
- \space\space\svg@tempa\@percentchar^^J%
- }^^J^^J%
\string\begin{document}^^J%
\string\pagestyle{empty}^^J%
\string\svgxoutputbox\@percentchar^^J%
@@ -4504,7 +4926,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\expandafter\svgx@ifinlist\expandafter{\svg@tempa}{\svgx@format}{%
\PackageWarning{svg-extract}{%
File type `\svg@tempa' was specified for option\MessageBreak%
- `extractformat' (\svgx@format) as well as for \MessageBreak
+ `extractformat' (\svgx@format) as well as for \MessageBreak%
option `convertformat' (\svgx@cnv@format) so the\MessageBreak%
conversion won't be done%
}%
@@ -4701,8 +5123,8 @@ svg-extract -- Extract independent graphic files from SVG pictures
}%
\svg@tempa#1,\@nil%
\edef\svg@tempa{%
- \noexpand\endgroup%
- \noexpand\def\noexpand\svgx@cnv@informat{\svg@tempa}%
+ \endgroup%
+ \def\noexpand\svgx@cnv@informat{\svg@tempa}%
}%
\svg@tempa%
% \end{macrocode}
@@ -4782,9 +5204,9 @@ svg-extract -- Extract independent graphic files from SVG pictures
\edef\svg@tempb{%
The graphic file \svg@tempb\space failed\MessageBreak%
for `#1.#2'\MessageBreak%
- Troubleshooting: Please check the log file how the\MessageBreak%
- invocation of the extraction took place and try\MessageBreak%
- to execute it yourself in the terminal%
+ Troubleshooting: Please check the log file how\MessageBreak%
+ the invocation of the extraction took place and\MessageBreak%
+ try to execute it yourself in the terminal%
}%
\else%
\def\svg@tempb{%
@@ -4900,11 +5322,11 @@ svg-extract -- Extract independent graphic files from SVG pictures
\fi%
}%
\edef\svg@tempb{%
- \noexpand\endgroup%
+ \endgroup%
\ifx\svg@tempa\relax%
- \noexpand\let\noexpand\svg@tempa\noexpand\relax%
+ \let\noexpand\svg@tempa\noexpand\relax%
\else%
- \noexpand\def\noexpand\svg@tempa{\svg@tempa}%
+ \def\noexpand\svg@tempa{\svg@tempa}%
\fi%
}%
\svg@tempb%
@@ -4982,42 +5404,48 @@ svg-extract -- Extract independent graphic files from SVG pictures
% needed. Within this file, the following commands are used to include the
% desired graphic.
%
-% \begin{macro}{\svgxdelayed}
-% \changes{v2.00b}{2017/05/23}{new}^^A
-% This macro executes its argument at the very end of \cs{AtBeginDocument} if
-% package \pkg{etoolbox} was loaded.
-% \begin{macrocode}
-\newcommand*\svgxdelayed[1]{
- \scr@ifundefinedorrelax{AtEndPreamble}{%
- \AtBeginDocument{#1}%
- }{%
- \AtEndPreamble{\AtBeginDocument{#1}}%
- }%
-}
-% \end{macrocode}
-% \end{macro}^^A \svgxdelayed
% \begin{macro}{\svgxsetbox}
-% \begin{macro}{\svgx@box}
+% \changes{v2.02}{2018/09/07}{late execution of \cs{svgxsetpapersize}}^^A
+% \begin{macro}{\svgx@setbox}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% \begin{macro}{\if@svgx@standalone}
+% \changes{v2.02}{2018/09/07}{new}^^A
% Within the preamble of the auxiliary \LaTeX~file, the desired grahic is used
% to setup a box, which is used both to define the papersize as well as for the
-% output itself. For \TUDScript-classes, the crop-mode is acrivated.
+% output itself. The macro \cs{svgx@setbox} is executed twice, the first time
+% in the preamble and the second time at the very end of \cs{AtBeginDocument}
+% if package \pkg{etoolbox} was loaded.
+%
+% The switch \cs{if@svgx@standalone} is defined for enabling classes to
+% implement a different behavoiur for \pkg{svg-extract} in standalone mode.
+% for example, \TUDScript-classes are using this switch.
% \begin{macrocode}
-\newbox\svgx@box
+\newif\if@svgx@standalone
\newcommand*\svgxsetbox[2][]{%
- \csname @tud@x@standalone@croptrue\endcsname%
- \sbox\svgx@box{\svg@@input[{#1},draft=false]{#2}}%
- \svgxsetpapersize%
+ \@svgx@standalonetrue%
+ \svgx@setbox{#1}{#2}%
+ \scr@ifundefinedorrelax{AtEndPreamble}{%
+ \let\svg@tempa\@firstofone%
+ }{%
+ \def\svg@tempa{\AtEndPreamble}%
+ }%
+ \svg@tempa{\AtBeginDocument{\svgx@setbox{#1}{#2}}}%
+}
+\newcommand*\svgx@setbox[2]{%
+ \sbox\svg@box{\svg@@input[{#1},draft=false]{#2}}%
+ \svgxsetpapersize%
}
% \end{macrocode}
-% \end{macro}^^A \svgx@box
+% \end{macro}^^A \if@svgx@standalone
+% \end{macro}^^A \svgx@setbox
% \end{macro}^^A \svgxsetbox
% \begin{macro}{\svgxsetpapersize}
% \changes{v2.00a}{2017/02/28}{Bug fix for checking stock- and mediasizes}^^A
% This macro sets all well known length macros for defining the paper size as
-% well as the type area to the size of \cs{svgx@box}.
+% well as the type area to the size of \cs{svg@box}.
% \begin{macrocode}
\newcommand*\svgxsetpapersize{%
- \setlength\paperwidth{\the\wd\svgx@box}%
+ \setlength\paperwidth{\the\wd\svg@box}%
% \end{macrocode}
% Due to the fact, that the lengths for stock- and mediasizes are maybe set to
% \cs{relax}, these macros are checked with \cs{scr@ifundefinedorrelax}.
@@ -5029,7 +5457,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\setlength\mediawidth{\paperwidth}%
}%
\setlength\textwidth{\paperwidth}%
- \setlength\paperheight{\the\dimexpr\ht\svgx@box+\dp\svgx@box\relax}%
+ \setlength\paperheight{\the\dimexpr\ht\svg@box+\dp\svg@box\relax}%
\scr@ifundefinedorrelax{stockheight}{}{%
\setlength\stockheight{\paperheight}%
}%
@@ -5071,10 +5499,10 @@ svg-extract -- Extract independent graphic files from SVG pictures
\if@svgx@beamer%
\setbeamertemplate{navigation symbols}{}%
\begin{frame}[plain]%
- \usebox\svgx@box%
+ \usebox\svg@box%
\end{frame}%
\else%
- \usebox\svgx@box%
+ \usebox\svg@box%
\fi%
\endgraf%
\endgroup%
@@ -5097,13 +5525,15 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{macrocode}
%<*base>
\FamilyExecuteOptions{SVG}{%
- inkscape=true,inkscapepath=basesubdir,inkscapelatex=true,%
- inkscapearea=drawing,usexcolor=true,usetransparent=true%
+ inkscape=true,inkscapepath=basesubdir,
+ inkscapelatex=true,inkscapearea=drawing,distort=false,%
+ usexcolor=true,usetransparent=true%
}
%</base>
%<*extract>
\FamilyExecuteOptions{SVG}{%
- extract=true,extractpath=basesubdir,extractruns=2,extractname=namenumbered,%
+ extract=true,extractpath=basesubdir,%
+ extractruns=2,extractname=namenumbered,extractdistort=false,%
convert=magick,convert=false,%
gsdevice={png=png16m},gsdevice={jpeg=jpeg},gsdevice={jpg=jpeg},%
gsdevice={tif=tiff48nc},gsdevice={tiff=tiff48nc},%
@@ -5153,8 +5583,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{macrocode}
\newcommand*\svg@shell@mkdir[1]{%
\begingroup%
- \edef\svg@tempa{#1}%
- \svg@quotes@remove{\svg@tempa}%
+ \svg@quotes@remove[{#1}]{\svg@tempa}%
\@svg@tempswatrue%
\ifstr{\svg@tempa}{}{\@svg@tempswafalse}{%
\ifstr{\svg@tempa}{./}{\@svg@tempswafalse}{%
@@ -5180,6 +5609,10 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{macro}^^A \svg@shell@mv
% \end{macro}^^A \svg@shell@@mkdir
% \end{macro}^^A \svg@shell@mkdir
+% At the very end, the catcodes are restored.
+% \begin{macrocode}
+\svg@catcodecodes@restore
+% \end{macrocode}
%
% \iffalse
%</package&base&body>