diff options
author | Karl Berry <karl@freefriends.org> | 2018-09-08 21:41:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-09-08 21:41:57 +0000 |
commit | 6a8d502f6063d1e03f46b7852876aacbdbc9658b (patch) | |
tree | 1a53b42cea7894a427d7926394740a38d4e25d67 /Master/texmf-dist/tex/latex/svg | |
parent | 80b28c052dd903d1c5c60a1faafd530bec8f5e45 (diff) |
svg (8sep18)
git-svn-id: svn://tug.org/texlive/trunk@48626 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/svg')
-rw-r--r-- | Master/texmf-dist/tex/latex/svg/svg-extract.sty | 153 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/svg/svg.sty | 434 |
2 files changed, 392 insertions, 195 deletions
diff --git a/Master/texmf-dist/tex/latex/svg/svg-extract.sty b/Master/texmf-dist/tex/latex/svg/svg-extract.sty index f7472d3a063..e4be74acca3 100644 --- a/Master/texmf-dist/tex/latex/svg/svg-extract.sty +++ b/Master/texmf-dist/tex/latex/svg/svg-extract.sty @@ -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@deprecated@key{pdf}{extractformat={\svgx@format}}% \else% - \FamilyKeyStateUnknownValue + \FamilyKeyStateUnknownValue% \fi% \fi% } @@ -94,7 +94,7 @@ }% \svg@deprecated@key{eps}{extractformat={\svgx@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@svgx@cnv@run \newcommand*\svgx@cnv@cmd{} @@ -286,7 +286,7 @@ }% \svg@deprecated@key{png}{convertformat={\svgx@cnv@format}}% \else% - \FamilyKeyStateUnknownValue + \FamilyKeyStateUnknownValue% \fi% \fi% } @@ -341,12 +341,13 @@ } \newcommand*\svgx@out@path{} \DefineFamilyKey{SVG}{extractpath}{% + \svg@sanitize@dq\svg@tempb{#1}% \FamilySetNumerical{SVG}{extractpath}{svg@tempa}{% {svgpath}{0},{svgdir}{0},% {svgsubpath}{1},{svgsubdir}{1},% {basepath}{2},{basedir}{2},{jobpath}{2},{jobdir}{2},% {basesubpath}{3},{basesubdir}{3},{jobsubpath}{3},{jobsubdir}{3}% - }{#1}% + }{\svg@tempb}% \ifx\FamilyKeyState\FamilyKeyStateProcessed% \ifcase\svg@tempa\relax% svgpath \renewcommand*\svgx@out@path{\svg@file@path}% @@ -358,7 +359,7 @@ \renewcommand*\svgx@out@path{./svg-extract/}% \fi% \else% - \renewcommand*\svgx@out@path{#1}% + \edef\svgx@out@path{\svg@tempb}% \svg@normalize@path{\svgx@out@path}% \FamilyKeyStateProcessed% \fi% @@ -370,12 +371,13 @@ \newcommand*\svgx@out@name{} \newif\if@svgx@out@sec \DefineFamilyKey{SVG}{extractname}{% + \svg@quotes@remove[{#1}]{\svg@tempb}% \FamilySetNumerical{SVG}{extractname}{svg@tempa}{% {filename}{0},{name}{0},% {filenamenumbered}{1},{namenumbered}{1},% {numberedfilename}{1},{numberedname}{1},% {numbered}{2},{section}{2},{numberedsection}{2},{sectionnumbered}{2}% - }{#1}% + }{\svg@tempb}% \@svgx@out@secfalse% \ifx\FamilyKeyState\FamilyKeyStateProcessed% \ifcase\svg@tempa\relax% filename @@ -387,10 +389,11 @@ \@svgx@out@sectrue% \fi% \else% - \def\svg@tempa##1.##2\@nil{% - \IfArgIsEmpty{##1}{}{\renewcommand*\svgx@out@name{##1}}% - }% - \svg@tempa#1.\@nil% + \if@svg@quotes@found% + \edef\svgx@out@name{"\svg@tempb"}% + \else% + \edef\svgx@out@name{\svg@tempb}% + \fi% \FamilyKeyStateProcessed% \fi% } @@ -409,8 +412,10 @@ \FamilyKeyStateProcessed% }{% \FamilySetLengthMacro{SVG}{extractwidth}{\svgx@param@width}{#1}% - \ifdim\svgx@param@width<\z@\relax% - \FamilyKeyStateUnknownValue% + \ifx\FamilyKeyState\FamilyKeyStateProcessed% + \ifdim\svgx@param@width<\z@\relax% + \FamilyKeyStateUnknownValue% + \fi% \fi% }% }% @@ -427,12 +432,41 @@ \FamilyKeyStateProcessed% }{% \FamilySetLengthMacro{SVG}{extractheight}{\svgx@param@height}{#1}% - \ifdim\svgx@param@height<\z@\relax% - \FamilyKeyStateUnknownValue% + \ifx\FamilyKeyState\FamilyKeyStateProcessed% + \ifdim\svgx@param@height<\z@\relax% + \FamilyKeyStateUnknownValue% + \fi% \fi% }% }% } +\newif\if@svgx@param@distort +\DefineFamilyKey{SVG}{extractdistort}[true]{% + \FamilyKeyStateUnknownValue% + \svg@ifvalueisrelax{#1}{% + \@svgx@param@distortfalse% + \FamilyKeyStateProcessed% + }{% + \ifstr{#1}{inherit}{% + \renewcommand*\if@svgx@param@distort{\if@svg@param@distort}% + \FamilyKeyStateProcessed% + }{% + \FamilySetBool{SVG}{extractdistort}{@svgx@param@distort}{#1}% + }% + }% +} +\DefineFamilyKey{SVG}{extractkeepaspectratio}[true]{% + \FamilySetBool{SVG}{extractkeepaspectratio}{@svg@tempswa}{#1}% + \ifx\FamilyKeyState\FamilyKeyStateProcessed% + \if@svg@tempswa% + \FamilyOptions{SVG}{extractdistort=false}% + \else + \FamilyOptions{SVG}{extractdistort=true}% + \fi% + \else% + \FamilyOptions{SVG}{extractdistort=#1}% + \fi% +} \newcommand*\svgx@param@scale{\svg@param@scale} \DefineFamilyKey{SVG}{extractscale}{% \FamilyKeyStateUnknownValue% @@ -459,9 +493,9 @@ \let\svgx@param@pretex\relax% }{% \ifstr{#1}{inherit}{% - \def\svgx@param@pretex{\svg@param@pretex}% + \renewcommand*\svgx@param@pretex{\svg@param@pretex}% }{% - \def\svgx@param@pretex{#1}% + \renewcommand*\svgx@param@pretex{#1}% }% }% \FamilyKeyStateProcessed% @@ -472,9 +506,9 @@ \let\svgx@param@apptex\relax% }{% \ifstr{#1}{inherit}{% - \def\svgx@param@apptex{\svg@param@apptex}% + \renewcommand*\svgx@param@apptex{\svg@param@apptex}% }{% - \def\svgx@param@apptex{#1}% + \renewcommand*\svgx@param@apptex{#1}% }% }% \FamilyKeyStateProcessed% @@ -569,11 +603,11 @@ \fi% }% \edef\svg@tempb{% - \noexpand\endgroup% + \endgroup% \ifx\svg@tempa\relax% - \noexpand\let\noexpand\svg@tempa\noexpand\relax% + \let\noexpand\svg@tempa\noexpand\relax% \else% - \noexpand\def\noexpand\svg@tempa{\svg@tempa}% + \def\noexpand\svg@tempa{\svg@tempa}% \fi% }% \svg@tempb% @@ -611,21 +645,23 @@ \fi% }% } -\newcommand*\svgxdelayed[1]{ +\newif\if@svgx@standalone +\newcommand*\svgxsetbox[2][]{% + \@svgx@standalonetrue% + \svgx@setbox{#1}{#2}% \scr@ifundefinedorrelax{AtEndPreamble}{% - \AtBeginDocument{#1}% + \let\svg@tempa\@firstofone% }{% - \AtEndPreamble{\AtBeginDocument{#1}}% + \def\svg@tempa{\AtEndPreamble}% }% + \svg@tempa{\AtBeginDocument{\svgx@setbox{#1}{#2}}}% } -\newbox\svgx@box -\newcommand*\svgxsetbox[2][]{% - \csname @tud@x@standalone@croptrue\endcsname% - \sbox\svgx@box{\svg@@input[{#1},draft=false]{#2}}% +\newcommand*\svgx@setbox[2]{% + \sbox\svg@box{\svg@@input[{#1},draft=false]{#2}}% \svgxsetpapersize% } \newcommand*\svgxsetpapersize{% - \setlength\paperwidth{\the\wd\svgx@box}% + \setlength\paperwidth{\the\wd\svg@box}% \scr@ifundefinedorrelax{stockwidth}{}{% \setlength\stockwidth{\paperwidth}% }% @@ -633,7 +669,7 @@ \setlength\mediawidth{\paperwidth}% }% \setlength\textwidth{\paperwidth}% - \setlength\paperheight{\the\dimexpr\ht\svgx@box+\dp\svgx@box\relax}% + \setlength\paperheight{\the\dimexpr\ht\svg@box+\dp\svg@box\relax}% \scr@ifundefinedorrelax{stockheight}{}{% \setlength\stockheight{\paperheight}% }% @@ -665,22 +701,44 @@ \if@svgx@beamer% \setbeamertemplate{navigation symbols}{}% \begin{frame}[plain]% - \usebox\svgx@box% + \usebox\svg@box% \end{frame}% \else% - \usebox\svgx@box% + \usebox\svg@box% \fi% \endgraf% \endgroup% } \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},% gsdevice={eps=eps2write},gsdevice={ps=ps2write}% } \FamilyProcessOptions{SVG} +\DefineFamilyMember[.param]{SVG} +\newcommand*\svgx@param@angle{0} +\svg@local@param@def{% + \DefineFamilyKey[.param]{SVG}{extractangle}{% + \FamilyKeyStateUnknownValue% + \svg@ifvalueisrelax{#1}{% + \renewcommand*\svgx@param@angle{0}% + \FamilyKeyStateProcessed% + }{% + \ifstr{#1}{inherit}{% + \renewcommand*\svgx@param@angle{\svg@param@angle}% + \FamilyKeyStateProcessed% + }{% + \ifisdimension{#1\p@}{% + \renewcommand*\svgx@param@angle{#1}% + \FamilyKeyStateProcessed% + }{}% + }% + }% + }% +} \let\svghidepreamblestart\relax \let\svghidepreambleend\relax \ifnum\pdf@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@tempa'% + file `\svg@tempa'\MessageBreak% }% \endgroup% \fi% @@ -833,6 +891,9 @@ \ifdim\svgx@param@height>\z@\relax% \svg@tempa{height=\svgx@param@height}% \fi% + \if@svgx@param@distort% + \svg@tempa{distort=true}% + \fi% \ifdim\dimexpr\svgx@param@scale\p@\relax=\p@\relax\else% \svg@tempa{scale=\svgx@param@scale}% \fi% @@ -864,6 +925,11 @@ \fi% }{}% \fi% + \ifdim\dimexpr\svgx@param@angle\p@\relax=\z@\relax\else% + \edef\svg@tempa{% + angle=\svgx@param@angle\ifx\svg@tempa\@empty\else,\svg@tempa\fi% + }% + \fi% \ifx\svg@tempa\@empty% \def\svg@tempa{\string\svgxsetbox{#1}}% \else% @@ -879,9 +945,6 @@ }{}% \fi% \immediate\write\svgx@stream@out{% - \string\svgxdelayed{\@percentchar^^J% - \space\space\svg@tempa\@percentchar^^J% - }^^J^^J% \string\begin{document}^^J% \string\pagestyle{empty}^^J% \string\svgxoutputbox\@percentchar^^J% @@ -954,7 +1017,7 @@ \expandafter\svgx@ifinlist\expandafter{\svg@tempa}{\svgx@format}{% \PackageWarning{svg-extract}{% File type `\svg@tempa' was specified for option\MessageBreak% - `extractformat' (\svgx@format) as well as for \MessageBreak + `extractformat' (\svgx@format) as well as for \MessageBreak% option `convertformat' (\svgx@cnv@format) so the\MessageBreak% conversion won't be done% }% @@ -1073,8 +1136,8 @@ }% \svg@tempa#1,\@nil% \edef\svg@tempa{% - \noexpand\endgroup% - \noexpand\def\noexpand\svgx@cnv@informat{\svg@tempa}% + \endgroup% + \def\noexpand\svgx@cnv@informat{\svg@tempa}% }% \svg@tempa% \ifx\svgx@cnv@informat\@empty% @@ -1133,9 +1196,9 @@ \edef\svg@tempb{% The graphic file \svg@tempb\space failed\MessageBreak% for `#1.#2'\MessageBreak% - Troubleshooting: Please check the log file how the\MessageBreak% - invocation of the extraction took place and try\MessageBreak% - to execute it yourself in the terminal% + Troubleshooting: Please check the log file how\MessageBreak% + the invocation of the extraction took place and\MessageBreak% + try to execute it yourself in the terminal% }% \else% \def\svg@tempb{% diff --git a/Master/texmf-dist/tex/latex/svg/svg.sty b/Master/texmf-dist/tex/latex/svg/svg.sty index 0948d5dc94b..61fc51de676 100644 --- a/Master/texmf-dist/tex/latex/svg/svg.sty +++ b/Master/texmf-dist/tex/latex/svg/svg.sty @@ -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{ifxetex}[2010/09/12] -\RequirePackage{ifluatex}[2016/05/16] \RequirePackage{ifpdf}[2016/05/14] +\RequirePackage{ifluatex}[2016/05/16] +\RequirePackage{ifxetex}[2010/09/12] \RequirePackage{pdftexcmds}[2016/05/21] \RequirePackage{shellesc}[2016/06/07] +\RequirePackage{trimspaces}[2009/09/17] \RequirePackage{graphicx}[1999/02/16] +\newcommand*\svg@tempa{} +\newcommand*\svg@tempb{} +\newbox\svg@box +\newif\if@svg@tempswa +\edef\svg@catcodecodes@restore{% + \catcode`\noexpand\"\the\catcode`\"\relax% +} +\@makeother\"% \DefineFamily{SVG} \DefineFamilyMember{SVG} \newcommand*\svg@deprecated@key[3][svg]{% @@ -53,9 +62,6 @@ }% \FamilyOptions{SVG}{#3}% } -\newcommand*\svg@tempa{} -\newcommand*\svg@tempb{} -\newif\if@svg@tempswa \newif\if@svg@use@xcolor \FamilyBoolKey{SVG}{usexcolor}{@svg@use@xcolor} \DeclareOption{noxcolor}{\FamilyOptions{SVG}{usexcolor=false}} @@ -82,7 +88,7 @@ } \newcommand*\svg@ink@mode{} \DefineFamilyKey{SVG}{inkscape}[true]{% - \lowercase{\def\svg@tempa{#1}}% + \lowercase{\svg@sanitize@dq\svg@tempb{#1}}% \FamilySetNumerical{SVG}{inkscape}{svg@tempa}{% {false}{0},{off}{0},{no}{0},% {true}{1},{on}{1},{yes}{1},{onlynewer}{1},{newer}{1},% @@ -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@tempa}% + }{\svg@tempb}% \ifx\FamilyKeyState\FamilyKeyStateProcessed% \ifnum\svg@tempa<\thr@@\relax% \let\svg@ink@mode\svg@tempa% @@ -120,16 +126,23 @@ \def\svg@tempa##1dpi##2\@nil{% \ifstr{##2}{dpi}{\FamilyOptions{SVG}{inkscapedpi=##1}}{}% }% - \lowercase{\svg@tempa#1dpi\@nil}% + \lowercase{\expandafter\svg@tempa\svg@tempb dpi\@nil}% \ifx\FamilyKeyState\FamilyKeyStateProcessed\else% + \svg@quotes@remove[{#1}]{\svg@tempb}% \def\svg@tempa##1-##2\@nil{% \IfArgIsEmpty{##2}{\def\svg@tempb{}}{% - \def\svg@tempa##1####1\@nil{\def\svg@tempb{####1}}% - \svg@tempa#1\@nil% + \def\svg@tempa####1-\@nil{\def\svg@tempb{-####1}}% + \svg@tempa##2\@nil% }% - \def\svg@tempa{##1}% + \edef\svg@tempa{\trim@spaces{##1}}% + }% + \edef\svg@tempb{% + \noexpand\svg@tempa\svg@tempb-\noexpand\@nil% }% - \svg@tempa#1-\@nil% + \svg@tempb% + \if@svg@quotes@found% + \edef\svg@tempa{"\svg@tempa"}% + \fi% \PackageWarning{svg}{% Setting the executable% \ifx\svg@tempb\@empty\else% @@ -235,14 +248,8 @@ } \newcommand*\svg@file@ext{svg} \DefineFamilyKey{SVG}{svgextension}{% - \def\svg@tempa##1.##2.##3\relax{% - \IfArgIsEmpty{##1}{% - \def\svg@file@ext{##2}% - }{% - \def\svg@file@ext{##1}% - }% - }% - \lowercase{\svg@tempa#1..\relax}% + \lowercase{\svg@quotes@remove[{#1}]{\svg@file@ext}}% + \svg@remove@leadingchar.\svg@file@ext% } \DefineFamilyKey{SVG}{extension}{\FamilyOptions{SVG}{svgextension=#1}} \DefineFamilyKey{SVG}{ext}{\FamilyOptions{SVG}{svgextension=#1}} @@ -250,12 +257,13 @@ \newcommand*\svg@out@name{\svg@file@name\svg@file@suffix} \newcommand*\svg@out@base{\svg@out@path\svg@out@name.\svg@ink@format} \DefineFamilyKey{SVG}{inkscapepath}{% + \svg@sanitize@dq\svg@tempb{#1}% \FamilySetNumerical{SVG}{inkscapepath}{svg@tempa}{% {svgpath}{0},{svgdir}{0},% {svgsubpath}{1},{svgsubdir}{1},% {basepath}{2},{basedir}{2},{jobpath}{2},{jobdir}{2},% {basesubpath}{3},{basesubdir}{3},{jobsubpath}{3},{jobsubdir}{3}% - }{#1}% + }{\svg@tempb}% \ifx\FamilyKeyState\FamilyKeyStateProcessed% \ifcase\svg@tempa\relax% svgpath \renewcommand*\svg@out@path{\svg@file@path}% @@ -267,7 +275,7 @@ \renewcommand*\svg@out@path{./svg-inkscape/}% \fi% \else% - \renewcommand*\svg@out@path{#1}% + \edef\svg@out@path{\svg@tempb}% \svg@normalize@path{\svg@out@path}% \FamilyKeyStateProcessed% \fi% @@ -284,8 +292,10 @@ \FamilyKeyStateProcessed% }{% \FamilySetLengthMacro{SVG}{width}{\svg@param@width}{#1}% - \ifdim\svg@param@width<\z@\relax% - \FamilyKeyStateUnknownValue% + \ifx\FamilyKeyState\FamilyKeyStateProcessed% + \ifdim\svg@param@width<\z@\relax% + \FamilyKeyStateUnknownValue% + \fi% \fi% }% } @@ -297,11 +307,25 @@ \FamilyKeyStateProcessed% }{% \FamilySetLengthMacro{SVG}{height}{\svg@param@height}{#1}% - \ifdim\svg@param@height<\z@\relax% - \FamilyKeyStateUnknownValue% + \ifx\FamilyKeyState\FamilyKeyStateProcessed% + \ifdim\svg@param@height<\z@\relax% + \FamilyKeyStateUnknownValue% + \fi% \fi% }% } +\newif\if@svg@param@distort +\FamilyBoolKey{SVG}{distort}{@svg@param@distort} +\DefineFamilyKey{SVG}{keepaspectratio}[true]{% + \FamilySetBool{SVG}{keepaspectratio}{@svg@tempswa}{#1}% + \ifx\FamilyKeyState\FamilyKeyStateProcessed% + \if@svg@tempswa% + \FamilyOptions{SVG}{distort=false}% + \else + \FamilyOptions{SVG}{distort=true}% + \fi% + \fi% +} \newcommand*\svg@param@scale{1} \DefineFamilyKey{SVG}{scale}{% \FamilyKeyStateUnknownValue% @@ -357,13 +381,30 @@ \newif\if@svg@draft \FamilyBoolKey{SVG}{draft}{@svg@draft} \AtBeginDocument{\if@svg@draft\else\ifGin@draft\@svg@drafttrue\fi\fi} -\newcommand*\svg@quotes@remove[1]{% +\newcommand*\svg@deactivate@dq{} +\AfterPackage*{babel}{% + \renewcommand*\svg@deactivate@dq{\bbl@deactivate{"}}% +} +\newcommand*\svg@sanitize@dq[2]{% \begingroup% - \edef\svg@tempa{#1}% + \svg@deactivate@dq% + \edef\svg@tempa{\endgroup\def\noexpand#1{#2}}% + \svg@tempa% +} +\newcommand*\svg@quotes@remove[2][]{% + \begingroup% + \IfArgIsEmpty{#1}{\def\svg@tempb{#2}}{\def\svg@tempb{#1}}% + \svg@sanitize@dq\svg@tempa{\svg@tempb}% + \expandafter\svg@quotes@check\expandafter{\svg@tempa}% \expandafter\svg@quotes@@remove\svg@tempa""\@nil% \edef\svg@tempb{% \endgroup% - \noexpand\def\noexpand#1{\unexpanded\expandafter{\svg@tempa}}% + \def\noexpand#2{\svg@tempa}% + \if@svg@quotes@found% + \noexpand\@svg@quotes@foundtrue% + \else% + \noexpand\@svg@quotes@foundfalse% + \fi% }% \svg@tempb% } @@ -383,43 +424,66 @@ \def\svg@quotes@@check#1"#2\@nil{% \IfArgIsEmpty{#2}{\@svg@quotes@foundfalse}{\@svg@quotes@foundtrue}% } +\newcommand*\svg@remove@leadingchar[2]{% + \begingroup% + \svg@sanitize@dq\svg@tempa{#2}% + \def\svg@tempb{% + \def\svg@tempa####1\@nil{\def\svg@tempa{####1}}% + \kernel@ifnextchar#1% + {\expandafter\svg@tempa\@gobble}% + {\svg@tempa}% + }% + \expandafter\svg@tempb\svg@tempa\@nil% + \edef\svg@tempb{% + \endgroup% + \def\noexpand#2{\svg@tempa}% + }% + \svg@tempb% +} \newcommand*\svg@set@input@path[1][]{% \begingroup% + \svg@deactivate@dq% \ifx\svg@file@path\@empty\else% + \svg@normalize@path{\svg@file@path}% \edef\svg@file@path{{\svg@file@path}}% \fi% \svg@append@input@path{\svg@file@path}{\svg@input@path}% \svg@append@input@path{\svg@file@path}{\Ginput@path}% - \svg@append@input@path{\svg@file@path}{{#1}}% + \IfArgIsEmpty{#1}{}{\svg@append@input@path{\svg@file@path}{{#1}}}% \svg@append@input@path{\svg@file@path}{\input@path}% - \def\svg@tempb{}% - \expandafter\@tfor\expandafter\svg@tempa\expandafter:\expandafter=% - \svg@file@path\do{% - \ifx\svg@tempa\@empty\else% - \svg@normalize@path{\svg@tempa}% - \edef\svg@tempb{% - \unexpanded\expandafter{\svg@tempb}{\svg@tempa}% - }% - \fi% - }% \edef\svg@tempa{% \endgroup% - \ifx\svg@tempb\@empty\else% - \noexpand\def\noexpand\input@path{\unexpanded\expandafter{\svg@tempb}}% + \ifx\svg@file@path\@empty\else% + \def\noexpand\input@path{\svg@file@path}% \fi% }% \svg@tempa% } \newcommand*\svg@append@input@path[2]{% \ifx#2\@undefined\else% - \edef#1{\unexpanded\expandafter{#1}#2}% + \edef\svg@tempb{#2}% + \expandafter\@tfor\expandafter\svg@tempa\expandafter:\expandafter=% + \svg@tempb\do{% + \ifx\svg@tempa\@empty\else% + \@svg@tempswatrue% + \svg@normalize@path{\svg@tempa}% + \expandafter\@tfor\expandafter\svg@tempb\expandafter:\expandafter=% + #1\do{% + \ifx\svg@tempa\svg@tempb% + \@svg@tempswafalse% + \@break@tfor% + \fi% + }% + \if@svg@tempswa% + \edef#1{#1{\svg@tempa}}% + \fi% + \fi% + }% \fi% } \newcommand*\svg@normalize@path[1]{% \begingroup% - \edef\svg@tempa{#1}% - \svg@quotes@check{\svg@tempa}% - \svg@quotes@remove{\svg@tempa}% + \svg@quotes@remove[{#1}]{\svg@tempa}% \ifx\svg@tempa\@empty\relax% \def\svg@tempa{./}% \fi% @@ -427,9 +491,9 @@ \edef\svg@tempb{% \endgroup% \if@svg@quotes@found% - \noexpand\def\noexpand#1{"\unexpanded\expandafter{\svg@tempa}"}% + \def\noexpand#1{"\svg@tempa"}% \else% - \noexpand\def\noexpand#1{\unexpanded\expandafter{\svg@tempa}}% + \def\noexpand#1{\svg@tempa}% \fi% }% \svg@tempb% @@ -440,7 +504,7 @@ \IfArgIsEmpty{#1}{\def\svg@tempa{}}{\def\svg@tempa{#1/}}% }{% \svg@normalize@@path#2/\@nil% - \edef\svg@tempa{#1/\unexpanded\expandafter{\svg@tempa}}% + \edef\svg@tempa{#1/\svg@tempa}% }% } \newcommand*\svg@ifvalueisrelax[1]{% @@ -515,6 +579,8 @@ \svg@dummy@key{name} \svg@dummy@key{extractwidth} \svg@dummy@key{extractheight} +\svg@dummy@key{extractdistort} +\svg@dummy@key{extractkeepaspectratio} \svg@dummy@key{extractscale} \svg@dummy@key{extractpretex} \svg@dummy@key{extractapptex} @@ -523,8 +589,9 @@ \svg@dummy@key[true]{clear} \svg@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@svg@file@found @@ -534,94 +601,112 @@ \newcommand*\svg@file@suffix{} \newcommand*\svg@get@path[3][\svg@file@ext]{% \begingroup% - \edef\svg@tempa{#2}% - \svg@quotes@check{\svg@tempa}% - \svg@quotes@remove{\svg@tempa}% - \expandafter\svg@filename@parse\expandafter{\svg@tempa}% + \svg@filename@parse[{#1}]{#2}% \IfArgIsEmpty{#1}{% \edef\svg@tempa{\filename@area\filename@base.\filename@ext}% }{% \edef\svg@tempa{\filename@area\filename@base.#1}% }% - \if@svg@quotes@found% - \edef\svg@tempa{"\svg@tempa"}% - \fi% - \svg@set@input@path[#3]% + \svg@set@input@path[{#3}]% \@svg@tempswafalse% \expandafter\IfFileExists\expandafter{\svg@tempa}{% \@svg@tempswatrue% - \expandafter\svg@filename@parse\expandafter{\@filef@und}% + \edef\@filef@und{\expandafter\trim@spaces\expandafter{\@filef@und}}% + \svg@filename@parse[{#1}]{\@filef@und}% }{}% \edef\svg@tempa{% \endgroup% \if@svg@tempswa% \noexpand\@svg@file@foundtrue% - \noexpand\def\noexpand\svg@file@path{\filename@area}% - \noexpand\def\noexpand\svg@file@name{\filename@base}% - \noexpand\def\noexpand\svg@file@base{\filename@area\filename@base}% + \def\noexpand\svg@file@path{\filename@area}% + \def\noexpand\svg@file@name{\filename@base}% + \def\noexpand\svg@file@base{\filename@area\filename@base}% \else% \noexpand\@svg@file@foundfalse% - \noexpand\def\noexpand\svg@file@path{}% - \noexpand\def\noexpand\svg@file@name{#2}% - \noexpand\def\noexpand\svg@file@base{#2}% + \def\noexpand\svg@file@path{}% + \def\noexpand\svg@file@name{#2}% + \def\noexpand\svg@file@base{#2}% \fi% }% \svg@tempa% } -\newcommand*\svg@filename@parse[1]{% +\newcommand*\svg@filename@parse[2][]{% \begingroup% - \def\svg@tempa##1{% - \def\svg@tempb####1####2\@nil{% - \ifstr{####1}{"}{\def\svg@tempb{####2}}{\def\svg@tempb{####1####2}}% - }% - \expandafter\svg@tempb##1\@nil% - \edef##1{\svg@tempb}% - }% - \filename@parse{#1}% - \ifx\filename@ext\relax\else% - \edef\filename@base{\filename@base.\filename@ext}% - \fi% - \svg@quotes@check{\filename@area}% + \svg@sanitize@dq\svg@tempa{#2}% + \expandafter\filename@parse\expandafter{\svg@tempa}% + \svg@quotes@remove{\filename@area}% \if@svg@quotes@found% - \svg@quotes@remove{\filename@area}% \edef\filename@area{"\filename@area"}% - \svg@tempa{\filename@base}% + \svg@remove@leadingchar"\filename@base% \fi% - \svg@quotes@check{\filename@base}% - \if@svg@quotes@found% - \svg@quotes@remove{\filename@base}% + \ifx\filename@ext\relax\else% + \svg@quotes@remove{\filename@ext}% + \svg@extension@parse{#1}% + \if@svg@quotes@found% + \edef\filename@base{\filename@base"}% + \fi% \fi% - \let\svg@tempa\filename@area% - \expandafter\filename@parse\expandafter{\filename@base}% - \let\filename@area\svg@tempa% + \svg@quotes@remove{\filename@base}% \if@svg@quotes@found% - \edef\filename@base{"\filename@base"}% + \edef\filename@base{"\filename@base"}% \fi% \edef\svg@tempa{% - \noexpand\endgroup% - \noexpand\def\noexpand\filename@area{\filename@area}% - \noexpand\def\noexpand\filename@base{\filename@base}% + \endgroup% + \def\noexpand\filename@area{\filename@area}% + \def\noexpand\filename@base{\filename@base}% \ifx\filename@ext\relax% - \noexpand\let\noexpand\filename@ext\noexpand\relax% + \let\noexpand\filename@ext\noexpand\relax% \else% - \noexpand\def\noexpand\filename@ext{\filename@ext}% + \def\noexpand\filename@ext{\filename@ext}% \fi% }% \svg@tempa% } +\newcommand*\svg@extension@parse[1]{% + \IfArgIsEmpty{#1}{}{% + \ifstr{#1}{\filename@ext}{}{% + \begingroup% + \edef\svg@tempa{% + \def\noexpand\svg@tempa{}% + \let\noexpand\svg@tempb\relax% + \noexpand\svg@extension@@parse% + \filename@ext.\noexpand\@nil#1\noexpand\@nil% + }% + \svg@tempa% + \edef\svg@tempa{% + \endgroup% + \def\noexpand\filename@base{\filename@base\svg@tempa}% + \ifx\svg@tempb\relax% + \let\noexpand\filename@ext\relax% + \else% + \def\noexpand\filename@ext{\svg@tempb}% + \fi% + }% + \svg@tempa% + }% + }% +} +\newcommand*\svg@extension@@parse{} +\def\svg@extension@@parse#1.#2\@nil#3\@nil{% + \edef\svg@tempa{\svg@tempa.#1}% + \IfArgIsEmpty{#2}{}{% + \ifstr{#2}{#3.}{% + \edef\svg@tempb{#3}% + }{% + \svg@extension@@parse#2\@nil#3\@nil% + }% + }% +} \newcommand*\svg@file@missing[3][]{% \begingroup% - \edef\svg@tempa{#2}% - \expandafter\svg@filename@parse\expandafter{\svg@tempa}% - \svg@quotes@remove{\filename@area}% - \svg@quotes@remove{\filename@base}% - \ifx\filename@ext\relax\else% - \svg@quotes@remove{\filename@ext}% - \fi% + \svg@quotes@remove[{#2}]{\svg@tempa}% + \svg@filename@parse[{#1}]{\svg@tempa}% \IfArgIsEmpty{#1}{% + \svg@quotes@remove[{#3}]{\svg@tempb}% \def\svg@tempa{% Did you run the export with Inkscape? There's no file\MessageBreak% - `\filename@area\filename@base.\filename@ext'% + `\filename@area\filename@base.\filename@ext'\MessageBreak% + although `\svg@tempb' was found.% }% }{% \edef\filename@ext{#1}% @@ -636,7 +721,7 @@ \ifx\input@path\@undefined% \def\svg@tempb{No additional path was given.}% \else% - \def\svg@tempb{Following folders have been searched:}% + \def\svg@tempb{Following folders have additionally been searched:}% \expandafter\@tfor\expandafter\svg@tempa\expandafter:\expandafter=% \input@path\do{% \edef\svg@tempb{\svg@tempb\noexpand\MessageBreak\svg@tempa}% @@ -677,6 +762,13 @@ \svg@local@param@use% \FamilyOptions{SVG}{#1}% \ifstr{\svg@ink@format}{png}{\FamilyOptions{SVG}{inkscapelatex=false}}{}% + \@svg@tempswafalse% + \ifdim\svg@param@width>\z@\relax\ifdim\svg@param@height>\z@\relax% + \@svg@tempswatrue% + \fi\fi% + \if@svg@tempswa\else% + \FamilyOptions{SVG}{distort=false}% + \fi% } \newcommand*\svg@local@param@use{} \newcommand*\svg@local@param@def[1]{% @@ -690,9 +782,16 @@ \newcommand*\svg@input@path{} \let\svg@input@path\input@path \newcommand*\svgpath[1]{% - \def\svg@input@path{#1}% + \def\svg@tempa##1\@nil{% + \ifx\svg@tempb\bgroup% + \def\svg@input@path{#1}% + \else% + \def\svg@input@path{{#1}}% + \fi% + }% + \futurelet\svg@tempb\svg@tempa#1\@nil% } -\newcommand*{\includesvg}[2][]{% +\newcommand*\includesvg[2][]{% \begingroup% \svg@deprecated@param% \svg@local@param@set{#1}% @@ -707,12 +806,12 @@ \svg@ink@run% \IfFileExists{\svg@out@base}{}{% \@svg@file@foundfalse% - \svg@file@missing{\svg@out@base}{}% + \svg@file@missing{\svg@out@base}{\svg@file@base.\svg@file@ext}% }% \if@svg@ink@latex% \IfFileExists{\svg@out@base_tex}{}{% \@svg@file@foundfalse% - \svg@file@missing{\svg@out@base_tex}{}% + \svg@file@missing{\svg@out@base_tex}{\svg@file@base.\svg@file@ext}% }% \fi% \if@svg@file@found% @@ -730,8 +829,10 @@ \newcommand*\svg@param@angle{0} \svg@local@param@def{% \DefineFamilyKey[.param]{SVG}{angle}{% - \renewcommand*\svg@param@angle{#1}% - \FamilyKeyStateProcessed% + \ifisdimension{#1\p@}{% + \renewcommand*\svg@param@angle{#1}% + \FamilyKeyStateProcessed% + }{}% }% } \newcommand*\svg@param@origin{c} @@ -741,39 +842,56 @@ \FamilyKeyStateProcessed% }% } -\newcommand*{\includeinkscape}[2][]{% +\newcommand*\includeinkscape[2][]{% \begingroup% \svg@deprecated@param% - \filename@parse{#2}% + \svg@filename@parse{#2}% \ifx\filename@ext\relax\else% \svg@quotes@remove{\filename@ext}% \expandafter\lowercase\expandafter{% \expandafter\def\expandafter\filename@ext\expandafter{\filename@ext}% }% - \let\svg@tempb\filename@ext% - \def\svg@tempa##1_tex##2\@nil{\def\svg@tempb{##1}}% - \expandafter\svg@tempa\svg@tempb_tex\@nil% - \@for\svg@tempa:={pdf,eps,ps,png}\do{% - \ifstr{\svg@tempb}{\svg@tempa}{% - \edef\svg@tempa{% - \noexpand\FamilyOptions{SVG}{inkscapeformat=\svg@tempb}% - }% - \svg@tempa% - }{}% + \def\svg@tempb##1_tex##2\@nil{% + \IfArgIsEmpty{##1}{}{\def\filename@ext{##1}}% + \ifstr{##2}{_tex}{\@svg@tempswatrue}{\@svg@tempswafalse}% }% - \ifstr{\filename@ext}{\svg@ink@format_tex}{% - \FamilyOptions{SVG}{inkscapelatex=true}% - }{}% + \@svg@tempswafalse% + \@tfor\svg@tempa:={pdf}{eps}{ps}{png}\do{% + \begingroup% + \expandafter\svg@tempb\filename@ext_tex\@nil% + \svg@extension@parse{\svg@tempa}% + \ifx\filename@ext\relax% + \def\svg@tempb{\endgroup}% + \else% + \edef\svg@tempb{% + \endgroup% + \noexpand\FamilyOptions{SVG}{inkscapeformat=\svg@tempa}% + \if@svg@tempswa% + \noexpand\FamilyOptions{SVG}{inkscapelatex=true}% + \fi% + \def\noexpand\filename@base{\filename@base}% + \def\noexpand\filename@ext{\filename@ext}% + \noexpand\@svg@tempswatrue% + }% + \fi% + \svg@tempb% + \if@svg@tempswa% + \@break@tfor% + \fi% + }% + \if@svg@tempswa\else% + \svg@extension@parse{\svg@ink@format}% + \fi% \fi% \svg@local@param@set{#1}% - \expandafter\svg@get@path\expandafter[\svg@ink@format]{#2}{\svg@out@path}% + \svg@get@path[\svg@ink@format]{\filename@area\filename@base}{\svg@out@path}% \if@svg@file@found% \edef\svg@out@name{\svg@file@name}% \edef\svg@out@base{\svg@file@path\svg@file@name.\svg@ink@format}% \if@svg@ink@latex% \IfFileExists{\svg@out@base_tex}{}{% \@svg@file@foundfalse% - \svg@file@missing{\svg@out@base_tex}{}% + \svg@file@missing{\svg@out@base_tex}{\svg@out@base}% }% \fi% \if@svg@file@found% @@ -821,8 +939,7 @@ \ifnum\pdf@shellescape=\@ne\relax\if@svg@ink@run% \svg@iffilenewer{\svg@out@base_tex}{\svg@out@base}{% \@svg@ink@runfalse% - \edef\svg@tempa{\svg@out@base}% - \svg@quotes@remove{\svg@tempa}% + \svg@quotes@remove[\svg@out@base]{\svg@tempa}% \PackageWarning{svg}{% Since the encountered filedate of file\MessageBreak% `\svg@tempa_tex' is newer than \MessageBreak% @@ -851,10 +968,8 @@ \space with added options `\svg@ink@opt'% \fi% }% - \edef\svg@tempa{\svg@file@base}% - \edef\svg@tempb{\svg@out@name}% - \svg@quotes@remove{\svg@tempa}% - \svg@quotes@remove{\svg@tempb}% + \svg@quotes@remove[\svg@file@base]{\svg@tempa}% + \svg@quotes@remove[\svg@out@name]{\svg@tempb}% \ShellEscape{\svg@ink@cmd{\svg@tempa}{\svg@tempb}}% \IfFileExists{\svg@out@name.\svg@ink@format}{% \edef\svg@tempb{\svg@tempb.\svg@ink@format}% @@ -874,8 +989,7 @@ }% }% \else% - \edef\svg@tempa{\svg@file@base}% - \svg@quotes@remove{\svg@tempa}% + \svg@quotes@remove[\svg@file@base]{\svg@tempa}% \PackageWarning{svg}{% You didn't enable `shell escape' (or `write18')\MessageBreak% so it wasn't possible to launch the Inkscape export\MessageBreak% @@ -922,7 +1036,7 @@ \PackageInfo{svg}{Last page of `#1' is \the\@tempcnta}% \fi% \edef\svg@tempa{% - \noexpand\endgroup% + \endgroup% \noexpand\FamilyOptions{SVG}{lastpage=\the\@tempcnta}% }% \svg@tempa% @@ -952,32 +1066,57 @@ \if@svg@draft% \@svg@ink@latexfalse% \fi% - \edef\svg@tempa{#2}% + \def\svg@tempb##1.##2\@nil{% + \IfArgIsEmpty{##2}{% + \def\svg@tempb{##1}% + }{% + \edef\svg@tempa{\svg@tempa.##1}% + \svg@tempb##2\@nil% + }% + }% + \edef\svg@tempa{% + \def\noexpand\svg@tempa{}% + \noexpand\svg@tempb#2.\noexpand\@nil% + }% + \svg@tempa% + \svg@remove@leadingchar.\svg@tempa% + \edef\svg@tempa{{\svg@tempa}.\svg@tempb}% + \edef\svg@tempb{#2}% \if@svg@ink@latex% \svg@patches{\svg@tempa}% \ifnum\value{svg@param@lastpage}=\z@\relax% - \expandafter\svg@get@lastpage\expandafter{\svg@tempa}% + \expandafter\svg@get@lastpage\expandafter{\svg@tempb}% \fi% \edef\svg@tempa{% \ifx\svg@param@pretex\relax\else% \noexpand\svg@param@pretex% \fi% - \noexpand\input{\svg@tempa_tex}% + \noexpand\input{\svg@tempb_tex}% \ifx\svg@param@apptex\relax\else% \noexpand\svg@param@apptex% \fi% }% + \if@svg@param@distort% + \def\svg@tempb{\resizebox*{\svg@param@width}{\svg@param@height}}% + \else% + \let\svg@tempb\@firstofone% + \fi% + \sbox\svg@box{\svg@tempb{\svg@tempa}}% \ifdim\dimexpr\svg@param@angle\p@\relax=\z@\relax% - \svg@tempa% + \let\svg@tempb\@firstofone% \else% - \edef\svg@tempb{origin=\svg@param@origin}% - \expandafter\rotatebox\expandafter[\svg@tempb]{\svg@param@angle}{% - \svg@tempa% + \edef\svg@tempb{% + \noexpand\rotatebox[origin=\svg@param@origin]{\svg@param@angle}% }% \fi% + \svg@tempb{\usebox\svg@box}% \else% \svg@wrn@scale% - \edef\svg@tempb{keepaspectratio,scale=\svg@param@scale}% + \edef\svg@tempb{% + draft\if@svg@draft\else=false\fi,% + scale=\svg@param@scale,% + keepaspectratio\if@svg@param@distort=false\fi% + }% \ifdim\svg@param@height>\z@\relax% \edef\svg@tempb{\svg@tempb,height=\svg@param@height}% \fi% @@ -989,11 +1128,6 @@ \svg@tempb,origin=\svg@param@origin,angle=\svg@param@angle% }% \fi% - \if@svg@draft% - \edef\svg@tempb{\svg@tempb,draft}% - \else% - \edef\svg@tempb{\svg@tempb,draft=false}% - \fi% \expandafter\includegraphics\expandafter[\svg@tempb]{\svg@tempa}% \fi% } @@ -1077,8 +1211,7 @@ \fi \newcommand*\svg@shell@mkdir[1]{% \begingroup% - \edef\svg@tempa{#1}% - \svg@quotes@remove{\svg@tempa}% + \svg@quotes@remove[{#1}]{\svg@tempa}% \@svg@tempswatrue% \ifstr{\svg@tempa}{}{\@svg@tempswafalse}{% \ifstr{\svg@tempa}{./}{\@svg@tempswafalse}{% @@ -1094,6 +1227,7 @@ \newcommand*\svg@shell@rm[1]{% \ShellEscape{\svg@shell@@rm\space"#1"}% } +\svg@catcodecodes@restore \endinput %% %% End of file `svg.sty'. |