texlive[48626] Master/texmf-dist: svg (8sep18)

commits+karl at tug.org commits+karl at tug.org
Sat Sep 8 23:41:57 CEST 2018


Revision: 48626
          http://tug.org/svn/texlive?view=revision&revision=48626
Author:   karl
Date:     2018-09-08 23:41:57 +0200 (Sat, 08 Sep 2018)
Log Message:
-----------
svg (8sep18)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/svg/README.md
    trunk/Master/texmf-dist/doc/latex/svg/svg-preamble.tex
    trunk/Master/texmf-dist/doc/latex/svg/svg.pdf
    trunk/Master/texmf-dist/source/latex/svg/svg.dtx
    trunk/Master/texmf-dist/tex/latex/svg/svg-extract.sty
    trunk/Master/texmf-dist/tex/latex/svg/svg.sty

Modified: trunk/Master/texmf-dist/doc/latex/svg/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/svg/README.md	2018-09-08 21:41:40 UTC (rev 48625)
+++ trunk/Master/texmf-dist/doc/latex/svg/README.md	2018-09-08 21:41:57 UTC (rev 48626)
@@ -5,7 +5,7 @@
  Copyright (C) Philip Ilten <philten at cern.ch>, 2012-2016  
  Copyright (C) Falk Hanisch <hanisch.latex at outlook.com>, 2017-
 
- svg 2017/11/29 v2.01
+ svg 2018/09/08 v2.02
 
 ----------------------------------------------------------------------------
 
@@ -34,6 +34,14 @@
 Versions
 --------
 
+**v2.02** (2018/09/08)
++ distortion of included and extracted graphics supported with options `distort` 
+  (or `keepaspectratio`) and `extractdistort` as well as rotation for 
+  extractions (`extractangle`)
++ fixed errors with active double qoutes from **babel** in path arguments
++ multiple dots within file names possible
++ package **trimspaces** required
+
 **v2.01** (2017/11/29)
 + new option `svgextension` to change the format of files exported by
   ***Inkscape*** from `svg` to a custom one

Modified: trunk/Master/texmf-dist/doc/latex/svg/svg-preamble.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/svg/svg-preamble.tex	2018-09-08 21:41:40 UTC (rev 48625)
+++ trunk/Master/texmf-dist/doc/latex/svg/svg-preamble.tex	2018-09-08 21:41:57 UTC (rev 48626)
@@ -1,10 +1,5 @@
 \documentclass{scrartcl}
-\usepackage{ifxetex}
-\usepackage{ifluatex}
-\ifxetex\else\ifluatex\else
 \usepackage[T1]{fontenc}
-\usepackage{selinput}\SelectInputMappings{adieresis={ä},germandbls={ß}}
-\fi\fi
 \usepackage{svg}
 \usepackage{relsize}
 \usepackage{hyperref}

Modified: trunk/Master/texmf-dist/doc/latex/svg/svg.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/svg/svg.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/svg/svg.dtx	2018-09-08 21:41:40 UTC (rev 48625)
+++ trunk/Master/texmf-dist/source/latex/svg/svg.dtx	2018-09-08 21:41:57 UTC (rev 48626)
@@ -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 @@
 %<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 @@
 %<*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 @@
 %   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 @@
 % 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 @@
 % 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 @@
 %
 % \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 @@
 %   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,17 +512,20 @@
 %
 % \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}.
+% 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.
 %
-% 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, 
 % such as font or color commands. The options \opt{pretex} and \opt{apptex} are
@@ -523,9 +544,9 @@
 % \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 @@
 % \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 @@
 % \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 @@
 % \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 @@
 % 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 @@
 %   \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 @@
 %   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 @@
 % 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 @@
 % 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 @@
 % \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 @@
 % 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 @@
 % \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,11 +1302,12 @@
 %    \begin{macrocode}
 %<*base>
 \RequirePackage{scrbase}[2016/06/14]
+\RequirePackage{ifpdf}[2016/05/14]
+\RequirePackage{ifluatex}[2016/05/16]
 \RequirePackage{ifxetex}[2010/09/12]
-\RequirePackage{ifluatex}[2016/05/16]
-\RequirePackage{ifpdf}[2016/05/14]
 \RequirePackage{pdftexcmds}[2016/05/21]
 \RequirePackage{shellesc}[2016/06/07]
+\RequirePackage{trimspaces}[2009/09/17]
 \RequirePackage{graphicx}[1999/02/16]
 %</base>
 %<*extract>
@@ -1259,15 +1314,58 @@
 \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 at tempa}
+% \begin{macro}{\svg at tempb}
+% \begin{macro}{\svg at box}
+% \begin{macro}{\if at svg@tempswa}
+% Internal temporary macros. The catcode for double quotes are also temporarily 
+% changed.
+%    \begin{macrocode}
+\newcommand*\svg at tempa{}
+\newcommand*\svg at tempb{}
+\newbox\svg at box
+\newif\if at svg@tempswa
+\edef\svg at catcodecodes@restore{%
+  \catcode`\noexpand\"\the\catcode`\"\relax%
+}
+\@makeother\"%
+%    \end{macrocode}
+% \end{macro}^^A \if at svg@tempswa
+% \end{macro}^^A \svg at box
+% \end{macro}^^A \svg at tempb
+% \end{macro}^^A \svg at 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 at 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 
@@ -1274,7 +1372,6 @@
 % provided. If an old key was given, a warning is issued and the valid key is
 % used.
 %    \begin{macrocode}
-%<*base>
 \newcommand*\svg at deprecated@key[3][svg]{%
   \PackageWarning{#1}{%
     The option key `#2' is deprecated.\MessageBreak%
@@ -1283,35 +1380,9 @@
   }%
   \FamilyOptions{SVG}{#3}%
 }
-%</base>
 %    \end{macrocode}
 % \end{macro}^^A \svg at deprecated@key
-% \begin{macro}{\svg at tempa}
-% \begin{macro}{\svg at tempb}
-% \begin{macro}{\if at svg@tempswa}
-% Internal temporary macros.
-%    \begin{macrocode}
-%<*base>
-\newcommand*\svg at tempa{}
-\newcommand*\svg at tempb{}
-\newif\if at svg@tempswa
-%</base>
-%    \end{macrocode}
-% \end{macro}^^A \if at svg@tempswa
-% \end{macro}^^A \svg at tempb
-% \end{macro}^^A \svg at 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 
 % packages anyways.
@@ -1374,6 +1445,8 @@
 %
 % \begin{option}{inkscape}
 % \changes{v2.00}{2017/02/17}{changed/extended}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg at sanitize@dq}}^^A
+% \changes{v2.01}{2017/11/28}{using \cs{trim at spaces}}^^A
 % \begin{macro}{\svg at 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 @@
 %    \begin{macrocode}
 \newcommand*\svg at ink@mode{}
 \DefineFamilyKey{SVG}{inkscape}[true]{%
-  \lowercase{\def\svg at tempa{#1}}%
+  \lowercase{\svg at sanitize@dq\svg at tempb{#1}}%
   \FamilySetNumerical{SVG}{inkscape}{svg at tempa}{%
     {false}{0},{off}{0},{no}{0},%
     {true}{1},{on}{1},{yes}{1},{onlynewer}{1},{newer}{1},%
@@ -1396,7 +1469,7 @@
     {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 at tempa}%
+  }{\svg at tempb}%
   \ifx\FamilyKeyState\FamilyKeyStateProcessed%
 %    \end{macrocode}
 % Setting the mode for invoking \app{Inkscape}\dots
@@ -1433,7 +1506,7 @@
     \def\svg at tempa##1dpi##2\@nil{%
       \ifstr{##2}{dpi}{\FamilyOptions{SVG}{inkscapedpi=##1}}{}%
     }%
-    \lowercase{\svg at tempa#1dpi\@nil}%
+    \lowercase{\expandafter\svg at tempa\svg at 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 @@
 % \cs{svg at tempa} and the option part---which is recognized by the first |-| 
 % character--- in \cs{svg at tempb}.
 %    \begin{macrocode}
+      \svg at quotes@remove[{#1}]{\svg at tempb}%
       \def\svg at tempa##1-##2\@nil{%
         \IfArgIsEmpty{##2}{\def\svg at tempb{}}{%
-          \def\svg at tempa##1####1\@nil{\def\svg at tempb{####1}}%
-          \svg at tempa#1\@nil%
+          \def\svg at tempa####1-\@nil{\def\svg at tempb{-####1}}%
+          \svg at tempa##2\@nil%
         }%
-        \def\svg at tempa{##1}%
+        \edef\svg at tempa{\trim at spaces{##1}}%
       }%
-      \svg at tempa#1-\@nil%
+      \edef\svg at tempb{%
+        \noexpand\svg at tempa\svg at tempb-\noexpand\@nil%
+      }%
+      \svg at tempb%
+      \if at svg@quotes at found%
+        \edef\svg at tempa{"\svg at tempa"}%
+      \fi%
       \PackageWarning{svg}{%
         Setting the executable%
         \ifx\svg at tempb\@empty\else%
@@ -1642,6 +1722,8 @@
 % \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 at quotes@remove}}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg at remove@leadingchar}}^^A
 % \begin{option}{extension}
 % \begin{option}{ext}
 % \begin{macro}{\svg at file@ext}
@@ -1651,19 +1733,13 @@
 \newcommand*\svg at 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 at tempa##1.##2.##3\relax{%
-    \IfArgIsEmpty{##1}{%
-      \def\svg at file@ext{##2}%
-    }{%
-      \def\svg at file@ext{##1}%
-    }%
-  }%
+  \lowercase{\svg at quotes@remove[{#1}]{\svg at file@ext}}%
 %    \end{macrocode}
-% The extension should be in lower case letters.
+% Remove leading dots from the extension.
 %    \begin{macrocode}
-  \lowercase{\svg at tempa#1..\relax}%
+  \svg at remove@leadingchar.\svg at file@ext%
 }
 \DefineFamilyKey{SVG}{extension}{\FamilyOptions{SVG}{svgextension=#1}}
 \DefineFamilyKey{SVG}{ext}{\FamilyOptions{SVG}{svgextension=#1}}
@@ -1679,6 +1755,7 @@
 %
 % \begin{option}{inkscapepath}
 % \changes{v2.00}{2017/02/17}{new}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg at sanitize@dq}}^^A
 % \begin{option}{inkscapename}
 % \changes{v2.00}{2017/02/17}{new}^^A
 % \begin{macro}{\svg at out@path}
@@ -1692,12 +1769,13 @@
 \newcommand*\svg at out@name{\svg at file@name\svg at file@suffix}
 \newcommand*\svg at out@base{\svg at out@path\svg at out@name.\svg at ink@format}
 \DefineFamilyKey{SVG}{inkscapepath}{%
+  \svg at sanitize@dq\svg at tempb{#1}%
   \FamilySetNumerical{SVG}{inkscapepath}{svg at 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 at tempb}%
   \ifx\FamilyKeyState\FamilyKeyStateProcessed%
     \ifcase\svg at tempa\relax% svgpath
       \renewcommand*\svg at out@path{\svg at file@path}%
@@ -1709,7 +1787,7 @@
       \renewcommand*\svg at out@path{./svg-inkscape/}%
     \fi%
   \else%
-    \renewcommand*\svg at out@path{#1}%
+    \edef\svg at out@path{\svg at tempb}%
     \svg at normalize@path{\svg at out@path}%
     \FamilyKeyStateProcessed%
   \fi%
@@ -1737,6 +1815,11 @@
 % \begin{option}{height}
 % \changes{v2.00}{2017/02/17}{new}^^A
 % \begin{macro}{\svg at 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 at svg@param at distort}
 % \begin{option}{scale}
 % \changes{v2.00}{2017/02/17}{new}^^A
 % \begin{macro}{\svg at param@scale}
@@ -1752,8 +1835,10 @@
     \FamilyKeyStateProcessed%
   }{%
     \FamilySetLengthMacro{SVG}{width}{\svg at param@width}{#1}%
-    \ifdim\svg at param@width<\z@\relax%
-      \FamilyKeyStateUnknownValue%
+    \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+      \ifdim\svg at param@width<\z@\relax%
+        \FamilyKeyStateUnknownValue%
+      \fi%
     \fi%
   }%
 }
@@ -1765,11 +1850,25 @@
     \FamilyKeyStateProcessed%
   }{%
     \FamilySetLengthMacro{SVG}{height}{\svg at param@height}{#1}%
-    \ifdim\svg at param@height<\z@\relax%
-      \FamilyKeyStateUnknownValue%
+    \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+      \ifdim\svg at param@height<\z@\relax%
+        \FamilyKeyStateUnknownValue%
+      \fi%
     \fi%
   }%
 }
+\newif\if at svg@param at distort
+\FamilyBoolKey{SVG}{distort}{@svg at param@distort}
+\DefineFamilyKey{SVG}{keepaspectratio}[true]{%
+  \FamilySetBool{SVG}{keepaspectratio}{@svg at tempswa}{#1}%
+  \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+    \if at svg@tempswa%
+      \FamilyOptions{SVG}{distort=false}%
+    \else
+      \FamilyOptions{SVG}{distort=true}%
+    \fi%
+  \fi%
+}
 \newcommand*\svg at param@scale{1}
 \DefineFamilyKey{SVG}{scale}{%
   \FamilyKeyStateUnknownValue%
@@ -1788,6 +1887,9 @@
 %    \end{macrocode}
 % \end{macro}^^A \svg at param@scale
 % \end{option}^^A scale
+% \end{macro}^^A \if at svg@param at distort
+% \end{option}^^A keepaspectratio
+% \end{option}^^A distort
 % \end{macro}^^A \svg at param@height
 % \end{option}^^A height
 % \end{macro}^^A \svg at param@width
@@ -1878,19 +1980,52 @@
 % 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 at 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 at deactivate@dq{}
+\AfterPackage*{babel}{%
+  \renewcommand*\svg at deactivate@dq{\bbl at deactivate{"}}%
+}
+%    \end{macrocode}
+% \end{macro}^^A \svg at deactivate@dq
+% \begin{macro}{\svg at 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 at sanitize@dq[2]{%
+  \begingroup%
+    \svg at deactivate@dq%
+    \edef\svg at tempa{\endgroup\def\noexpand#1{#2}}%
+  \svg at tempa%
+}
+%    \end{macrocode}
+% \end{macro}^^A \svg at sanitize@dq
 % \begin{macro}{\svg at quotes@remove}
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg at sanitize@dq}}^^A
+% \changes{v2.02}{2018/09/07}{calling \cs{svg at quotes@check}}^^A
 % \begin{macro}{\svg at quotes@@remove}
 % These two commands are used to remove all occurring quotes within a string. 
 % The only argument passed to \cs{svg at quotes@remove} is not the string itself
 % but a macro in which a string is stored.
 %    \begin{macrocode}
-\newcommand*\svg at quotes@remove[1]{%
+\newcommand*\svg at quotes@remove[2][]{%
   \begingroup%
-    \edef\svg at tempa{#1}%
+    \IfArgIsEmpty{#1}{\def\svg at tempb{#2}}{\def\svg at tempb{#1}}%
+    \svg at sanitize@dq\svg at tempa{\svg at tempb}%
+    \expandafter\svg at quotes@check\expandafter{\svg at tempa}%
     \expandafter\svg at quotes@@remove\svg at tempa""\@nil%
     \edef\svg at tempb{%
       \endgroup%
-      \noexpand\def\noexpand#1{\unexpanded\expandafter{\svg at tempa}}%
+      \def\noexpand#2{\svg at tempa}%
+      \if at svg@quotes at found%
+        \noexpand\@svg at quotes@foundtrue%
+      \else%
+        \noexpand\@svg at quotes@foundfalse%
+      \fi%
     }%
   \svg at tempb%
 }
@@ -1926,10 +2061,35 @@
 % \end{macro}^^A \if at svg@quotes at found
 % \end{macro}^^A \svg at quotes@@check
 % \end{macro}^^A \svg at quotes@check
+% \begin{macro}{\svg at 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 at remove@leadingchar[2]{%
+  \begingroup%
+    \svg at sanitize@dq\svg at tempa{#2}%
+    \def\svg at tempb{%
+      \def\svg at tempa####1\@nil{\def\svg at tempa{####1}}%
+      \kernel at ifnextchar#1%
+        {\expandafter\svg at tempa\@gobble}%
+        {\svg at tempa}%
+    }%
+    \expandafter\svg at tempb\svg at tempa\@nil%
+    \edef\svg at tempb{%
+      \endgroup%
+      \def\noexpand#2{\svg at tempa}%
+    }%
+  \svg at tempb%
+}
+%    \end{macrocode}
+% \end{macro}^^A \svg at remove@leadingchar% 
 % \begin{macro}{\svg at set@input at 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 at deactivate@dq}}^^A
 % \begin{macro}{\svg at append@input at 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 at path}}^^A
 % In order to import SVG~files from different folders, \cs{svg at set@input at path}
 % evaluates several macros, which are supposed to be used for holding different 
 % search folders. Any given path will be handled by \cs{svg at normalize@path}.
@@ -1937,6 +2097,7 @@
 %    \begin{macrocode}
 \newcommand*\svg at set@input at path[1][]{%
   \begingroup%
+    \svg at deactivate@dq%
 %    \end{macrocode}
 % If a path was already found and stored within \cs{svg at file@path}, it is
 % searched first and wrapped in curly braces. This is necessary for using
@@ -1943,6 +2104,7 @@
 % commands like \cs{input}\marg{tex filename} within SVG~files.
 %    \begin{macrocode}
     \ifx\svg at file@path\@empty\else%
+      \svg at normalize@path{\svg at file@path}%
       \edef\svg at file@path{{\svg at file@path}}%
     \fi%
 %    \end{macrocode}
@@ -1953,38 +2115,48 @@
 %    \begin{macrocode}
     \svg at append@input at path{\svg at file@path}{\svg at input@path}%
     \svg at append@input at path{\svg at file@path}{\Ginput at path}%
-    \svg at append@input at path{\svg at file@path}{{#1}}%
+    \IfArgIsEmpty{#1}{}{\svg at append@input at path{\svg at file@path}{{#1}}}%
     \svg at append@input at path{\svg at file@path}{\input at path}%
 %    \end{macrocode}
-% Passing each path to \cs{svg at normalize@path}.
-%    \begin{macrocode}
-    \def\svg at tempb{}%
-    \expandafter\@tfor\expandafter\svg at tempa\expandafter:\expandafter=%
-        \svg at file@path\do{%
-      \ifx\svg at tempa\@empty\else%
-        \svg at normalize@path{\svg at tempa}%
-        \edef\svg at tempb{%
-          \unexpanded\expandafter{\svg at tempb}{\svg at tempa}%
-        }%
-      \fi%
-    }%
-%    \end{macrocode}
 % Finally, \cs{input at path} is set.
 %    \begin{macrocode}
     \edef\svg at tempa{%
       \endgroup%
-      \ifx\svg at tempb\@empty\else%
-        \noexpand\def\noexpand\input at path{\unexpanded\expandafter{\svg at tempb}}%
+      \ifx\svg at file@path\@empty\else%
+        \def\noexpand\input at path{\svg at file@path}%
       \fi%
     }%
   \svg at 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 at append@input at path[2]{%
   \ifx#2\@undefined\else%
-    \edef#1{\unexpanded\expandafter{#1}#2}%
+    \edef\svg at tempb{#2}%
+    \expandafter\@tfor\expandafter\svg at tempa\expandafter:\expandafter=%
+        \svg at tempb\do{%
+%    \end{macrocode}
+% Passing each new path to \cs{svg at normalize@path}. If a path already exists, 
+% switch \cs{if at svg@tempswa} is set to \val{false}.
+%    \begin{macrocode}
+      \ifx\svg at tempa\@empty\else%
+        \@svg at tempswatrue%
+        \svg at normalize@path{\svg at tempa}%
+        \expandafter\@tfor\expandafter\svg at tempb\expandafter:\expandafter=%
+            #1\do{%
+          \ifx\svg at tempa\svg at tempb%
+            \@svg at tempswafalse%
+            \@break at tfor%
+          \fi%
+        }%
+        \if at svg@tempswa%
+          \edef#1{#1{\svg at tempa}}%
+        \fi%
+      \fi%
+    }%
   \fi%
 }
 %    \end{macrocode}
@@ -1991,6 +2163,7 @@
 % \end{macro}^^A \svg at append@input at path
 % \end{macro}^^A \svg at set@input at path
 % \begin{macro}{\svg at normalize@path}
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg at deactivate@dq}}^^A
 % \begin{macro}{\svg at 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 @@
 %    \begin{macrocode}
 \newcommand*\svg at normalize@path[1]{%
   \begingroup%
-    \edef\svg at tempa{#1}%
-    \svg at quotes@check{\svg at tempa}%
-    \svg at quotes@remove{\svg at tempa}%
+    \svg at quotes@remove[{#1}]{\svg at tempa}%
     \ifx\svg at tempa\@empty\relax%
       \def\svg at tempa{./}%
     \fi%
@@ -2009,9 +2180,9 @@
     \edef\svg at tempb{%
       \endgroup%
       \if at svg@quotes at found%
-        \noexpand\def\noexpand#1{"\unexpanded\expandafter{\svg at tempa}"}%
+        \def\noexpand#1{"\svg at tempa"}%
       \else%
-        \noexpand\def\noexpand#1{\unexpanded\expandafter{\svg at tempa}}%
+        \def\noexpand#1{\svg at tempa}%
       \fi%
     }%
   \svg at tempb%
@@ -2022,7 +2193,7 @@
     \IfArgIsEmpty{#1}{\def\svg at tempa{}}{\def\svg at tempa{#1/}}%
   }{%
     \svg at normalize@@path#2/\@nil%
-    \edef\svg at tempa{#1/\unexpanded\expandafter{\svg at tempa}}%
+    \edef\svg at tempa{#1/\svg at tempa}%
   }%
 }
 %    \end{macrocode}
@@ -2054,7 +2225,8 @@
 % \fi
 %
 % \begin{macro}{\svg at get@path}
-% \changes{v2.01}{2017/11/28}{using \cs{svg at set@input at path}}%
+% \changes{v2.01}{2017/11/28}{using \cs{svg at set@input at path}}^^A
+% \changes{v2.01}{2017/11/28}{using \cs{trim at spaces}}^^A
 % \begin{macro}{\if at svg@file at found}
 % \begin{macro}{\svg at file@path}
 % \begin{macro}{\svg at file@name}
@@ -2078,24 +2250,18 @@
 %    \end{macrocode}
 % A maybe given, unneeded file extension is removed.
 %    \begin{macrocode}
-    \edef\svg at tempa{#2}%
-    \svg at quotes@check{\svg at tempa}%
-    \svg at quotes@remove{\svg at tempa}%
-    \expandafter\svg at filename@parse\expandafter{\svg at tempa}%
+    \svg at filename@parse[{#1}]{#2}%
     \IfArgIsEmpty{#1}{%
       \edef\svg at tempa{\filename at area\filename at base.\filename at ext}%
     }{%
       \edef\svg at tempa{\filename at area\filename at base.#1}%
     }%
-    \if at svg@quotes at found%
-      \edef\svg at tempa{"\svg at tempa"}%
-    \fi%
 %    \end{macrocode}
 % After calling \cs{svg at set@input at path}, all search paths are stored in
 % \cs{input at path}, a single path given in the third argument will also be 
 % considered.
 %    \begin{macrocode}
-    \svg at set@input at path[#3]%
+    \svg at set@input at path[{#3}]%
 %    \end{macrocode}
 % The specified file is searched with \cs{IfFileExists}. If the file search was 
 % succesful, the macro \cs{svg at filename@parse} is called with the result.
@@ -2103,20 +2269,21 @@
     \@svg at tempswafalse%
     \expandafter\IfFileExists\expandafter{\svg at tempa}{%
       \@svg at tempswatrue%
-      \expandafter\svg at filename@parse\expandafter{\@filef at und}%
+      \edef\@filef at und{\expandafter\trim at spaces\expandafter{\@filef at und}}%
+      \svg at filename@parse[{#1}]{\@filef at und}%
     }{}%
     \edef\svg at tempa{%
       \endgroup%
       \if at svg@tempswa%
         \noexpand\@svg at file@foundtrue%
-        \noexpand\def\noexpand\svg at file@path{\filename at area}%
-        \noexpand\def\noexpand\svg at file@name{\filename at base}%
-        \noexpand\def\noexpand\svg at file@base{\filename at area\filename at base}%
+        \def\noexpand\svg at file@path{\filename at area}%
+        \def\noexpand\svg at file@name{\filename at base}%
+        \def\noexpand\svg at file@base{\filename at area\filename at base}%
       \else%
         \noexpand\@svg at file@foundfalse%
-        \noexpand\def\noexpand\svg at file@path{}%
-        \noexpand\def\noexpand\svg at file@name{#2}%
-        \noexpand\def\noexpand\svg at file@base{#2}%
+        \def\noexpand\svg at file@path{}%
+        \def\noexpand\svg at file@name{#2}%
+        \def\noexpand\svg at file@base{#2}%
       \fi%
     }%
   \svg at tempa%
@@ -2129,52 +2296,49 @@
 % \end{macro}^^A \if at svg@file at found
 % \end{macro}^^A \svg at get@path
 % \begin{macro}{\svg at filename@parse}
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg at sanitize@dq}}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg at remove@leadingchar}}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg at extension@parse}}^^A
 % As the internal \LaTeXe{} command \cs{filename at parse} is not able to split a 
 % given file name containing quotes, \cs{svg at 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 at ext}. If found 
+% at the very end, the previous part is appended to \cs{filename at base}.
 %    \begin{macrocode}
-\newcommand*\svg at filename@parse[1]{%
+\newcommand*\svg at filename@parse[2][]{%
   \begingroup%
-    \def\svg at tempa##1{%
-      \def\svg at tempb####1####2\@nil{%
-        \ifstr{####1}{"}{\def\svg at tempb{####2}}{\def\svg at tempb{####1####2}}%
-      }%
-      \expandafter\svg at tempb##1\@nil%
-      \edef##1{\svg at tempb}%
-    }%
 %    \end{macrocode}
-% The given path and file is parsed with \cs{filename at 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 at parse}.
 %    \begin{macrocode}
-    \filename at parse{#1}%
-    \ifx\filename at ext\relax\else%
-      \edef\filename at base{\filename at base.\filename at ext}%
-    \fi%
-%    \end{macrocode}
+    \svg at sanitize@dq\svg at tempa{#2}%
+    \expandafter\filename at parse\expandafter{\svg at tempa}%
 % If there are quotes in the file path, the closing one will be found as first 
 % character in \cs{filename at base} as \cs{filename at area} is splitted at the last
 % slash. This leading quote is removed from \cs{filename at base} with 
-% \cs{svg at tempa}.
+% \cs{svg at remove@leadingchar}.
 %    \begin{macrocode}
-    \svg at quotes@check{\filename at area}%
+    \svg at quotes@remove{\filename at area}%
     \if at svg@quotes at found%
-      \svg at quotes@remove{\filename at area}%
       \edef\filename at area{"\filename at area"}%
-      \svg at tempa{\filename at base}%
+      \svg at remove@leadingchar"\filename at base%
     \fi%
 %    \end{macrocode}
-% Before the second call of \cs{filename at parse} remaining quotes are removed 
-% and the path in \cs{filename at area} is temporary stored in \cs{svg at 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 at base}.
 %    \begin{macrocode}
-    \svg at quotes@check{\filename at base}%
-    \if at svg@quotes at found%
-      \svg at quotes@remove{\filename at base}%
+    \ifx\filename at ext\relax\else%
+      \svg at quotes@remove{\filename at ext}%
+      \svg at extension@parse{#1}%
+      \if at svg@quotes at found%
+        \edef\filename at base{\filename at base"}%
+      \fi%
     \fi%
-    \let\svg at tempa\filename at area%
-    \expandafter\filename at parse\expandafter{\filename at base}%
-    \let\filename at area\svg at tempa%
+%    \end{macrocode}
+% Quotes within \cs{filename at base} are normalized.
+%    \begin{macrocode}
+    \svg at quotes@remove{\filename at base}%
     \if at svg@quotes at found%
-       \edef\filename at base{"\filename at base"}%
+      \edef\filename at base{"\filename at base"}%
     \fi%
 %    \end{macrocode}
 % With \cs{svg at tempa} the group is closed and the results are saved in the
@@ -2181,13 +2345,13 @@
 % macros \cs{filename@\dots}.
 %    \begin{macrocode}
     \edef\svg at tempa{%
-      \noexpand\endgroup%
-      \noexpand\def\noexpand\filename at area{\filename at area}%
-      \noexpand\def\noexpand\filename at base{\filename at base}%
+      \endgroup%
+      \def\noexpand\filename at area{\filename at area}%
+      \def\noexpand\filename at base{\filename at base}%
       \ifx\filename at ext\relax%
-        \noexpand\let\noexpand\filename at ext\noexpand\relax%
+        \let\noexpand\filename at ext\noexpand\relax%
       \else%
-        \noexpand\def\noexpand\filename at ext{\filename at ext}%
+        \def\noexpand\filename at ext{\filename at ext}%
       \fi%
     }%
   \svg at tempa%
@@ -2194,23 +2358,86 @@
 }
 %    \end{macrocode}
 % \end{macro}^^A \svg at filename@parse
+% \begin{macro}{\svg at extension@parse}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% \begin{macro}{\svg at 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 at ext} is split at each occurence of \val{.} and the trailing part 
+% is compared against the content of the argument of \cs{svg at extension@parse}, 
+% which is probably \cs{svg at file@ext}. If they are equal, the previous part is 
+% appended to \cs{filename at base} and \cs{filename at ext} is set to the content of 
+% the first argument.
+%    \begin{macrocode}
+\newcommand*\svg at extension@parse[1]{%
+  \IfArgIsEmpty{#1}{}{%
+    \ifstr{#1}{\filename at ext}{}{%
+      \begingroup%
+%    \end{macrocode}
+% Macro \cs{svg at tempa} is used to temporarily store anything before the 
+% searched extension at the end of \cs{filename at ext} and \cs{svg at tempb} is set
+% to the actual searched extension if found.
+%    \begin{macrocode}
+        \edef\svg at tempa{%
+          \def\noexpand\svg at tempa{}%
+          \let\noexpand\svg at tempb\relax%
+          \noexpand\svg at extension@@parse%
+            \filename at ext.\noexpand\@nil#1\noexpand\@nil%
+        }%
+        \svg at tempa%
+        \edef\svg at tempa{%
+          \endgroup%
+%    \end{macrocode}
+% If the trailing extension was found, \cs{filename at base} and \cs{filename at ext} 
+% are adopted.
+%    \begin{macrocode}
+          \def\noexpand\filename at base{\filename at base\svg at tempa}%
+          \ifx\svg at tempb\relax%
+            \let\noexpand\filename at ext\relax%
+          \else%
+            \def\noexpand\filename at ext{\svg at tempb}%
+          \fi%
+        }%
+      \svg at tempa%
+    }%
+  }%
+}
+%    \end{macrocode}
+% Macro \cs{svg at extension@@parse} is recursively called as long as there are 
+% any dots or the searched extension is found.
+%    \begin{macrocode}
+\newcommand*\svg at extension@@parse{}
+\def\svg at extension@@parse#1.#2\@nil#3\@nil{%
+  \edef\svg at tempa{\svg at tempa.#1}%
+  \IfArgIsEmpty{#2}{}{%
+    \ifstr{#2}{#3.}{%
+%    \end{macrocode}
+% If the trailing extension is found, \cs{svg at tempb} is definied.
+%    \begin{macrocode}
+      \edef\svg at tempb{#3}%
+    }{%
+      \svg at extension@@parse#2\@nil#3\@nil%
+    }%
+  }%
+}
+%    \end{macrocode}
+% \end{macro}^^A \svg at extension@@parse
+% \end{macro}^^A \svg at extension@parse
 % \begin{macro}{\svg at 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 at file@missing[3][]{%
   \begingroup%
-    \edef\svg at tempa{#2}%
-    \expandafter\svg at filename@parse\expandafter{\svg at tempa}%
-    \svg at quotes@remove{\filename at area}%
-    \svg at quotes@remove{\filename at base}%
-    \ifx\filename at ext\relax\else%
-      \svg at quotes@remove{\filename at ext}%
-    \fi%
+    \svg at quotes@remove[{#2}]{\svg at tempa}%
+    \svg at filename@parse[{#1}]{\svg at tempa}%
     \IfArgIsEmpty{#1}{%
+      \svg at quotes@remove[{#3}]{\svg at tempb}%
       \def\svg at tempa{%
         Did you run the export with Inkscape? There's no file\MessageBreak%
-        `\filename at area\filename at base.\filename at ext'%
+        `\filename at area\filename at base.\filename at ext'\MessageBreak%
+        although `\svg at tempb' was found.%
       }%
     }{%
       \edef\filename at ext{#1}%
@@ -2228,7 +2455,7 @@
       \ifx\input at path\@undefined%
         \def\svg at tempb{No additional path was given.}%
       \else%
-        \def\svg at tempb{Following folders have been searched:}%
+        \def\svg at tempb{Following folders have additionally been searched:}%
         \expandafter\@tfor\expandafter\svg at tempa\expandafter:\expandafter=%
             \input at path\do{%
           \edef\svg at tempb{\svg at tempb\noexpand\MessageBreak\svg at tempa}%
@@ -2279,11 +2506,10 @@
 %    \end{macrocode}
 % \end{macro}^^A \svg at iffilenewer
 %
-%
-%
 % \subsection{Optional Parameters for user commands}
 %
 % \begin{macro}{\svg at local@param at set}
+% \changes{v2.02}{2018/09/07}{reasonable value for key \opt{distort}}^^A
 % \begin{macro}{\svg at local@param at use}
 % \begin{macro}{\svg at local@param at def}
 % Most of the package options can also be used as optional parameters for 
@@ -2302,6 +2528,17 @@
 % \val{png} with option \opt{inkscapeformat}.
 %    \begin{macrocode}
   \ifstr{\svg at 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 at tempswafalse%
+  \ifdim\svg at param@width>\z@\relax\ifdim\svg at param@height>\z@\relax%
+    \@svg at tempswatrue%
+  \fi\fi%
+  \if at svg@tempswa\else%
+    \FamilyOptions{SVG}{distort=false}%
+  \fi%
 }
 \newcommand*\svg at local@param at use{}
 \newcommand*\svg at local@param at def[1]{%
@@ -2309,14 +2546,29 @@
     \unexpanded\expandafter{\svg at local@param at use}\unexpanded{#1}%
   }%
 }
-\DefineFamilyMember[.param]{SVG}
 %    \end{macrocode}
 % \end{macro}^^A \svg at local@param at def
 % \end{macro}^^A \svg at local@param at use
 % \end{macro}^^A \svg at local@param at 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 @@
 % \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 at 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,7 +2597,14 @@
 \newcommand*\svg at input@path{}
 \let\svg at input@path\input at path
 \newcommand*\svgpath[1]{%
-  \def\svg at input@path{#1}%
+  \def\svg at tempa##1\@nil{%
+    \ifx\svg at tempb\bgroup%
+      \def\svg at input@path{#1}%
+    \else%
+      \def\svg at input@path{{#1}}%
+    \fi%
+  }%
+  \futurelet\svg at tempb\svg at tempa#1\@nil%
 }
 %    \end{macrocode}
 % \end{macro}^^A \svg at input@path
@@ -2349,9 +2611,10 @@
 % \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 at 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,9 +2633,13 @@
 % \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}
@@ -2379,25 +2646,6 @@
 % \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 @@
 %    \begin{macrocode}
     \svg at local@param at 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 at ink@run%
       \IfFileExists{\svg at out@base}{}{%
         \@svg at file@foundfalse%
-        \svg at file@missing{\svg at out@base}{}%
+        \svg at file@missing{\svg at out@base}{\svg at file@base.\svg at file@ext}%
       }%
       \if at svg@ink at latex%
         \IfFileExists{\svg at out@base_tex}{}{%
           \@svg at file@foundfalse%
-          \svg at file@missing{\svg at out@base_tex}{}%
+          \svg at file@missing{\svg at out@base_tex}{\svg at file@base.\svg at file@ext}%
         }%
       \fi%
 %    \end{macrocode}
@@ -2493,6 +2724,7 @@
 % \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 @@
 \newcommand*\svg at param@angle{0}
 \svg at local@param at def{%
   \DefineFamilyKey[.param]{SVG}{angle}{%
-    \renewcommand*\svg at param@angle{#1}%
-    \FamilyKeyStateProcessed%
+    \ifisdimension{#1\p@}{%
+      \renewcommand*\svg at param@angle{#1}%
+      \FamilyKeyStateProcessed%
+    }{}%
   }%
 }
 \newcommand*\svg at param@origin{c}
@@ -2518,10 +2752,11 @@
 % \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 at 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,26 +2767,50 @@
 % 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 at parse{#2}%
+    \svg at filename@parse{#2}%
     \ifx\filename at ext\relax\else%
       \svg at quotes@remove{\filename at ext}%
       \expandafter\lowercase\expandafter{%
         \expandafter\def\expandafter\filename at ext\expandafter{\filename at ext}%
       }%
-      \let\svg at tempb\filename at ext%
-      \def\svg at tempa##1_tex##2\@nil{\def\svg at tempb{##1}}%
-      \expandafter\svg at tempa\svg at tempb_tex\@nil%
-      \@for\svg at tempa:={pdf,eps,ps,png}\do{%
-        \ifstr{\svg at tempb}{\svg at tempa}{%
-          \edef\svg at tempa{%
-            \noexpand\FamilyOptions{SVG}{inkscapeformat=\svg at tempb}%
-          }%
-          \svg at tempa%
-        }{}%
+      \def\svg at tempb##1_tex##2\@nil{%
+        \IfArgIsEmpty{##1}{}{\def\filename at ext{##1}}%
+        \ifstr{##2}{_tex}{\@svg at tempswatrue}{\@svg at tempswafalse}%
       }%
-      \ifstr{\filename at ext}{\svg at ink@format_tex}{%
-        \FamilyOptions{SVG}{inkscapelatex=true}%
-      }{}%
+      \@svg at tempswafalse%
+      \@tfor\svg at tempa:={pdf}{eps}{ps}{png}\do{%
+        \begingroup%
+          \expandafter\svg at tempb\filename at ext_tex\@nil%
+          \svg at extension@parse{\svg at tempa}%
+          \ifx\filename at ext\relax%
+            \def\svg at tempb{\endgroup}%
+          \else%
+            \edef\svg at tempb{%
+              \endgroup%
+              \noexpand\FamilyOptions{SVG}{inkscapeformat=\svg at tempa}%
+              \if at svg@tempswa%
+                \noexpand\FamilyOptions{SVG}{inkscapelatex=true}%
+              \fi%
+              \def\noexpand\filename at base{\filename at base}%
+              \def\noexpand\filename at ext{\filename at ext}%
+              \noexpand\@svg at tempswatrue%
+            }%
+          \fi%
+        \svg at tempb%
+%    \end{macrocode}
+% Break for loop, if valid extension was found.
+%    \begin{macrocode}
+        \if at svg@tempswa%
+          \@break at 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 at base}.
+%    \begin{macrocode}
+      \if at svg@tempswa\else%
+        \svg at extension@parse{\svg at ink@format}%
+      \fi%
     \fi%
 %    \end{macrocode}
 % \begin{parameter}{inkscapeformat}
@@ -2558,6 +2817,7 @@
 % \begin{parameter}{inkscapelatex}
 % \begin{parameter}{width}
 % \begin{parameter}{height}
+% \begin{parameter}{distort}
 % \begin{parameter}{scale}
 % \begin{parameter}{pretex}
 % \begin{parameter}{apptex}
@@ -2565,26 +2825,7 @@
 % \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).
@@ -2591,25 +2832,6 @@
 %    \begin{macrocode}
     \svg at local@param at 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,6 +2839,7 @@
 % \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
@@ -2623,7 +2846,7 @@
 % \end{parameter}^^A inkscapeformat
 % Searching all given paths for the relevant PDF/EPS~file.
 %    \begin{macrocode}
-    \expandafter\svg at get@path\expandafter[\svg at ink@format]{#2}{\svg at out@path}%
+    \svg at get@path[\svg at ink@format]{\filename at area\filename at base}{\svg at out@path}%
     \if at svg@file at found%
 %    \end{macrocode}
 % Checking the required files for graphic inclusion.
@@ -2633,7 +2856,7 @@
       \if at svg@ink at latex%
         \IfFileExists{\svg at out@base_tex}{}{%
           \@svg at file@foundfalse%
-          \svg at file@missing{\svg at out@base_tex}{}%
+          \svg at file@missing{\svg at out@base_tex}{\svg at out@base}%
         }%
       \fi%
 %    \end{macrocode}
@@ -2719,8 +2942,7 @@
             \ifnum\pdf at shellescape=\@ne\relax\if at svg@ink at run%
               \svg at iffilenewer{\svg at out@base_tex}{\svg at out@base}{%
                 \@svg at ink@runfalse%
-                \edef\svg at tempa{\svg at out@base}%
-                \svg at quotes@remove{\svg at tempa}%
+                \svg at quotes@remove[\svg at out@base]{\svg at tempa}%
                 \PackageWarning{svg}{%
                   Since the encountered filedate of file\MessageBreak%
                   `\svg at tempa_tex' is newer than \MessageBreak%
@@ -2761,10 +2983,8 @@
 % Executing \app{Inkscape} on command line. Afterwards, the export results are 
 % moved into the given output path.
 %    \begin{macrocode}
-          \edef\svg at tempa{\svg at file@base}%
-          \edef\svg at tempb{\svg at out@name}%
-          \svg at quotes@remove{\svg at tempa}%
-          \svg at quotes@remove{\svg at tempb}%
+          \svg at quotes@remove[\svg at file@base]{\svg at tempa}%
+          \svg at quotes@remove[\svg at out@name]{\svg at tempb}%
           \ShellEscape{\svg at ink@cmd{\svg at tempa}{\svg at tempb}}%
           \IfFileExists{\svg at out@name.\svg at ink@format}{%
             \edef\svg at tempb{\svg at tempb.\svg at ink@format}%
@@ -2787,8 +3007,7 @@
 % If \file{-{}-shell-escape} wasn't enabled, a warning is issued.
 %    \begin{macrocode}
         \else%
-          \edef\svg at tempa{\svg at file@base}%
-          \svg at quotes@remove{\svg at tempa}%
+          \svg at quotes@remove[\svg at file@base]{\svg at 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 @@
         \PackageInfo{svg}{Last page of `#1' is \the\@tempcnta}%
       \fi%
       \edef\svg at tempa{%
-        \noexpand\endgroup%
+        \endgroup%
         \noexpand\FamilyOptions{SVG}{lastpage=\the\@tempcnta}%
       }%
     \svg at tempa%
@@ -2894,37 +3113,71 @@
     \@svg at 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 at tempb} as 
+% extension. Everything before is stored in \cs{svg at tempa}.
+%    \begin{macrocode}
+  \def\svg at tempb##1.##2\@nil{%
+    \IfArgIsEmpty{##2}{%
+      \def\svg at tempb{##1}%
+    }{%
+      \edef\svg at tempa{\svg at tempa.##1}%
+      \svg at tempb##2\@nil%
+    }%
+  }%
+  \edef\svg at tempa{%
+    \def\noexpand\svg at tempa{}%
+    \noexpand\svg at tempb#2.\noexpand\@nil%
+  }%
+  \svg at tempa%
+%    \end{macrocode}
+% Afterwards \cs{svg at tempa} is defined with the file name itself within 
+% enclosing braces followed by the extension and \cs{svg at tempb} holds the 
+% original file name plus extension without enclosing braces.
+%    \begin{macrocode}
+  \svg at remove@leadingchar.\svg at tempa%
+  \edef\svg at tempa{{\svg at tempa}.\svg at tempb}%
+  \edef\svg at 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 at patches}.
 %    \begin{macrocode}
-  \edef\svg at tempa{#2}%
   \if at svg@ink at latex%
     \svg at patches{\svg at tempa}%
     \ifnum\value{svg at param@lastpage}=\z@\relax%
-      \expandafter\svg at get@lastpage\expandafter{\svg at tempa}%
+      \expandafter\svg at get@lastpage\expandafter{\svg at tempb}%
     \fi%
     \edef\svg at tempa{%
       \ifx\svg at param@pretex\relax\else%
         \noexpand\svg at param@pretex%
       \fi%
-      \noexpand\input{\svg at tempa_tex}%
+      \noexpand\input{\svg at tempb_tex}%
       \ifx\svg at param@apptex\relax\else%
         \noexpand\svg at param@apptex%
       \fi%
     }%
 %    \end{macrocode}
+% If \opt{distort=true} is desired, the input is resized with \cs{resizebox*}.
+%    \begin{macrocode}
+    \if at svg@param at distort%
+      \def\svg at tempb{\resizebox*{\svg at param@width}{\svg at param@height}}%
+    \else%
+      \let\svg at tempb\@firstofone%
+    \fi%
+    \sbox\svg at box{\svg at tempb{\svg at tempa}}%
+%    \end{macrocode}
 % If a rotation angle was given, the input is done within \cs{rotatebox}.
 %    \begin{macrocode}
     \ifdim\dimexpr\svg at param@angle\p@\relax=\z@\relax%
-      \svg at tempa%
+      \let\svg at tempb\@firstofone%
     \else%
-      \edef\svg at tempb{origin=\svg at param@origin}%
-      \expandafter\rotatebox\expandafter[\svg at tempb]{\svg at param@angle}{%
-        \svg at tempa%
+      \edef\svg at tempb{%
+        \noexpand\rotatebox[origin=\svg at param@origin]{\svg at param@angle}%
       }%
     \fi%
+    \svg at tempb{\usebox\svg at box}%
   \else%
 %    \end{macrocode}
 % If the export with \app{Inkscape} was done without \LaTeX~support, the 
@@ -2931,7 +3184,11 @@
 % resulting graphic file will be included with \cs{includegraphics}.
 %    \begin{macrocode}
     \svg at wrn@scale%
-    \edef\svg at tempb{keepaspectratio,scale=\svg at param@scale}%
+    \edef\svg at tempb{%
+      draft\if at svg@draft\else=false\fi,%
+      scale=\svg at param@scale,%
+      keepaspectratio\if at svg@param at distort=false\fi%
+    }%
     \ifdim\svg at param@height>\z@\relax%
       \edef\svg at tempb{\svg at tempb,height=\svg at param@height}%
     \fi%
@@ -2943,11 +3200,6 @@
         \svg at tempb,origin=\svg at param@origin,angle=\svg at param@angle%
       }%
     \fi%
-    \if at svg@draft%
-      \edef\svg at tempb{\svg at tempb,draft}%
-    \else%
-      \edef\svg at tempb{\svg at tempb,draft=false}%
-    \fi%
     \expandafter\includegraphics\expandafter[\svg at tempb]{\svg at tempa}%
   \fi%
 }
@@ -3050,10 +3302,10 @@
     }%
   \fi%
 %    \end{macrocode}
-% Pages are only included, if counter \cnt{svg at param@lastpage} is smaller than 
-% \cnt{svg at param@currpage}, where \cnt{svg at param@lastpage} was either given as 
-% a number with parameter \prm{lastpage} or was automatically calculated with 
-% \cs{svg at get@lastpage}.
+% Only if counter \cnt{svg at param@lastpage} is smaller than 
+% \cnt{svg at param@currpage}, pages are included, where \cnt{svg at param@lastpage}
+% was either given as a number with parameter \prm{lastpage} or was
+% automatically calculated with \cs{svg at get@lastpage}.
 %    \begin{macrocode}
   \ifnum\value{svg at param@currpage}>\value{svg at param@lastpage}\relax\else%
 %    \end{macrocode}
@@ -3076,7 +3328,7 @@
 %
 %
 %
-% \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 at deprecated@key{pdf}{extractformat={\svgx at format}}%
     \else%
-      \FamilyKeyStateUnknownValue
+      \FamilyKeyStateUnknownValue%
     \fi%
   \fi%
 }
@@ -3224,7 +3476,7 @@
       }%
       \svg at deprecated@key{eps}{extractformat={\svgx at format}}%
     \else%
-      \FamilyKeyStateUnknownValue
+      \FamilyKeyStateUnknownValue%
     \fi%
   \fi%
 }
@@ -3441,7 +3693,7 @@
     `pdftopsopt' instead. See the manual for\MessageBreak%
     more. Nothing was done%
   }%
-  \FamilyKeyStateProcessed
+  \FamilyKeyStateProcessed%
 }
 %</extract>
 %    \end{macrocode}
@@ -3594,7 +3846,7 @@
       }%
       \svg at deprecated@key{png}{convertformat={\svgx at cnv@format}}%
     \else%
-      \FamilyKeyStateUnknownValue
+      \FamilyKeyStateUnknownValue%
     \fi%
   \fi%
 }
@@ -3739,10 +3991,12 @@
 %
 % \begin{option}{extractpath}
 % \changes{v2.00}{2017/02/24}{new}^^A
+% \changes{v2.02}{2018/09/07}{usage of \cs{svg at 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 at 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 @@
 %<*extract>
 \newcommand*\svgx at out@path{}
 \DefineFamilyKey{SVG}{extractpath}{%
+  \svg at sanitize@dq\svg at tempb{#1}%
   \FamilySetNumerical{SVG}{extractpath}{svg at 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 at tempb}%
   \ifx\FamilyKeyState\FamilyKeyStateProcessed%
     \ifcase\svg at tempa\relax% svgpath
       \renewcommand*\svgx at out@path{\svg at file@path}%
@@ -3781,7 +4036,7 @@
       \renewcommand*\svgx at out@path{./svg-extract/}%
     \fi%
   \else%
-    \renewcommand*\svgx at out@path{#1}%
+    \edef\svgx at out@path{\svg at tempb}%
     \svg at normalize@path{\svgx at out@path}%
     \FamilyKeyStateProcessed%
   \fi%
@@ -3793,12 +4048,13 @@
 \newcommand*\svgx at out@name{}
 \newif\if at svgx@out at sec
 \DefineFamilyKey{SVG}{extractname}{%
+  \svg at quotes@remove[{#1}]{\svg at tempb}%
   \FamilySetNumerical{SVG}{extractname}{svg at tempa}{%
     {filename}{0},{name}{0},%
     {filenamenumbered}{1},{namenumbered}{1},%
     {numberedfilename}{1},{numberedname}{1},%
     {numbered}{2},{section}{2},{numberedsection}{2},{sectionnumbered}{2}%
-  }{#1}%
+  }{\svg at tempb}%
   \@svgx at out@secfalse%
   \ifx\FamilyKeyState\FamilyKeyStateProcessed%
     \ifcase\svg at tempa\relax% filename
@@ -3810,10 +4066,11 @@
       \@svgx at out@sectrue%
     \fi%
   \else%
-    \def\svg at tempa##1.##2\@nil{%
-      \IfArgIsEmpty{##1}{}{\renewcommand*\svgx at out@name{##1}}%
-    }%
-    \svg at tempa#1.\@nil%
+    \if at svg@quotes at found%
+      \edef\svgx at out@name{"\svg at tempb"}%
+    \else%
+      \edef\svgx at out@name{\svg at tempb}%
+    \fi%
     \FamilyKeyStateProcessed%
   \fi%
 }
@@ -3841,6 +4098,10 @@
 % \begin{option}{extractheight}
 % \changes{v2.00}{2017/02/20}{new}^^A
 % \begin{macro}{\svgx at param@width}
+% \begin{option}{extractdistort}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% \begin{option}{extractkeepaspectratio}
+% \begin{macro}{\svgx at param@distort}
 % \begin{option}{extractscale}
 % \changes{v2.00}{2017/02/20}{new}^^A
 % \begin{macro}{\svgx at param@scale}
@@ -3853,6 +4114,8 @@
 %<*base>
 \svg at dummy@key{extractwidth}
 \svg at dummy@key{extractheight}
+\svg at dummy@key{extractdistort}
+\svg at dummy@key{extractkeepaspectratio}
 \svg at dummy@key{extractscale}
 %</base>
 %<*extract>
@@ -3868,8 +4131,10 @@
       \FamilyKeyStateProcessed%
     }{%
       \FamilySetLengthMacro{SVG}{extractwidth}{\svgx at param@width}{#1}%
-      \ifdim\svgx at param@width<\z@\relax%
-        \FamilyKeyStateUnknownValue%
+      \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+        \ifdim\svgx at param@width<\z@\relax%
+          \FamilyKeyStateUnknownValue%
+        \fi%
       \fi%
     }%
   }%
@@ -3886,12 +4151,41 @@
       \FamilyKeyStateProcessed%
     }{%
       \FamilySetLengthMacro{SVG}{extractheight}{\svgx at param@height}{#1}%
-      \ifdim\svgx at param@height<\z@\relax%
-        \FamilyKeyStateUnknownValue%
+      \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+        \ifdim\svgx at param@height<\z@\relax%
+          \FamilyKeyStateUnknownValue%
+        \fi%
       \fi%
     }%
   }%
 }
+\newif\if at svgx@param at distort
+\DefineFamilyKey{SVG}{extractdistort}[true]{%
+  \FamilyKeyStateUnknownValue%
+  \svg at ifvalueisrelax{#1}{%
+    \@svgx at param@distortfalse%
+    \FamilyKeyStateProcessed%
+  }{%
+    \ifstr{#1}{inherit}{%
+      \renewcommand*\if at svgx@param at distort{\if at svg@param at distort}%
+      \FamilyKeyStateProcessed%
+    }{%
+      \FamilySetBool{SVG}{extractdistort}{@svgx at param@distort}{#1}%
+    }%
+  }%
+}
+\DefineFamilyKey{SVG}{extractkeepaspectratio}[true]{%
+  \FamilySetBool{SVG}{extractkeepaspectratio}{@svg at tempswa}{#1}%
+  \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+    \if at svg@tempswa%
+      \FamilyOptions{SVG}{extractdistort=false}%
+    \else
+      \FamilyOptions{SVG}{extractdistort=true}%
+    \fi%
+  \else%
+    \FamilyOptions{SVG}{extractdistort=#1}%
+  \fi%
+}
 \newcommand*\svgx at param@scale{\svg at param@scale}
 \DefineFamilyKey{SVG}{extractscale}{%
   \FamilyKeyStateUnknownValue%
@@ -3916,6 +4210,9 @@
 %    \end{macrocode}
 % \end{macro}^^A \svgx at param@scale
 % \end{option}^^A extractscale
+% \end{macro}^^A \svgx at param@distort
+% \end{option}^^A extractkeepaspectratio
+% \end{option}^^A extractdistort
 % \end{macro}^^A \svgx at param@height
 % \end{option}^^A extractheight
 % \end{macro}^^A \svgx at param@width
@@ -3942,9 +4239,9 @@
     \let\svgx at param@pretex\relax%
   }{%
     \ifstr{#1}{inherit}{%
-      \def\svgx at param@pretex{\svg at param@pretex}%
+      \renewcommand*\svgx at param@pretex{\svg at param@pretex}%
     }{%
-      \def\svgx at param@pretex{#1}%
+      \renewcommand*\svgx at param@pretex{#1}%
     }%
   }%
   \FamilyKeyStateProcessed%
@@ -3955,9 +4252,9 @@
     \let\svgx at param@apptex\relax%
   }{%
     \ifstr{#1}{inherit}{%
-      \def\svgx at param@apptex{\svg at param@apptex}%
+      \renewcommand*\svgx at param@apptex{\svg at param@apptex}%
     }{%
-      \def\svgx at param@apptex{#1}%
+      \renewcommand*\svgx at param@apptex{#1}%
     }%
   }%
   \FamilyKeyStateProcessed%
@@ -4048,6 +4345,123 @@
 %
 % \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 at param@angle{0}
+\svg at local@param at def{%
+  \DefineFamilyKey[.param]{SVG}{extractangle}{%
+    \FamilyKeyStateUnknownValue%
+    \svg at ifvalueisrelax{#1}{%
+      \renewcommand*\svgx at param@angle{0}%
+      \FamilyKeyStateProcessed%
+    }{%
+      \ifstr{#1}{inherit}{%
+        \renewcommand*\svgx at param@angle{\svg at param@angle}%
+        \FamilyKeyStateProcessed%
+      }{%
+        \ifisdimension{#1\p@}{%
+          \renewcommand*\svgx at 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 @@
         \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 at tempa'%
+          file `\svg at tempa'\MessageBreak%
         }%
       \endgroup%
     \fi%
@@ -4330,6 +4744,9 @@
       \ifdim\svgx at param@height>\z@\relax%
         \svg at tempa{height=\svgx at param@height}%
       \fi%
+      \if at svgx@param at distort%
+        \svg at tempa{distort=true}%
+      \fi%
       \ifdim\dimexpr\svgx at param@scale\p@\relax=\p@\relax\else%
         \svg at tempa{scale=\svgx at param@scale}%
       \fi%
@@ -4366,6 +4783,14 @@
         }{}%
       \fi%
 %    \end{macrocode}
+% The rotation angle, if given.
+%    \begin{macrocode}
+      \ifdim\dimexpr\svgx at param@angle\p@\relax=\z@\relax\else%
+        \edef\svg at tempa{%
+          angle=\svgx at param@angle\ifx\svg at tempa\@empty\else,\svg at 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 @@
         }{}%
       \fi%
       \immediate\write\svgx at stream@out{%
-        \string\svgxdelayed{\@percentchar^^J%
-          \space\space\svg at tempa\@percentchar^^J%
-        }^^J^^J%
         \string\begin{document}^^J%
         \string\pagestyle{empty}^^J%
         \string\svgxoutputbox\@percentchar^^J%
@@ -4504,7 +4926,7 @@
             \expandafter\svgx at ifinlist\expandafter{\svg at tempa}{\svgx at format}{%
               \PackageWarning{svg-extract}{%
                 File type `\svg at tempa' was specified for option\MessageBreak% 
-                `extractformat' (\svgx at format) as well as for \MessageBreak
+                `extractformat' (\svgx at format) as well as for \MessageBreak%
                 option `convertformat' (\svgx at cnv@format) so the\MessageBreak%
                 conversion won't be done%
               }%
@@ -4701,8 +5123,8 @@
     }%
     \svg at tempa#1,\@nil%
     \edef\svg at tempa{%
-      \noexpand\endgroup%
-      \noexpand\def\noexpand\svgx at cnv@informat{\svg at tempa}%
+      \endgroup%
+      \def\noexpand\svgx at cnv@informat{\svg at tempa}%
     }%
   \svg at tempa%
 %    \end{macrocode}
@@ -4782,9 +5204,9 @@
         \edef\svg at tempb{%
           The graphic file \svg at 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 at tempb{%
@@ -4900,11 +5322,11 @@
       \fi%
     }%
     \edef\svg at tempb{%
-      \noexpand\endgroup%
+      \endgroup%
       \ifx\svg at tempa\relax%
-        \noexpand\let\noexpand\svg at tempa\noexpand\relax%
+        \let\noexpand\svg at tempa\noexpand\relax%
       \else%
-        \noexpand\def\noexpand\svg at tempa{\svg at tempa}%
+        \def\noexpand\svg at tempa{\svg at tempa}%
       \fi%
     }%
   \svg at tempb%
@@ -4982,42 +5404,48 @@
 % 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 at ifundefinedorrelax{AtEndPreamble}{%
-    \AtBeginDocument{#1}%
-  }{%
-    \AtEndPreamble{\AtBeginDocument{#1}}%
-  }%
-}
-%    \end{macrocode}
-% \end{macro}^^A \svgxdelayed
 % \begin{macro}{\svgxsetbox}
-% \begin{macro}{\svgx at box}
+% \changes{v2.02}{2018/09/07}{late execution of \cs{svgxsetpapersize}}^^A
+% \begin{macro}{\svgx at setbox}
+% \changes{v2.02}{2018/09/07}{new}^^A
+% \begin{macro}{\if at 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 at 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 at 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 at box
+\newif\if at svgx@standalone
 \newcommand*\svgxsetbox[2][]{%
-  \csname @tud at x@standalone at croptrue\endcsname%
-  \sbox\svgx at box{\svg@@input[{#1},draft=false]{#2}}%
-  \svgxsetpapersize%
+  \@svgx at standalonetrue%
+  \svgx at setbox{#1}{#2}%
+  \scr at ifundefinedorrelax{AtEndPreamble}{%
+    \let\svg at tempa\@firstofone%
+  }{%
+    \def\svg at tempa{\AtEndPreamble}%
+  }%
+  \svg at tempa{\AtBeginDocument{\svgx at setbox{#1}{#2}}}%
 }
+\newcommand*\svgx at setbox[2]{%
+  \sbox\svg at box{\svg@@input[{#1},draft=false]{#2}}%
+  \svgxsetpapersize% 
+}
 %    \end{macrocode}
-% \end{macro}^^A \svgx at box
+% \end{macro}^^A \if at svgx@standalone
+% \end{macro}^^A \svgx at 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 at box}.
+% well as the type area to the size of \cs{svg at box}.
 %    \begin{macrocode}
 \newcommand*\svgxsetpapersize{%
-  \setlength\paperwidth{\the\wd\svgx at box}%
+  \setlength\paperwidth{\the\wd\svg at 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 at ifundefinedorrelax}.
@@ -5029,7 +5457,7 @@
     \setlength\mediawidth{\paperwidth}%
   }%
   \setlength\textwidth{\paperwidth}%
-  \setlength\paperheight{\the\dimexpr\ht\svgx at box+\dp\svgx at box\relax}%
+  \setlength\paperheight{\the\dimexpr\ht\svg at box+\dp\svg at box\relax}%
   \scr at ifundefinedorrelax{stockheight}{}{%
     \setlength\stockheight{\paperheight}%
   }%
@@ -5071,10 +5499,10 @@
     \if at svgx@beamer%
       \setbeamertemplate{navigation symbols}{}%
       \begin{frame}[plain]%
-      \usebox\svgx at box%
+      \usebox\svg at box%
       \end{frame}%
     \else%
-      \usebox\svgx at box%
+      \usebox\svg at box%
     \fi%
     \endgraf%
   \endgroup%
@@ -5097,13 +5525,15 @@
 %    \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 @@
 %    \begin{macrocode}
 \newcommand*\svg at shell@mkdir[1]{%
   \begingroup%
-    \edef\svg at tempa{#1}%
-    \svg at quotes@remove{\svg at tempa}%
+    \svg at quotes@remove[{#1}]{\svg at tempa}%
     \@svg at tempswatrue%
     \ifstr{\svg at tempa}{}{\@svg at tempswafalse}{%
     \ifstr{\svg at tempa}{./}{\@svg at tempswafalse}{%
@@ -5180,6 +5609,10 @@
 % \end{macro}^^A \svg at shell@mv
 % \end{macro}^^A \svg at shell@@mkdir
 % \end{macro}^^A \svg at shell@mkdir
+% At the very end, the catcodes are restored.
+%    \begin{macrocode}
+\svg at catcodecodes@restore
+%    \end{macrocode}
 %
 % \iffalse
 %</package&base&body>

Modified: trunk/Master/texmf-dist/tex/latex/svg/svg-extract.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/svg/svg-extract.sty	2018-09-08 21:41:40 UTC (rev 48625)
+++ trunk/Master/texmf-dist/tex/latex/svg/svg-extract.sty	2018-09-08 21:41:57 UTC (rev 48626)
@@ -33,7 +33,7 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{svg-extract}[%
-  2017/11/29 v2.01\space%
+  2018/09/08 v2.02\space%
   (extract independent graphics from SVG pictures)%
 ]
 \RequirePackage{svg}[2017/03/27]
@@ -81,7 +81,7 @@
       }%
       \svg at deprecated@key{pdf}{extractformat={\svgx at format}}%
     \else%
-      \FamilyKeyStateUnknownValue
+      \FamilyKeyStateUnknownValue%
     \fi%
   \fi%
 }
@@ -94,7 +94,7 @@
       }%
       \svg at deprecated@key{eps}{extractformat={\svgx at format}}%
     \else%
-      \FamilyKeyStateUnknownValue
+      \FamilyKeyStateUnknownValue%
     \fi%
   \fi%
 }
@@ -196,7 +196,7 @@
     `pdftopsopt' instead. See the manual for\MessageBreak%
     more. Nothing was done%
   }%
-  \FamilyKeyStateProcessed
+  \FamilyKeyStateProcessed%
 }
 \newif\if at svgx@cnv at run
 \newcommand*\svgx at cnv@cmd{}
@@ -286,7 +286,7 @@
       }%
       \svg at deprecated@key{png}{convertformat={\svgx at cnv@format}}%
     \else%
-      \FamilyKeyStateUnknownValue
+      \FamilyKeyStateUnknownValue%
     \fi%
   \fi%
 }
@@ -341,12 +341,13 @@
 }
 \newcommand*\svgx at out@path{}
 \DefineFamilyKey{SVG}{extractpath}{%
+  \svg at sanitize@dq\svg at tempb{#1}%
   \FamilySetNumerical{SVG}{extractpath}{svg at 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 at tempb}%
   \ifx\FamilyKeyState\FamilyKeyStateProcessed%
     \ifcase\svg at tempa\relax% svgpath
       \renewcommand*\svgx at out@path{\svg at file@path}%
@@ -358,7 +359,7 @@
       \renewcommand*\svgx at out@path{./svg-extract/}%
     \fi%
   \else%
-    \renewcommand*\svgx at out@path{#1}%
+    \edef\svgx at out@path{\svg at tempb}%
     \svg at normalize@path{\svgx at out@path}%
     \FamilyKeyStateProcessed%
   \fi%
@@ -370,12 +371,13 @@
 \newcommand*\svgx at out@name{}
 \newif\if at svgx@out at sec
 \DefineFamilyKey{SVG}{extractname}{%
+  \svg at quotes@remove[{#1}]{\svg at tempb}%
   \FamilySetNumerical{SVG}{extractname}{svg at tempa}{%
     {filename}{0},{name}{0},%
     {filenamenumbered}{1},{namenumbered}{1},%
     {numberedfilename}{1},{numberedname}{1},%
     {numbered}{2},{section}{2},{numberedsection}{2},{sectionnumbered}{2}%
-  }{#1}%
+  }{\svg at tempb}%
   \@svgx at out@secfalse%
   \ifx\FamilyKeyState\FamilyKeyStateProcessed%
     \ifcase\svg at tempa\relax% filename
@@ -387,10 +389,11 @@
       \@svgx at out@sectrue%
     \fi%
   \else%
-    \def\svg at tempa##1.##2\@nil{%
-      \IfArgIsEmpty{##1}{}{\renewcommand*\svgx at out@name{##1}}%
-    }%
-    \svg at tempa#1.\@nil%
+    \if at svg@quotes at found%
+      \edef\svgx at out@name{"\svg at tempb"}%
+    \else%
+      \edef\svgx at out@name{\svg at tempb}%
+    \fi%
     \FamilyKeyStateProcessed%
   \fi%
 }
@@ -409,8 +412,10 @@
       \FamilyKeyStateProcessed%
     }{%
       \FamilySetLengthMacro{SVG}{extractwidth}{\svgx at param@width}{#1}%
-      \ifdim\svgx at param@width<\z@\relax%
-        \FamilyKeyStateUnknownValue%
+      \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+        \ifdim\svgx at param@width<\z@\relax%
+          \FamilyKeyStateUnknownValue%
+        \fi%
       \fi%
     }%
   }%
@@ -427,12 +432,41 @@
       \FamilyKeyStateProcessed%
     }{%
       \FamilySetLengthMacro{SVG}{extractheight}{\svgx at param@height}{#1}%
-      \ifdim\svgx at param@height<\z@\relax%
-        \FamilyKeyStateUnknownValue%
+      \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+        \ifdim\svgx at param@height<\z@\relax%
+          \FamilyKeyStateUnknownValue%
+        \fi%
       \fi%
     }%
   }%
 }
+\newif\if at svgx@param at distort
+\DefineFamilyKey{SVG}{extractdistort}[true]{%
+  \FamilyKeyStateUnknownValue%
+  \svg at ifvalueisrelax{#1}{%
+    \@svgx at param@distortfalse%
+    \FamilyKeyStateProcessed%
+  }{%
+    \ifstr{#1}{inherit}{%
+      \renewcommand*\if at svgx@param at distort{\if at svg@param at distort}%
+      \FamilyKeyStateProcessed%
+    }{%
+      \FamilySetBool{SVG}{extractdistort}{@svgx at param@distort}{#1}%
+    }%
+  }%
+}
+\DefineFamilyKey{SVG}{extractkeepaspectratio}[true]{%
+  \FamilySetBool{SVG}{extractkeepaspectratio}{@svg at tempswa}{#1}%
+  \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+    \if at svg@tempswa%
+      \FamilyOptions{SVG}{extractdistort=false}%
+    \else
+      \FamilyOptions{SVG}{extractdistort=true}%
+    \fi%
+  \else%
+    \FamilyOptions{SVG}{extractdistort=#1}%
+  \fi%
+}
 \newcommand*\svgx at param@scale{\svg at param@scale}
 \DefineFamilyKey{SVG}{extractscale}{%
   \FamilyKeyStateUnknownValue%
@@ -459,9 +493,9 @@
     \let\svgx at param@pretex\relax%
   }{%
     \ifstr{#1}{inherit}{%
-      \def\svgx at param@pretex{\svg at param@pretex}%
+      \renewcommand*\svgx at param@pretex{\svg at param@pretex}%
     }{%
-      \def\svgx at param@pretex{#1}%
+      \renewcommand*\svgx at param@pretex{#1}%
     }%
   }%
   \FamilyKeyStateProcessed%
@@ -472,9 +506,9 @@
     \let\svgx at param@apptex\relax%
   }{%
     \ifstr{#1}{inherit}{%
-      \def\svgx at param@apptex{\svg at param@apptex}%
+      \renewcommand*\svgx at param@apptex{\svg at param@apptex}%
     }{%
-      \def\svgx at param@apptex{#1}%
+      \renewcommand*\svgx at param@apptex{#1}%
     }%
   }%
   \FamilyKeyStateProcessed%
@@ -569,11 +603,11 @@
       \fi%
     }%
     \edef\svg at tempb{%
-      \noexpand\endgroup%
+      \endgroup%
       \ifx\svg at tempa\relax%
-        \noexpand\let\noexpand\svg at tempa\noexpand\relax%
+        \let\noexpand\svg at tempa\noexpand\relax%
       \else%
-        \noexpand\def\noexpand\svg at tempa{\svg at tempa}%
+        \def\noexpand\svg at tempa{\svg at tempa}%
       \fi%
     }%
   \svg at tempb%
@@ -611,21 +645,23 @@
     \fi%
   }%
 }
-\newcommand*\svgxdelayed[1]{
+\newif\if at svgx@standalone
+\newcommand*\svgxsetbox[2][]{%
+  \@svgx at standalonetrue%
+  \svgx at setbox{#1}{#2}%
   \scr at ifundefinedorrelax{AtEndPreamble}{%
-    \AtBeginDocument{#1}%
+    \let\svg at tempa\@firstofone%
   }{%
-    \AtEndPreamble{\AtBeginDocument{#1}}%
+    \def\svg at tempa{\AtEndPreamble}%
   }%
+  \svg at tempa{\AtBeginDocument{\svgx at setbox{#1}{#2}}}%
 }
-\newbox\svgx at box
-\newcommand*\svgxsetbox[2][]{%
-  \csname @tud at x@standalone at croptrue\endcsname%
-  \sbox\svgx at box{\svg@@input[{#1},draft=false]{#2}}%
+\newcommand*\svgx at setbox[2]{%
+  \sbox\svg at box{\svg@@input[{#1},draft=false]{#2}}%
   \svgxsetpapersize%
 }
 \newcommand*\svgxsetpapersize{%
-  \setlength\paperwidth{\the\wd\svgx at box}%
+  \setlength\paperwidth{\the\wd\svg at box}%
   \scr at ifundefinedorrelax{stockwidth}{}{%
     \setlength\stockwidth{\paperwidth}%
   }%
@@ -633,7 +669,7 @@
     \setlength\mediawidth{\paperwidth}%
   }%
   \setlength\textwidth{\paperwidth}%
-  \setlength\paperheight{\the\dimexpr\ht\svgx at box+\dp\svgx at box\relax}%
+  \setlength\paperheight{\the\dimexpr\ht\svg at box+\dp\svg at box\relax}%
   \scr at ifundefinedorrelax{stockheight}{}{%
     \setlength\stockheight{\paperheight}%
   }%
@@ -665,16 +701,17 @@
     \if at svgx@beamer%
       \setbeamertemplate{navigation symbols}{}%
       \begin{frame}[plain]%
-      \usebox\svgx at box%
+      \usebox\svg at box%
       \end{frame}%
     \else%
-      \usebox\svgx at box%
+      \usebox\svg at box%
     \fi%
     \endgraf%
   \endgroup%
 }
 \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},%
@@ -681,6 +718,27 @@
   gsdevice={eps=eps2write},gsdevice={ps=ps2write}%
 }
 \FamilyProcessOptions{SVG}
+\DefineFamilyMember[.param]{SVG}
+\newcommand*\svgx at param@angle{0}
+\svg at local@param at def{%
+  \DefineFamilyKey[.param]{SVG}{extractangle}{%
+    \FamilyKeyStateUnknownValue%
+    \svg at ifvalueisrelax{#1}{%
+      \renewcommand*\svgx at param@angle{0}%
+      \FamilyKeyStateProcessed%
+    }{%
+      \ifstr{#1}{inherit}{%
+        \renewcommand*\svgx at param@angle{\svg at param@angle}%
+        \FamilyKeyStateProcessed%
+      }{%
+        \ifisdimension{#1\p@}{%
+          \renewcommand*\svgx at param@angle{#1}%
+          \FamilyKeyStateProcessed%
+        }{}%
+      }%
+    }%
+  }%
+}
 \let\svghidepreamblestart\relax
 \let\svghidepreambleend\relax
 \ifnum\pdf at shellescape=\@ne\relax\else%
@@ -692,7 +750,7 @@
         \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 at tempa'%
+          file `\svg at tempa'\MessageBreak%
         }%
       \endgroup%
     \fi%
@@ -833,6 +891,9 @@
       \ifdim\svgx at param@height>\z@\relax%
         \svg at tempa{height=\svgx at param@height}%
       \fi%
+      \if at svgx@param at distort%
+        \svg at tempa{distort=true}%
+      \fi%
       \ifdim\dimexpr\svgx at param@scale\p@\relax=\p@\relax\else%
         \svg at tempa{scale=\svgx at param@scale}%
       \fi%
@@ -864,6 +925,11 @@
           \fi%
         }{}%
       \fi%
+      \ifdim\dimexpr\svgx at param@angle\p@\relax=\z@\relax\else%
+        \edef\svg at tempa{%
+          angle=\svgx at param@angle\ifx\svg at tempa\@empty\else,\svg at tempa\fi%
+        }%
+      \fi%
       \ifx\svg at tempa\@empty%
         \def\svg at tempa{\string\svgxsetbox{#1}}%
       \else%
@@ -879,9 +945,6 @@
         }{}%
       \fi%
       \immediate\write\svgx at stream@out{%
-        \string\svgxdelayed{\@percentchar^^J%
-          \space\space\svg at tempa\@percentchar^^J%
-        }^^J^^J%
         \string\begin{document}^^J%
         \string\pagestyle{empty}^^J%
         \string\svgxoutputbox\@percentchar^^J%
@@ -954,7 +1017,7 @@
             \expandafter\svgx at ifinlist\expandafter{\svg at tempa}{\svgx at format}{%
               \PackageWarning{svg-extract}{%
                 File type `\svg at tempa' was specified for option\MessageBreak%
-                `extractformat' (\svgx at format) as well as for \MessageBreak
+                `extractformat' (\svgx at format) as well as for \MessageBreak%
                 option `convertformat' (\svgx at cnv@format) so the\MessageBreak%
                 conversion won't be done%
               }%
@@ -1073,8 +1136,8 @@
     }%
     \svg at tempa#1,\@nil%
     \edef\svg at tempa{%
-      \noexpand\endgroup%
-      \noexpand\def\noexpand\svgx at cnv@informat{\svg at tempa}%
+      \endgroup%
+      \def\noexpand\svgx at cnv@informat{\svg at tempa}%
     }%
   \svg at tempa%
   \ifx\svgx at cnv@informat\@empty%
@@ -1133,9 +1196,9 @@
         \edef\svg at tempb{%
           The graphic file \svg at 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 at tempb{%

Modified: trunk/Master/texmf-dist/tex/latex/svg/svg.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/svg/svg.sty	2018-09-08 21:41:40 UTC (rev 48625)
+++ trunk/Master/texmf-dist/tex/latex/svg/svg.sty	2018-09-08 21:41:57 UTC (rev 48626)
@@ -33,16 +33,25 @@
 %% 
 \NeedsTeXFormat{LaTeX2e}
 \ProvidesPackage{svg}[%
-  2017/11/29 v2.01\space%
+  2018/09/08 v2.02\space%
   (include SVG pictures)%
 ]
 \RequirePackage{scrbase}[2016/06/14]
+\RequirePackage{ifpdf}[2016/05/14]
+\RequirePackage{ifluatex}[2016/05/16]
 \RequirePackage{ifxetex}[2010/09/12]
-\RequirePackage{ifluatex}[2016/05/16]
-\RequirePackage{ifpdf}[2016/05/14]
 \RequirePackage{pdftexcmds}[2016/05/21]
 \RequirePackage{shellesc}[2016/06/07]
+\RequirePackage{trimspaces}[2009/09/17]
 \RequirePackage{graphicx}[1999/02/16]
+\newcommand*\svg at tempa{}
+\newcommand*\svg at tempb{}
+\newbox\svg at box
+\newif\if at svg@tempswa
+\edef\svg at catcodecodes@restore{%
+  \catcode`\noexpand\"\the\catcode`\"\relax%
+}
+\@makeother\"%
 \DefineFamily{SVG}
 \DefineFamilyMember{SVG}
 \newcommand*\svg at deprecated@key[3][svg]{%
@@ -53,9 +62,6 @@
   }%
   \FamilyOptions{SVG}{#3}%
 }
-\newcommand*\svg at tempa{}
-\newcommand*\svg at tempb{}
-\newif\if at svg@tempswa
 \newif\if at svg@use at xcolor
 \FamilyBoolKey{SVG}{usexcolor}{@svg at use@xcolor}
 \DeclareOption{noxcolor}{\FamilyOptions{SVG}{usexcolor=false}}
@@ -82,7 +88,7 @@
 }
 \newcommand*\svg at ink@mode{}
 \DefineFamilyKey{SVG}{inkscape}[true]{%
-  \lowercase{\def\svg at tempa{#1}}%
+  \lowercase{\svg at sanitize@dq\svg at tempb{#1}}%
   \FamilySetNumerical{SVG}{inkscape}{svg at tempa}{%
     {false}{0},{off}{0},{no}{0},%
     {true}{1},{on}{1},{yes}{1},{onlynewer}{1},{newer}{1},%
@@ -93,7 +99,7 @@
     {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 at tempa}%
+  }{\svg at tempb}%
   \ifx\FamilyKeyState\FamilyKeyStateProcessed%
     \ifnum\svg at tempa<\thr@@\relax%
       \let\svg at ink@mode\svg at tempa%
@@ -120,16 +126,23 @@
     \def\svg at tempa##1dpi##2\@nil{%
       \ifstr{##2}{dpi}{\FamilyOptions{SVG}{inkscapedpi=##1}}{}%
     }%
-    \lowercase{\svg at tempa#1dpi\@nil}%
+    \lowercase{\expandafter\svg at tempa\svg at tempb dpi\@nil}%
     \ifx\FamilyKeyState\FamilyKeyStateProcessed\else%
+      \svg at quotes@remove[{#1}]{\svg at tempb}%
       \def\svg at tempa##1-##2\@nil{%
         \IfArgIsEmpty{##2}{\def\svg at tempb{}}{%
-          \def\svg at tempa##1####1\@nil{\def\svg at tempb{####1}}%
-          \svg at tempa#1\@nil%
+          \def\svg at tempa####1-\@nil{\def\svg at tempb{-####1}}%
+          \svg at tempa##2\@nil%
         }%
-        \def\svg at tempa{##1}%
+        \edef\svg at tempa{\trim at spaces{##1}}%
       }%
-      \svg at tempa#1-\@nil%
+      \edef\svg at tempb{%
+        \noexpand\svg at tempa\svg at tempb-\noexpand\@nil%
+      }%
+      \svg at tempb%
+      \if at svg@quotes at found%
+        \edef\svg at tempa{"\svg at tempa"}%
+      \fi%
       \PackageWarning{svg}{%
         Setting the executable%
         \ifx\svg at tempb\@empty\else%
@@ -235,14 +248,8 @@
 }
 \newcommand*\svg at file@ext{svg}
 \DefineFamilyKey{SVG}{svgextension}{%
-  \def\svg at tempa##1.##2.##3\relax{%
-    \IfArgIsEmpty{##1}{%
-      \def\svg at file@ext{##2}%
-    }{%
-      \def\svg at file@ext{##1}%
-    }%
-  }%
-  \lowercase{\svg at tempa#1..\relax}%
+  \lowercase{\svg at quotes@remove[{#1}]{\svg at file@ext}}%
+  \svg at remove@leadingchar.\svg at file@ext%
 }
 \DefineFamilyKey{SVG}{extension}{\FamilyOptions{SVG}{svgextension=#1}}
 \DefineFamilyKey{SVG}{ext}{\FamilyOptions{SVG}{svgextension=#1}}
@@ -250,12 +257,13 @@
 \newcommand*\svg at out@name{\svg at file@name\svg at file@suffix}
 \newcommand*\svg at out@base{\svg at out@path\svg at out@name.\svg at ink@format}
 \DefineFamilyKey{SVG}{inkscapepath}{%
+  \svg at sanitize@dq\svg at tempb{#1}%
   \FamilySetNumerical{SVG}{inkscapepath}{svg at 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 at tempb}%
   \ifx\FamilyKeyState\FamilyKeyStateProcessed%
     \ifcase\svg at tempa\relax% svgpath
       \renewcommand*\svg at out@path{\svg at file@path}%
@@ -267,7 +275,7 @@
       \renewcommand*\svg at out@path{./svg-inkscape/}%
     \fi%
   \else%
-    \renewcommand*\svg at out@path{#1}%
+    \edef\svg at out@path{\svg at tempb}%
     \svg at normalize@path{\svg at out@path}%
     \FamilyKeyStateProcessed%
   \fi%
@@ -284,8 +292,10 @@
     \FamilyKeyStateProcessed%
   }{%
     \FamilySetLengthMacro{SVG}{width}{\svg at param@width}{#1}%
-    \ifdim\svg at param@width<\z@\relax%
-      \FamilyKeyStateUnknownValue%
+    \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+      \ifdim\svg at param@width<\z@\relax%
+        \FamilyKeyStateUnknownValue%
+      \fi%
     \fi%
   }%
 }
@@ -297,11 +307,25 @@
     \FamilyKeyStateProcessed%
   }{%
     \FamilySetLengthMacro{SVG}{height}{\svg at param@height}{#1}%
-    \ifdim\svg at param@height<\z@\relax%
-      \FamilyKeyStateUnknownValue%
+    \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+      \ifdim\svg at param@height<\z@\relax%
+        \FamilyKeyStateUnknownValue%
+      \fi%
     \fi%
   }%
 }
+\newif\if at svg@param at distort
+\FamilyBoolKey{SVG}{distort}{@svg at param@distort}
+\DefineFamilyKey{SVG}{keepaspectratio}[true]{%
+  \FamilySetBool{SVG}{keepaspectratio}{@svg at tempswa}{#1}%
+  \ifx\FamilyKeyState\FamilyKeyStateProcessed%
+    \if at svg@tempswa%
+      \FamilyOptions{SVG}{distort=false}%
+    \else
+      \FamilyOptions{SVG}{distort=true}%
+    \fi%
+  \fi%
+}
 \newcommand*\svg at param@scale{1}
 \DefineFamilyKey{SVG}{scale}{%
   \FamilyKeyStateUnknownValue%
@@ -357,13 +381,30 @@
 \newif\if at svg@draft
 \FamilyBoolKey{SVG}{draft}{@svg at draft}
 \AtBeginDocument{\if at svg@draft\else\ifGin at draft\@svg at drafttrue\fi\fi}
-\newcommand*\svg at quotes@remove[1]{%
+\newcommand*\svg at deactivate@dq{}
+\AfterPackage*{babel}{%
+  \renewcommand*\svg at deactivate@dq{\bbl at deactivate{"}}%
+}
+\newcommand*\svg at sanitize@dq[2]{%
   \begingroup%
-    \edef\svg at tempa{#1}%
+    \svg at deactivate@dq%
+    \edef\svg at tempa{\endgroup\def\noexpand#1{#2}}%
+  \svg at tempa%
+}
+\newcommand*\svg at quotes@remove[2][]{%
+  \begingroup%
+    \IfArgIsEmpty{#1}{\def\svg at tempb{#2}}{\def\svg at tempb{#1}}%
+    \svg at sanitize@dq\svg at tempa{\svg at tempb}%
+    \expandafter\svg at quotes@check\expandafter{\svg at tempa}%
     \expandafter\svg at quotes@@remove\svg at tempa""\@nil%
     \edef\svg at tempb{%
       \endgroup%
-      \noexpand\def\noexpand#1{\unexpanded\expandafter{\svg at tempa}}%
+      \def\noexpand#2{\svg at tempa}%
+      \if at svg@quotes at found%
+        \noexpand\@svg at quotes@foundtrue%
+      \else%
+        \noexpand\@svg at quotes@foundfalse%
+      \fi%
     }%
   \svg at tempb%
 }
@@ -383,29 +424,37 @@
 \def\svg at quotes@@check#1"#2\@nil{%
   \IfArgIsEmpty{#2}{\@svg at quotes@foundfalse}{\@svg at quotes@foundtrue}%
 }
+\newcommand*\svg at remove@leadingchar[2]{%
+  \begingroup%
+    \svg at sanitize@dq\svg at tempa{#2}%
+    \def\svg at tempb{%
+      \def\svg at tempa####1\@nil{\def\svg at tempa{####1}}%
+      \kernel at ifnextchar#1%
+        {\expandafter\svg at tempa\@gobble}%
+        {\svg at tempa}%
+    }%
+    \expandafter\svg at tempb\svg at tempa\@nil%
+    \edef\svg at tempb{%
+      \endgroup%
+      \def\noexpand#2{\svg at tempa}%
+    }%
+  \svg at tempb%
+}
 \newcommand*\svg at set@input at path[1][]{%
   \begingroup%
+    \svg at deactivate@dq%
     \ifx\svg at file@path\@empty\else%
+      \svg at normalize@path{\svg at file@path}%
       \edef\svg at file@path{{\svg at file@path}}%
     \fi%
     \svg at append@input at path{\svg at file@path}{\svg at input@path}%
     \svg at append@input at path{\svg at file@path}{\Ginput at path}%
-    \svg at append@input at path{\svg at file@path}{{#1}}%
+    \IfArgIsEmpty{#1}{}{\svg at append@input at path{\svg at file@path}{{#1}}}%
     \svg at append@input at path{\svg at file@path}{\input at path}%
-    \def\svg at tempb{}%
-    \expandafter\@tfor\expandafter\svg at tempa\expandafter:\expandafter=%
-        \svg at file@path\do{%
-      \ifx\svg at tempa\@empty\else%
-        \svg at normalize@path{\svg at tempa}%
-        \edef\svg at tempb{%
-          \unexpanded\expandafter{\svg at tempb}{\svg at tempa}%
-        }%
-      \fi%
-    }%
     \edef\svg at tempa{%
       \endgroup%
-      \ifx\svg at tempb\@empty\else%
-        \noexpand\def\noexpand\input at path{\unexpanded\expandafter{\svg at tempb}}%
+      \ifx\svg at file@path\@empty\else%
+        \def\noexpand\input at path{\svg at file@path}%
       \fi%
     }%
   \svg at tempa%
@@ -412,14 +461,29 @@
 }
 \newcommand*\svg at append@input at path[2]{%
   \ifx#2\@undefined\else%
-    \edef#1{\unexpanded\expandafter{#1}#2}%
+    \edef\svg at tempb{#2}%
+    \expandafter\@tfor\expandafter\svg at tempa\expandafter:\expandafter=%
+        \svg at tempb\do{%
+      \ifx\svg at tempa\@empty\else%
+        \@svg at tempswatrue%
+        \svg at normalize@path{\svg at tempa}%
+        \expandafter\@tfor\expandafter\svg at tempb\expandafter:\expandafter=%
+            #1\do{%
+          \ifx\svg at tempa\svg at tempb%
+            \@svg at tempswafalse%
+            \@break at tfor%
+          \fi%
+        }%
+        \if at svg@tempswa%
+          \edef#1{#1{\svg at tempa}}%
+        \fi%
+      \fi%
+    }%
   \fi%
 }
 \newcommand*\svg at normalize@path[1]{%
   \begingroup%
-    \edef\svg at tempa{#1}%
-    \svg at quotes@check{\svg at tempa}%
-    \svg at quotes@remove{\svg at tempa}%
+    \svg at quotes@remove[{#1}]{\svg at tempa}%
     \ifx\svg at tempa\@empty\relax%
       \def\svg at tempa{./}%
     \fi%
@@ -427,9 +491,9 @@
     \edef\svg at tempb{%
       \endgroup%
       \if at svg@quotes at found%
-        \noexpand\def\noexpand#1{"\unexpanded\expandafter{\svg at tempa}"}%
+        \def\noexpand#1{"\svg at tempa"}%
       \else%
-        \noexpand\def\noexpand#1{\unexpanded\expandafter{\svg at tempa}}%
+        \def\noexpand#1{\svg at tempa}%
       \fi%
     }%
   \svg at tempb%
@@ -440,7 +504,7 @@
     \IfArgIsEmpty{#1}{\def\svg at tempa{}}{\def\svg at tempa{#1/}}%
   }{%
     \svg at normalize@@path#2/\@nil%
-    \edef\svg at tempa{#1/\unexpanded\expandafter{\svg at tempa}}%
+    \edef\svg at tempa{#1/\svg at tempa}%
   }%
 }
 \newcommand*\svg at ifvalueisrelax[1]{%
@@ -515,6 +579,8 @@
 \svg at dummy@key{name}
 \svg at dummy@key{extractwidth}
 \svg at dummy@key{extractheight}
+\svg at dummy@key{extractdistort}
+\svg at dummy@key{extractkeepaspectratio}
 \svg at dummy@key{extractscale}
 \svg at dummy@key{extractpretex}
 \svg at dummy@key{extractapptex}
@@ -523,8 +589,9 @@
 \svg at dummy@key[true]{clear}
 \svg at dummy@key[true]{exclude}
 \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%
 }
 \FamilyProcessOptions{SVG}
 \newif\if at svg@file at found
@@ -534,94 +601,112 @@
 \newcommand*\svg at file@suffix{}
 \newcommand*\svg at get@path[3][\svg at file@ext]{%
   \begingroup%
-    \edef\svg at tempa{#2}%
-    \svg at quotes@check{\svg at tempa}%
-    \svg at quotes@remove{\svg at tempa}%
-    \expandafter\svg at filename@parse\expandafter{\svg at tempa}%
+    \svg at filename@parse[{#1}]{#2}%
     \IfArgIsEmpty{#1}{%
       \edef\svg at tempa{\filename at area\filename at base.\filename at ext}%
     }{%
       \edef\svg at tempa{\filename at area\filename at base.#1}%
     }%
-    \if at svg@quotes at found%
-      \edef\svg at tempa{"\svg at tempa"}%
-    \fi%
-    \svg at set@input at path[#3]%
+    \svg at set@input at path[{#3}]%
     \@svg at tempswafalse%
     \expandafter\IfFileExists\expandafter{\svg at tempa}{%
       \@svg at tempswatrue%
-      \expandafter\svg at filename@parse\expandafter{\@filef at und}%
+      \edef\@filef at und{\expandafter\trim at spaces\expandafter{\@filef at und}}%
+      \svg at filename@parse[{#1}]{\@filef at und}%
     }{}%
     \edef\svg at tempa{%
       \endgroup%
       \if at svg@tempswa%
         \noexpand\@svg at file@foundtrue%
-        \noexpand\def\noexpand\svg at file@path{\filename at area}%
-        \noexpand\def\noexpand\svg at file@name{\filename at base}%
-        \noexpand\def\noexpand\svg at file@base{\filename at area\filename at base}%
+        \def\noexpand\svg at file@path{\filename at area}%
+        \def\noexpand\svg at file@name{\filename at base}%
+        \def\noexpand\svg at file@base{\filename at area\filename at base}%
       \else%
         \noexpand\@svg at file@foundfalse%
-        \noexpand\def\noexpand\svg at file@path{}%
-        \noexpand\def\noexpand\svg at file@name{#2}%
-        \noexpand\def\noexpand\svg at file@base{#2}%
+        \def\noexpand\svg at file@path{}%
+        \def\noexpand\svg at file@name{#2}%
+        \def\noexpand\svg at file@base{#2}%
       \fi%
     }%
   \svg at tempa%
 }
-\newcommand*\svg at filename@parse[1]{%
+\newcommand*\svg at filename@parse[2][]{%
   \begingroup%
-    \def\svg at tempa##1{%
-      \def\svg at tempb####1####2\@nil{%
-        \ifstr{####1}{"}{\def\svg at tempb{####2}}{\def\svg at tempb{####1####2}}%
-      }%
-      \expandafter\svg at tempb##1\@nil%
-      \edef##1{\svg at tempb}%
-    }%
-    \filename at parse{#1}%
-    \ifx\filename at ext\relax\else%
-      \edef\filename at base{\filename at base.\filename at ext}%
-    \fi%
-    \svg at quotes@check{\filename at area}%
+    \svg at sanitize@dq\svg at tempa{#2}%
+    \expandafter\filename at parse\expandafter{\svg at tempa}%
+    \svg at quotes@remove{\filename at area}%
     \if at svg@quotes at found%
-      \svg at quotes@remove{\filename at area}%
       \edef\filename at area{"\filename at area"}%
-      \svg at tempa{\filename at base}%
+      \svg at remove@leadingchar"\filename at base%
     \fi%
-    \svg at quotes@check{\filename at base}%
-    \if at svg@quotes at found%
-      \svg at quotes@remove{\filename at base}%
+    \ifx\filename at ext\relax\else%
+      \svg at quotes@remove{\filename at ext}%
+      \svg at extension@parse{#1}%
+      \if at svg@quotes at found%
+        \edef\filename at base{\filename at base"}%
+      \fi%
     \fi%
-    \let\svg at tempa\filename at area%
-    \expandafter\filename at parse\expandafter{\filename at base}%
-    \let\filename at area\svg at tempa%
+    \svg at quotes@remove{\filename at base}%
     \if at svg@quotes at found%
-       \edef\filename at base{"\filename at base"}%
+      \edef\filename at base{"\filename at base"}%
     \fi%
     \edef\svg at tempa{%
-      \noexpand\endgroup%
-      \noexpand\def\noexpand\filename at area{\filename at area}%
-      \noexpand\def\noexpand\filename at base{\filename at base}%
+      \endgroup%
+      \def\noexpand\filename at area{\filename at area}%
+      \def\noexpand\filename at base{\filename at base}%
       \ifx\filename at ext\relax%
-        \noexpand\let\noexpand\filename at ext\noexpand\relax%
+        \let\noexpand\filename at ext\noexpand\relax%
       \else%
-        \noexpand\def\noexpand\filename at ext{\filename at ext}%
+        \def\noexpand\filename at ext{\filename at ext}%
       \fi%
     }%
   \svg at tempa%
 }
+\newcommand*\svg at extension@parse[1]{%
+  \IfArgIsEmpty{#1}{}{%
+    \ifstr{#1}{\filename at ext}{}{%
+      \begingroup%
+        \edef\svg at tempa{%
+          \def\noexpand\svg at tempa{}%
+          \let\noexpand\svg at tempb\relax%
+          \noexpand\svg at extension@@parse%
+            \filename at ext.\noexpand\@nil#1\noexpand\@nil%
+        }%
+        \svg at tempa%
+        \edef\svg at tempa{%
+          \endgroup%
+          \def\noexpand\filename at base{\filename at base\svg at tempa}%
+          \ifx\svg at tempb\relax%
+            \let\noexpand\filename at ext\relax%
+          \else%
+            \def\noexpand\filename at ext{\svg at tempb}%
+          \fi%
+        }%
+      \svg at tempa%
+    }%
+  }%
+}
+\newcommand*\svg at extension@@parse{}
+\def\svg at extension@@parse#1.#2\@nil#3\@nil{%
+  \edef\svg at tempa{\svg at tempa.#1}%
+  \IfArgIsEmpty{#2}{}{%
+    \ifstr{#2}{#3.}{%
+      \edef\svg at tempb{#3}%
+    }{%
+      \svg at extension@@parse#2\@nil#3\@nil%
+    }%
+  }%
+}
 \newcommand*\svg at file@missing[3][]{%
   \begingroup%
-    \edef\svg at tempa{#2}%
-    \expandafter\svg at filename@parse\expandafter{\svg at tempa}%
-    \svg at quotes@remove{\filename at area}%
-    \svg at quotes@remove{\filename at base}%
-    \ifx\filename at ext\relax\else%
-      \svg at quotes@remove{\filename at ext}%
-    \fi%
+    \svg at quotes@remove[{#2}]{\svg at tempa}%
+    \svg at filename@parse[{#1}]{\svg at tempa}%
     \IfArgIsEmpty{#1}{%
+      \svg at quotes@remove[{#3}]{\svg at tempb}%
       \def\svg at tempa{%
         Did you run the export with Inkscape? There's no file\MessageBreak%
-        `\filename at area\filename at base.\filename at ext'%
+        `\filename at area\filename at base.\filename at ext'\MessageBreak%
+        although `\svg at tempb' was found.%
       }%
     }{%
       \edef\filename at ext{#1}%
@@ -636,7 +721,7 @@
       \ifx\input at path\@undefined%
         \def\svg at tempb{No additional path was given.}%
       \else%
-        \def\svg at tempb{Following folders have been searched:}%
+        \def\svg at tempb{Following folders have additionally been searched:}%
         \expandafter\@tfor\expandafter\svg at tempa\expandafter:\expandafter=%
             \input at path\do{%
           \edef\svg at tempb{\svg at tempb\noexpand\MessageBreak\svg at tempa}%
@@ -677,6 +762,13 @@
   \svg at local@param at use%
   \FamilyOptions{SVG}{#1}%
   \ifstr{\svg at ink@format}{png}{\FamilyOptions{SVG}{inkscapelatex=false}}{}%
+  \@svg at tempswafalse%
+  \ifdim\svg at param@width>\z@\relax\ifdim\svg at param@height>\z@\relax%
+    \@svg at tempswatrue%
+  \fi\fi%
+  \if at svg@tempswa\else%
+    \FamilyOptions{SVG}{distort=false}%
+  \fi%
 }
 \newcommand*\svg at local@param at use{}
 \newcommand*\svg at local@param at def[1]{%
@@ -690,9 +782,16 @@
 \newcommand*\svg at input@path{}
 \let\svg at input@path\input at path
 \newcommand*\svgpath[1]{%
-  \def\svg at input@path{#1}%
+  \def\svg at tempa##1\@nil{%
+    \ifx\svg at tempb\bgroup%
+      \def\svg at input@path{#1}%
+    \else%
+      \def\svg at input@path{{#1}}%
+    \fi%
+  }%
+  \futurelet\svg at tempb\svg at tempa#1\@nil%
 }
-\newcommand*{\includesvg}[2][]{%
+\newcommand*\includesvg[2][]{%
   \begingroup%
     \svg at deprecated@param%
     \svg at local@param at set{#1}%
@@ -707,12 +806,12 @@
       \svg at ink@run%
       \IfFileExists{\svg at out@base}{}{%
         \@svg at file@foundfalse%
-        \svg at file@missing{\svg at out@base}{}%
+        \svg at file@missing{\svg at out@base}{\svg at file@base.\svg at file@ext}%
       }%
       \if at svg@ink at latex%
         \IfFileExists{\svg at out@base_tex}{}{%
           \@svg at file@foundfalse%
-          \svg at file@missing{\svg at out@base_tex}{}%
+          \svg at file@missing{\svg at out@base_tex}{\svg at file@base.\svg at file@ext}%
         }%
       \fi%
       \if at svg@file at found%
@@ -730,8 +829,10 @@
 \newcommand*\svg at param@angle{0}
 \svg at local@param at def{%
   \DefineFamilyKey[.param]{SVG}{angle}{%
-    \renewcommand*\svg at param@angle{#1}%
-    \FamilyKeyStateProcessed%
+    \ifisdimension{#1\p@}{%
+      \renewcommand*\svg at param@angle{#1}%
+      \FamilyKeyStateProcessed%
+    }{}%
   }%
 }
 \newcommand*\svg at param@origin{c}
@@ -741,32 +842,49 @@
     \FamilyKeyStateProcessed%
   }%
 }
-\newcommand*{\includeinkscape}[2][]{%
+\newcommand*\includeinkscape[2][]{%
   \begingroup%
     \svg at deprecated@param%
-    \filename at parse{#2}%
+    \svg at filename@parse{#2}%
     \ifx\filename at ext\relax\else%
       \svg at quotes@remove{\filename at ext}%
       \expandafter\lowercase\expandafter{%
         \expandafter\def\expandafter\filename at ext\expandafter{\filename at ext}%
       }%
-      \let\svg at tempb\filename at ext%
-      \def\svg at tempa##1_tex##2\@nil{\def\svg at tempb{##1}}%
-      \expandafter\svg at tempa\svg at tempb_tex\@nil%
-      \@for\svg at tempa:={pdf,eps,ps,png}\do{%
-        \ifstr{\svg at tempb}{\svg at tempa}{%
-          \edef\svg at tempa{%
-            \noexpand\FamilyOptions{SVG}{inkscapeformat=\svg at tempb}%
-          }%
-          \svg at tempa%
-        }{}%
+      \def\svg at tempb##1_tex##2\@nil{%
+        \IfArgIsEmpty{##1}{}{\def\filename at ext{##1}}%
+        \ifstr{##2}{_tex}{\@svg at tempswatrue}{\@svg at tempswafalse}%
       }%
-      \ifstr{\filename at ext}{\svg at ink@format_tex}{%
-        \FamilyOptions{SVG}{inkscapelatex=true}%
-      }{}%
+      \@svg at tempswafalse%
+      \@tfor\svg at tempa:={pdf}{eps}{ps}{png}\do{%
+        \begingroup%
+          \expandafter\svg at tempb\filename at ext_tex\@nil%
+          \svg at extension@parse{\svg at tempa}%
+          \ifx\filename at ext\relax%
+            \def\svg at tempb{\endgroup}%
+          \else%
+            \edef\svg at tempb{%
+              \endgroup%
+              \noexpand\FamilyOptions{SVG}{inkscapeformat=\svg at tempa}%
+              \if at svg@tempswa%
+                \noexpand\FamilyOptions{SVG}{inkscapelatex=true}%
+              \fi%
+              \def\noexpand\filename at base{\filename at base}%
+              \def\noexpand\filename at ext{\filename at ext}%
+              \noexpand\@svg at tempswatrue%
+            }%
+          \fi%
+        \svg at tempb%
+        \if at svg@tempswa%
+          \@break at tfor%
+        \fi%
+      }%
+      \if at svg@tempswa\else%
+        \svg at extension@parse{\svg at ink@format}%
+      \fi%
     \fi%
     \svg at local@param at set{#1}%
-    \expandafter\svg at get@path\expandafter[\svg at ink@format]{#2}{\svg at out@path}%
+    \svg at get@path[\svg at ink@format]{\filename at area\filename at base}{\svg at out@path}%
     \if at svg@file at found%
       \edef\svg at out@name{\svg at file@name}%
       \edef\svg at out@base{\svg at file@path\svg at file@name.\svg at ink@format}%
@@ -773,7 +891,7 @@
       \if at svg@ink at latex%
         \IfFileExists{\svg at out@base_tex}{}{%
           \@svg at file@foundfalse%
-          \svg at file@missing{\svg at out@base_tex}{}%
+          \svg at file@missing{\svg at out@base_tex}{\svg at out@base}%
         }%
       \fi%
       \if at svg@file at found%
@@ -821,8 +939,7 @@
             \ifnum\pdf at shellescape=\@ne\relax\if at svg@ink at run%
               \svg at iffilenewer{\svg at out@base_tex}{\svg at out@base}{%
                 \@svg at ink@runfalse%
-                \edef\svg at tempa{\svg at out@base}%
-                \svg at quotes@remove{\svg at tempa}%
+                \svg at quotes@remove[\svg at out@base]{\svg at tempa}%
                 \PackageWarning{svg}{%
                   Since the encountered filedate of file\MessageBreak%
                   `\svg at tempa_tex' is newer than \MessageBreak%
@@ -851,10 +968,8 @@
               \space with added options `\svg at ink@opt'%
             \fi%
           }%
-          \edef\svg at tempa{\svg at file@base}%
-          \edef\svg at tempb{\svg at out@name}%
-          \svg at quotes@remove{\svg at tempa}%
-          \svg at quotes@remove{\svg at tempb}%
+          \svg at quotes@remove[\svg at file@base]{\svg at tempa}%
+          \svg at quotes@remove[\svg at out@name]{\svg at tempb}%
           \ShellEscape{\svg at ink@cmd{\svg at tempa}{\svg at tempb}}%
           \IfFileExists{\svg at out@name.\svg at ink@format}{%
             \edef\svg at tempb{\svg at tempb.\svg at ink@format}%
@@ -874,8 +989,7 @@
             }%
           }%
         \else%
-          \edef\svg at tempa{\svg at file@base}%
-          \svg at quotes@remove{\svg at tempa}%
+          \svg at quotes@remove[\svg at file@base]{\svg at tempa}%
           \PackageWarning{svg}{%
             You didn't enable `shell escape' (or `write18')\MessageBreak%
             so it wasn't possible to launch the Inkscape export\MessageBreak%
@@ -922,7 +1036,7 @@
         \PackageInfo{svg}{Last page of `#1' is \the\@tempcnta}%
       \fi%
       \edef\svg at tempa{%
-        \noexpand\endgroup%
+        \endgroup%
         \noexpand\FamilyOptions{SVG}{lastpage=\the\@tempcnta}%
       }%
     \svg at tempa%
@@ -952,32 +1066,57 @@
   \if at svg@draft%
     \@svg at ink@latexfalse%
   \fi%
-  \edef\svg at tempa{#2}%
+  \def\svg at tempb##1.##2\@nil{%
+    \IfArgIsEmpty{##2}{%
+      \def\svg at tempb{##1}%
+    }{%
+      \edef\svg at tempa{\svg at tempa.##1}%
+      \svg at tempb##2\@nil%
+    }%
+  }%
+  \edef\svg at tempa{%
+    \def\noexpand\svg at tempa{}%
+    \noexpand\svg at tempb#2.\noexpand\@nil%
+  }%
+  \svg at tempa%
+  \svg at remove@leadingchar.\svg at tempa%
+  \edef\svg at tempa{{\svg at tempa}.\svg at tempb}%
+  \edef\svg at tempb{#2}%
   \if at svg@ink at latex%
     \svg at patches{\svg at tempa}%
     \ifnum\value{svg at param@lastpage}=\z@\relax%
-      \expandafter\svg at get@lastpage\expandafter{\svg at tempa}%
+      \expandafter\svg at get@lastpage\expandafter{\svg at tempb}%
     \fi%
     \edef\svg at tempa{%
       \ifx\svg at param@pretex\relax\else%
         \noexpand\svg at param@pretex%
       \fi%
-      \noexpand\input{\svg at tempa_tex}%
+      \noexpand\input{\svg at tempb_tex}%
       \ifx\svg at param@apptex\relax\else%
         \noexpand\svg at param@apptex%
       \fi%
     }%
+    \if at svg@param at distort%
+      \def\svg at tempb{\resizebox*{\svg at param@width}{\svg at param@height}}%
+    \else%
+      \let\svg at tempb\@firstofone%
+    \fi%
+    \sbox\svg at box{\svg at tempb{\svg at tempa}}%
     \ifdim\dimexpr\svg at param@angle\p@\relax=\z@\relax%
-      \svg at tempa%
+      \let\svg at tempb\@firstofone%
     \else%
-      \edef\svg at tempb{origin=\svg at param@origin}%
-      \expandafter\rotatebox\expandafter[\svg at tempb]{\svg at param@angle}{%
-        \svg at tempa%
+      \edef\svg at tempb{%
+        \noexpand\rotatebox[origin=\svg at param@origin]{\svg at param@angle}%
       }%
     \fi%
+    \svg at tempb{\usebox\svg at box}%
   \else%
     \svg at wrn@scale%
-    \edef\svg at tempb{keepaspectratio,scale=\svg at param@scale}%
+    \edef\svg at tempb{%
+      draft\if at svg@draft\else=false\fi,%
+      scale=\svg at param@scale,%
+      keepaspectratio\if at svg@param at distort=false\fi%
+    }%
     \ifdim\svg at param@height>\z@\relax%
       \edef\svg at tempb{\svg at tempb,height=\svg at param@height}%
     \fi%
@@ -989,11 +1128,6 @@
         \svg at tempb,origin=\svg at param@origin,angle=\svg at param@angle%
       }%
     \fi%
-    \if at svg@draft%
-      \edef\svg at tempb{\svg at tempb,draft}%
-    \else%
-      \edef\svg at tempb{\svg at tempb,draft=false}%
-    \fi%
     \expandafter\includegraphics\expandafter[\svg at tempb]{\svg at tempa}%
   \fi%
 }
@@ -1077,8 +1211,7 @@
 \fi
 \newcommand*\svg at shell@mkdir[1]{%
   \begingroup%
-    \edef\svg at tempa{#1}%
-    \svg at quotes@remove{\svg at tempa}%
+    \svg at quotes@remove[{#1}]{\svg at tempa}%
     \@svg at tempswatrue%
     \ifstr{\svg at tempa}{}{\@svg at tempswafalse}{%
     \ifstr{\svg at tempa}{./}{\@svg at tempswafalse}{%
@@ -1094,6 +1227,7 @@
 \newcommand*\svg at shell@rm[1]{%
   \ShellEscape{\svg at shell@@rm\space"#1"}%
 }
+\svg at catcodecodes@restore
 \endinput
 %%
 %% End of file `svg.sty'.



More information about the tex-live-commits mailing list