summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/svg
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-11-29 22:07:30 +0000
committerKarl Berry <karl@freefriends.org>2017-11-29 22:07:30 +0000
commitcd3505f88f11b375a6fcc7b4d112edc9db836914 (patch)
treeac09524d45187ec1236f0b9c8f28adfa545c33a8 /Master/texmf-dist/source/latex/svg
parentdbfe97ac1900d00d6758523b2090282cea45ce1c (diff)
svg (29nov17)
git-svn-id: svn://tug.org/texlive/trunk@45941 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/svg')
-rw-r--r--Master/texmf-dist/source/latex/svg/svg.dtx287
1 files changed, 194 insertions, 93 deletions
diff --git a/Master/texmf-dist/source/latex/svg/svg.dtx b/Master/texmf-dist/source/latex/svg/svg.dtx
index 7577c0e84a0..46e17750e28 100644
--- a/Master/texmf-dist/source/latex/svg/svg.dtx
+++ b/Master/texmf-dist/source/latex/svg/svg.dtx
@@ -1,4 +1,4 @@
-% \CheckSum{3465}
+% \CheckSum{3514}
% \iffalse meta-comment
%
% svg and svg-extract -- Include and extract SVG pictures in LaTeX documents
@@ -44,9 +44,9 @@ This work has the LPPL maintenance status "author-maintained".
The current maintainer and author of this work is Falk Hanisch.
-This work consists of the main source file README.md, LICENSE.md, svg.dtx and
-the derived documentation svg.pdf as well as the example files svg-example.svg,
-svg-preamble.tex and root.C (with derived file root.svg).
+This work consists of the main source file README.md, LICENSE.md, svg.dtx
+and the derived documentation svg.pdf as well as the example files
+svg-example.svg, svg-preamble.tex and root.C (with derived file root.svg).
}
\endgroup
@@ -115,7 +115,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
%<package&option&base>\ProvidesPackage{svg}[%
%<package&option&extract>\ProvidesPackage{svg-extract}[%
%<*driver|package&option>
- 2017/05/23 v2.00b\space%
+ 2017/11/29 v2.01\space%
%<package&option&base> (include SVG pictures)%
%<package&option&extract> (extract independent graphics from SVG pictures)%
]
@@ -229,7 +229,15 @@ svg-extract -- Extract independent graphic files from SVG pictures
% support of subfigures stopped due to the huge number of packages which deal
% with this topic and the large variety of implementing this functionality;
% naming exported graphics after their consecutive numbering can't be ensured
-% for all variants of subfigures, so it's neglected.%
+% for all variants of subfigures, so it's neglected%
+% }^^A
+% \changes{v2.01}{2017/11/27}{%
+% new option \opt{svgextension} to change the format of files exported by
+% \app{Inkscape} from \file{svg} to a custom one
+% }^^A
+% \changes{v2.01}{2017/11/28}{%
+% usage of \cs{input}\marg{tex filename} within \app{Inkscape}~graphics
+% locates files in all declared searched folders
% }^^A
%
%
@@ -473,6 +481,15 @@ svg-extract -- Extract independent graphic files from SVG pictures
% command line tool. For further information see the documentation of
% \hrfn{https://inkscape.org/de/doc/inkscape-man.html}{\app{Inkscape}}.
%
+% \DescribeOption{svgextension}
+% The package assumes SVG~files with \file{.svg} extension as source for the
+% \app{Inkscape} export. This option can be used to change this behaviour.
+% For example, in order to process \file{.dia} files instead of \file{.svg} you
+% could use
+% \begin{svgexample}
+% \includesvg[svgextension=dia,§\meta{additional options}§]§\marg{filename}§
+% \end{svgexample}
+%
%
%
% \subsection{Options for the graphic inclusion}
@@ -495,7 +512,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% graphic~file and \opt{apptex} right afterwards. For example, to change the
% size of the included text one could use:
% \begin{svgexample}
-% \includsvg[pretex=\tiny,§\meta{additional options}§]§\marg{svg filename}§
+% \includesvg[pretex=\tiny,§\meta{additional options}§]§\marg{svg filename}§
% \end{svgexample}
%
% \DescribeOption{draft}
@@ -532,15 +549,18 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{DescribeParameterParent}{Macro}{\includesvg}
% \DescribeParameters{%
% inkscape,inkscapeformat,inkscapelatex,inkscapearea,inkscapedpi,inkscapeopt,%
-% width,height,scale,pretex,apptex,draft,%
+% svgextension,width,height,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
-% with \file{.svg} ruthlessly. If this file is not located in the current
-% working directory but elsewhere on your file~system, the command \cs{svgpath}
-% could be used to specify this path. It is recommended to avoid any spaces
-% and/or quotes respectively \cs{dq} both in paths an file~names. Espacially
-% when DVI~output is active using quotes will certainly cause an error.
+% with \file{.svg} ruthlessly. In order to change the source file format for
+% the \app{Inkscape} export, you have to use parameter \prm{svgextension}.
+%
+% If the given file is not located in the current working directory but
+% elsewhere on your file~system, the command \cs{svgpath} could be used to
+% specify this path. It is recommended to avoid any spaces and/or quotes
+% respectively \cs{dq} both in paths an file~names. Espacially when DVI~output
+% is active using quotes will certainly cause an error.
%
% The command \cs{includesvg} is intended to do an automated export with
% \app{Inkscape} at first, where the given SVG~file is exported to a
@@ -576,6 +596,10 @@ svg-extract -- Extract independent graphic files from SVG pictures
% corresponding to the graphic~files generated by \app{Inkscape}.
% \end{DescribeParameterParent}
%
+%
+%
+% \subsection{Including already exported SVG~files}
+%
% \DescribeMacro{\includeinkscape}
% If you don't want to make use of the automated export with \app{Inkscape} but
% the user interface provided by the \pkg{svg} package, you can use
@@ -583,7 +607,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{svgexample}
% \includeinkscape§\oarg{parameters}\marg{graphic filename}§
% \end{svgexample}
-%
+%
% \begin{DescribeParameterParent}{Macro}{\includeinkscape}
% \DescribeParameters{%
% inkscapeformat,inkscapelatex,%
@@ -598,7 +622,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% same effect as described before for command \cs{includesvg} once when
% \cs{includeinkscape} is executed and remain unchanged afterwards.
% \end{DescribeParameterParent}
-%
+%
%
%
% \section{Usage of package \pkg{svg-extract}}
@@ -915,7 +939,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% (\opt{\meta{option}}|=|\val{\{\meta{outputformat}[+]=\cs{relax}\}}).
%
% \DescribeOption{convertdpi}
-% This options controls the used density for all file~formats or a specific one,
+% This option controls the used density for all file~formats or a specific one,
% whether \app{ImageMagick} or \app{Ghostscript} is used for the graphic
% conversion. The desired resolution of the converted file is given in dots per
% inch~(DPI) either as a scalar value (e.g.~\opt{convertdpi}|=|\val{600}) or
@@ -1506,7 +1530,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{option}{tex}
% \changes{v2.00b}{2017/03/28}{new, alternative key for \opt{inkscapelatex}}^^A
% \begin{macro}{\svg@ink@latex}
-% This options controls whether the \app{Inkscape} export will be invoked with
+% This option controls whether the \app{Inkscape} export will be invoked with
% or without the generation of a seperate \LaTeX~file.
% \begin{macrocode}
\newif\if@svg@ink@latex
@@ -1595,7 +1619,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
%
%
%
-% \subsubsection{Setting input folder}
+% \subsubsection{Setting input folder and file}
%
% \begin{option}{svgpath}
% \changes{v2.00}{2017/02/12}{deprecated}^^A
@@ -1616,6 +1640,38 @@ svg-extract -- Extract independent graphic files from SVG pictures
}
% \end{macrocode}
% \end{option}^^A svgpath
+% \begin{option}{svgextension}
+% \changes{v2.01}{2017/11/27}{new due to user request}^^A
+% \begin{option}{extension}
+% \begin{option}{ext}
+% \begin{macro}{\svg@file@ext}
+% This option modifies the expected extension for the input file which is
+% exported with \app{Inkscape}. It is set to \file{svg} by default.
+% \begin{macrocode}
+\newcommand*\svg@file@ext{svg}
+\DefineFamilyKey{SVG}{svgextension}{%
+% \end{macrocode}
+% Remove leading dots from the extension.
+% \begin{macrocode}
+ \def\svg@tempa##1.##2.##3\relax{%
+ \IfArgIsEmpty{##1}{%
+ \def\svg@file@ext{##2}%
+ }{%
+ \def\svg@file@ext{##1}%
+ }%
+ }%
+% \end{macrocode}
+% The extension should be in lower case letters.
+% \begin{macrocode}
+ \lowercase{\svg@tempa#1..\relax}%
+}
+\DefineFamilyKey{SVG}{extension}{\FamilyOptions{SVG}{svgextension=#1}}
+\DefineFamilyKey{SVG}{ext}{\FamilyOptions{SVG}{svgextension=#1}}
+% \end{macrocode}
+% \end{macro}^^A \svg@file@ext
+% \end{option}^^A ext
+% \end{option}^^A extension
+% \end{option}^^A svgextension
%
%
%
@@ -1870,6 +1926,70 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{macro}^^A \if@svg@quotes@found
% \end{macro}^^A \svg@quotes@@check
% \end{macro}^^A \svg@quotes@check
+% \begin{macro}{\svg@set@input@path}
+% \changes{v2.01}{2017/11/28}{new}%
+% \begin{macro}{\svg@append@input@path}
+% \changes{v2.01}{2017/11/28}{new}%
+% In order to import SVG~files from different folders, \cs{svg@set@input@path}
+% evaluates several macros, which are supposed to be used for holding different
+% search folders. Any given path will be handled by \cs{svg@normalize@path}.
+% The optional argument can be used to append an additional search path.
+% \begin{macrocode}
+\newcommand*\svg@set@input@path[1][]{%
+ \begingroup%
+% \end{macrocode}
+% If a path was already found and stored within \cs{svg@file@path}, it is
+% searched first and wrapped in curly braces. This is necessary for using
+% commands like \cs{input}\marg{tex filename} within SVG~files.
+% \begin{macrocode}
+ \ifx\svg@file@path\@empty\else%
+ \edef\svg@file@path{{\svg@file@path}}%
+ \fi%
+% \end{macrocode}
+% Afterwards, several search paths are appended. If \cs{svgpath} was used, it
+% is searched next. If nothing was found, \cs{graphicspath} is considered if
+% defined followed by a path given in the third argument. If nothing was found
+% yet, the standard \cs{input@path} is searched last.
+% \begin{macrocode}
+ \svg@append@input@path{\svg@file@path}{\svg@input@path}%
+ \svg@append@input@path{\svg@file@path}{\Ginput@path}%
+ \svg@append@input@path{\svg@file@path}{{#1}}%
+ \svg@append@input@path{\svg@file@path}{\input@path}%
+% \end{macrocode}
+% Passing each path to \cs{svg@normalize@path}.
+% \begin{macrocode}
+ \def\svg@tempb{}%
+ \expandafter\@tfor\expandafter\svg@tempa\expandafter:\expandafter=%
+ \svg@file@path\do{%
+ \ifx\svg@tempa\@empty\else%
+ \svg@normalize@path{\svg@tempa}%
+ \edef\svg@tempb{%
+ \unexpanded\expandafter{\svg@tempb}{\svg@tempa}%
+ }%
+ \fi%
+ }%
+% \end{macrocode}
+% Finally, \cs{input@path} is set.
+% \begin{macrocode}
+ \edef\svg@tempa{%
+ \endgroup%
+ \ifx\svg@tempb\@empty\else%
+ \noexpand\def\noexpand\input@path{\unexpanded\expandafter{\svg@tempb}}%
+ \fi%
+ }%
+ \svg@tempa%
+}
+% \end{macrocode}
+% Only, if a certain search path is defined, it is added.
+% \begin{macrocode}
+\newcommand*\svg@append@input@path[2]{%
+ \ifx#2\@undefined\else%
+ \edef#1{\unexpanded\expandafter{#1}#2}%
+ \fi%
+}
+% \end{macrocode}
+% \end{macro}^^A \svg@append@input@path
+% \end{macro}^^A \svg@set@input@path
% \begin{macro}{\svg@normalize@path}
% \begin{macro}{\svg@normalize@@path}
% If any path is given, a trailing slash is needed. These two macros ensure
@@ -1934,7 +2054,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \fi
%
% \begin{macro}{\svg@get@path}
-% \begin{macro}{\svg@get@@path}
+% \changes{v2.01}{2017/11/28}{using \cs{svg@set@input@path}}%
% \begin{macro}{\if@svg@file@found}
% \begin{macro}{\svg@file@path}
% \begin{macro}{\svg@file@name}
@@ -1953,7 +2073,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\newcommand*\svg@file@name{}
\newcommand*\svg@file@base{}
\newcommand*\svg@file@suffix{}
-\newcommand*\svg@get@path[3][svg]{%
+\newcommand*\svg@get@path[3][\svg@file@ext]{%
\begingroup%
% \end{macrocode}
% A maybe given, unneeded file extension is removed.
@@ -1971,32 +2091,23 @@ svg-extract -- Extract independent graphic files from SVG pictures
\edef\svg@tempa{"\svg@tempa"}%
\fi%
% \end{macrocode}
-% If \cs{svgpath} was used, it is searched first. If nothing was found,
-% \cs{graphicspath} is considered if defined followed by a path given in the
-% third argument. If nothing was found yet, the standard \cs{input@path} is
-% searched last.
-% \begin{macrocode}
- \@svg@file@foundfalse%
- \let\input@path\svg@path%
- \svg@get@@path{\svg@tempa}%
- \if@svg@file@found\else%
- \ifx\Ginput@path\@undefined\else%
- \let\input@path\Ginput@path%
- \svg@get@@path{\svg@tempa}%
- \fi%
- \fi%
- \IfArgIsEmpty{#3}{}{%
- \if@svg@file@found\else%
- \ifx#3\@undefined\else%
- \edef\svg@tempb{{#3}}%
- \let\input@path\svg@tempb%
- \svg@get@@path{\svg@tempa}%
- \fi%
- \fi%
- }%
+% After calling \cs{svg@set@input@path}, all search paths are stored in
+% \cs{input@path}, a single path given in the third argument will also be
+% considered.
+% \begin{macrocode}
+ \svg@set@input@path[#3]%
+% \end{macrocode}
+% The specified file is searched with \cs{IfFileExists}. If the file search was
+% succesful, the macro \cs{svg@filename@parse} is called with the result.
+% \begin{macrocode}
+ \@svg@tempswafalse%
+ \expandafter\IfFileExists\expandafter{\svg@tempa}{%
+ \@svg@tempswatrue%
+ \expandafter\svg@filename@parse\expandafter{\@filef@und}%
+ }{}%
\edef\svg@tempa{%
\endgroup%
- \if@svg@file@found%
+ \if@svg@tempswa%
\noexpand\@svg@file@foundtrue%
\noexpand\def\noexpand\svg@file@path{\filename@area}%
\noexpand\def\noexpand\svg@file@name{\filename@base}%
@@ -2011,24 +2122,11 @@ svg-extract -- Extract independent graphic files from SVG pictures
\svg@tempa%
}
% \end{macrocode}
-% The macro \cs{svg@get@@path} does the actual search job.
-% \begin{macrocode}
-\newcommand*\svg@get@@path[1]{%
-% The specified file is searched with \cs{IfFileExists}. If the file search was
-% succesful, the macro \cs{svg@filename@parse} is called with the result.
-% \begin{macrocode}
- \expandafter\IfFileExists\expandafter{#1}{%
- \@svg@file@foundtrue%
- \expandafter\svg@filename@parse\expandafter{\@filef@und}%
- }{}%
-}
-% \end{macrocode}
% \end{macro}^^A \svg@file@suffix
% \end{macro}^^A \svg@file@base
% \end{macro}^^A \svg@file@name
% \end{macro}^^A \svg@file@path
% \end{macro}^^A \if@svg@file@found
-% \end{macro}^^A \svg@get@@path
% \end{macro}^^A \svg@get@path
% \begin{macro}{\svg@filename@parse}
% As the internal \LaTeXe{} command \cs{filename@parse} is not able to split a
@@ -2116,25 +2214,35 @@ svg-extract -- Extract independent graphic files from SVG pictures
}%
}{%
\edef\filename@ext{#1}%
+ \ifstr{\filename@area}{./}{\let\filename@area\@empty}{}%
+% \end{macrocode}
+% Collecting all considered path for the error message.
+% \begin{macrocode}
\edef\svg@tempb{#3}%
\ifstr{\svg@tempb}{./}{\let\svg@tempb\@empty}{}%
- \ifstr{\filename@area}{./}{\let\filename@area\@empty}{}%
+ \ifx\svg@tempb\@empty%
+ \svg@set@input@path%
+ \else%
+ \svg@set@input@path[\svg@tempb]%
+ \fi%
+ \ifx\input@path\@undefined%
+ \def\svg@tempb{No additional path was given.}%
+ \else%
+ \def\svg@tempb{Following folders have been searched:}%
+ \expandafter\@tfor\expandafter\svg@tempa\expandafter:\expandafter=%
+ \input@path\do{%
+ \edef\svg@tempb{\svg@tempb\noexpand\MessageBreak\svg@tempa}%
+ }%
+ \fi%
+% \end{macrocode}
+% The error message itself.
+% \begin{macrocode}
\def\svg@tempa{%
There's no file `\filename@base.\filename@ext'\MessageBreak%
\ifx\filename@area\@empty%
- neither in the current directory nor\MessageBreak%
- any other searched path given by\MessageBreak%
- \string\svgpath%
- \ifx\svg@path\@undefined\space\else%
- \space(\svg@path)\MessageBreak%
- \fi%
- or \string\graphicspath%
- \ifx\Ginput@path\@undefined\else%
- \space(\Ginput@path)%
- \fi%
- \ifx\svg@tempb\@empty\else%
- \MessageBreak or even `inkscapepath' (`\svg@tempb')%
- \fi.%
+ neither in the current directory nor any other searched\MessageBreak%
+ path given by \string\svgpath\space or \string\graphicspath.%
+ \MessageBreak\svg@tempb%
\else%
in folder `\filename@area'.%
\fi%
@@ -2226,27 +2334,18 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{macro}^^A \svgsetup
% \begin{macro}{\svgpath}
% \changes{v2.00}{2017/02/12}{new}^^A
-% \begin{macro}{\svg@path}
+% \begin{macro}{\svg@input@path}
% With \cs{svgpath} the user can give several root paths to SVG~files in the
% same way as \cs{graphicspath} is used. The only difference is that a missing
% slash is added at the end of the path, if needed.
% \begin{macrocode}
-\newcommand*\svg@path{}
-\let\svg@path\input@path
+\newcommand*\svg@input@path{}
+\let\svg@input@path\input@path
\newcommand*\svgpath[1]{%
- \def\svg@tempb{}%
- \@tfor\svg@tempa:=#1\do{%
- \ifx\svg@tempa\@empty\else%
- \svg@normalize@path{\svg@tempa}%
- \edef\svg@tempb{\svg@tempb{\svg@tempa}}%
- \fi%
- }%
- \ifx\svg@tempb\@empty\else%
- \let\svg@path\svg@tempb%
- \fi%
+ \def\svg@input@path{#1}%
}
% \end{macrocode}
-% \end{macro}^^A \svg@path
+% \end{macro}^^A \svg@input@path
% \end{macro}^^A \svgpath
% \begin{macro}{\includesvg}
% \changes{v2.00}{2017/02/17}{changes, especially to optional parameters}^^A
@@ -2341,9 +2440,9 @@ svg-extract -- Extract independent graphic files from SVG pictures
% The file suffix used by both packages \pkg{svg} and \pkg{svg-extract}.
% \begin{macrocode}
\if@svg@ink@latex%
- \def\svg@file@suffix{_svg-tex}%
+ \edef\svg@file@suffix{_\svg@file@ext-tex}%
\else%
- \def\svg@file@suffix{_svg-raw}%
+ \edef\svg@file@suffix{_\svg@file@ext-raw}%
\fi%
\@onelevel@sanitize\svg@file@suffix%
% \end{macrocode}
@@ -2377,7 +2476,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \end{macrocode}
% Raise an error, if the requested SVG~file wasn't found.
% \begin{macrocode}
- \svg@file@missing[svg]{\svg@file@base}{}%
+ \svg@file@missing[\svg@file@ext]{\svg@file@base}{}%
\fi%
\endgroup%
}
@@ -2607,7 +2706,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
% This is the case when the SVG~file is newer than the corresponding exported
% file, or if the latter isn't present at all.
% \begin{macrocode}
- \svg@iffilenewer{\svg@file@base.svg}{\svg@out@base}{}{%
+ \svg@iffilenewer{\svg@file@base.\svg@file@ext}{\svg@out@base}{}{%
\@svg@ink@runfalse%
}%
% \end{macrocode}
@@ -2678,7 +2777,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
}{%
\PackageWarning{svg}{%
The export with Inkscape failed for file\MessageBreak%
- `\svg@tempa.svg'\MessageBreak%
+ `\svg@tempa.\svg@file@ext'\MessageBreak%
Troubleshooting: Please check in the log file how\MessageBreak%
the invocation of Inkscape took place and try to\MessageBreak%
execute it yourself in the terminal%
@@ -2693,7 +2792,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\PackageWarning{svg}{%
You didn't enable `shell escape' (or `write18')\MessageBreak%
so it wasn't possible to launch the Inkscape export\MessageBreak%
- for `\svg@tempa.svg'%
+ for `\svg@tempa.\svg@file@ext'%
}%
\fi%
\fi%
@@ -2711,7 +2810,7 @@ svg-extract -- Extract independent graphic files from SVG pictures
\ifx\svg@ink@dpi\relax\else--export-dpi=\svg@ink@dpi\space\fi%
\if@svg@ink@latex--export-latex\space\fi%
\svg@ink@opt\space%
- --file="#1.svg"\space%
+ --file="#1.\svg@file@ext"\space%
--export-\svg@ink@format="#2.\svg@ink@format"\space%
}
% \end{macrocode}
@@ -2784,11 +2883,13 @@ svg-extract -- Extract independent graphic files from SVG pictures
% \begin{macro}{\svg@@input}
% With \cs{svg@@input} the export results of \app{Inkscape} are included. The
% macro \cs{svg@input} is defined in order to realize the option \opt{exclude}
-% for package \pkg{svg-extract}.
+% for package \pkg{svg-extract}. The macro \cs{svg@set@input@path} is called to
+% support commands like \cs{input}\marg{tex filename} within SVG~files.
% \begin{macrocode}
\newcommand*\svg@input{\svg@@input}
\newcommand*\svg@@input[2][]{%
\IfArgIsEmpty{#1}{}{\svg@local@param@set{#1}}%
+ \svg@set@input@path%
\if@svg@draft%
\@svg@ink@latexfalse%
\fi%