| 1 |
% \iffalse meta-comment |
| 2 |
%<*identify> |
| 3 |
% |
| 4 |
% svg and svg-extract -- Handling SVG pictures in LaTeX documents |
| 5 |
% |
| 6 |
%% ---------------------------------------------------------------------------- |
| 7 |
%% |
| 8 |
%% Copyright (C) Philip Ilten <[email protected]>, 2012-2016 |
| 9 |
%% Copyright (C) Falk Hanisch <[email protected]>, 2017-2020 |
| 10 |
%% |
| 11 |
%% ---------------------------------------------------------------------------- |
| 12 |
%% |
| 13 |
%% This work may be distributed and/or modified under the conditions |
| 14 |
%% of the LaTeX Project Public License, version 1.3c of the license. |
| 15 |
%% The latest version of this license is in |
| 16 |
%% http://www.latex-project.org/lppl.txt |
| 17 |
%% and version 1.3c or later is part of all distributions of |
| 18 |
%% LaTeX 2005/12/01 or later and of this work. |
| 19 |
%% |
| 20 |
%% This work has the LPPL maintenance status "author-maintained". |
| 21 |
%% |
| 22 |
%% The current maintainer and author of this work is Falk Hanisch. |
| 23 |
%% |
| 24 |
%% This work consists of the main source file README.md, LICENSE.md, svg.dtx |
| 25 |
%% and the derived documentation svg.pdf as well as the example files |
| 26 |
%% svg-example.svg, svg-preamble.tex and root.C (with derived file root.svg). |
| 27 |
%% |
| 28 |
%% ---------------------------------------------------------------------------- |
| 29 |
%% |
| 30 |
%</identify> |
| 31 |
% \fi |
| 32 |
% |
| 33 |
% \iffalse |
| 34 |
%<*dtx> |
| 35 |
\ifx\documentclass\undefined |
| 36 |
\input docstrip.tex |
| 37 |
\keepsilent |
| 38 |
|
| 39 |
\declarepreamble\svgmainpreamble |
| 40 |
|
| 41 |
svg -- Include SVG pictures in LaTeX documents using Inkscape |
| 42 |
|
| 43 |
\endpreamble |
| 44 |
\declarepreamble\svgextractpreamble |
| 45 |
|
| 46 |
svg-extract -- Extract independent graphic files from SVG pictures |
| 47 |
|
| 48 |
\endpreamble |
| 49 |
\askforoverwritefalse |
| 50 |
\usedir{tex/latex/svg} |
| 51 |
\generate{% |
| 52 |
\usepreamble\svgmainpreamble |
| 53 |
\file{svg.sty}{ |
| 54 |
\from{svg.dtx}{package,identify,main} |
| 55 |
\from{svg.dtx}{package,base,main} |
| 56 |
\from{svg.dtx}{package,option,main} |
| 57 |
\from{svg.dtx}{package,body,main} |
| 58 |
} |
| 59 |
\usepreamble\svgextractpreamble |
| 60 |
\file{svg-extract.sty}{ |
| 61 |
\from{svg.dtx}{package,identify,extract} |
| 62 |
\from{svg.dtx}{package,base,extract} |
| 63 |
\from{svg.dtx}{package,option,extract} |
| 64 |
\from{svg.dtx}{package,standalone,extract} |
| 65 |
\from{svg.dtx}{package,body,extract} |
| 66 |
} |
| 67 |
} |
| 68 |
\else |
| 69 |
\let\endbatchfile\relax |
| 70 |
\fi |
| 71 |
\endbatchfile |
| 72 |
%</dtx> |
| 73 |
% \fi |
| 74 |
% |
| 75 |
% \iffalse |
| 76 |
%<*dtx|package&identify> |
| 77 |
\NeedsTeXFormat{LaTeX2e}[2020-02-02] |
| 78 |
%<*dtx> |
| 79 |
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi |
| 80 |
%</dtx> |
| 81 |
\begingroup |
| 82 |
\catcode`\@11\relax% |
| 83 |
\def\svg@Provides#1#2[#3]{% |
| 84 |
\def\@tempa{\def\svg@version{#3}}% |
| 85 |
\ifx\svg@version\@undefined\else% |
| 86 |
\def\@tempb{#3}% |
| 87 |
\ifx\svg@version\@tempb\else% |
| 88 |
\def\@tempa{% |
| 89 |
\@latex@warning@no@line{% |
| 90 |
The version of package `#1' is `#3',\MessageBreak% |
| 91 |
but `\svg@version' was expected!\MessageBreak% |
| 92 |
You should update the svg bundle% |
| 93 |
}% |
| 94 |
}% |
| 95 |
\fi% |
| 96 |
\fi% |
| 97 |
\edef\@tempb{% |
| 98 |
\endgroup% |
| 99 |
%<*dtx> |
| 100 |
\noexpand\ProvidesFile% |
| 101 |
%</dtx> |
| 102 |
%<package&identify> \noexpand\ProvidesPackage% |
| 103 |
{#1}[#3\space(#2)]% |
| 104 |
%<package&identify&extract> \noexpand\RequirePackage{svg}[#3]% |
| 105 |
\unexpanded\expandafter{\@tempa}% |
| 106 |
}% |
| 107 |
}% |
| 108 |
\svg@Provides% |
| 109 |
%<*dtx> |
| 110 |
{svg.dtx}{source}% |
| 111 |
%</dtx> |
| 112 |
%<package&identify&main> {svg}{include SVG pictures}% |
| 113 |
%<package&identify&extract> {svg-extract}{extract graphics from SVG pictures}% |
| 114 |
[2020/11/26 v2.02k]% |
| 115 |
\@tempb |
| 116 |
%</dtx|package&identify> |
| 117 |
% \fi |
| 118 |
% |
| 119 |
% \iffalse |
| 120 |
%<*dtx> |
| 121 |
\documentclass[english,xindy]{tudscrdoc}[2017/03/27] |
| 122 |
\usepackage{iftex}[2020/03/06] |
| 123 |
\iftutex |
| 124 |
\usepackage{fontspec} |
| 125 |
\else |
| 126 |
\usepackage[T1]{fontenc} |
| 127 |
\fi |
| 128 |
\usepackage{babel} |
| 129 |
\KOMAoptions{parskip=half-} |
| 130 |
\usepackage{marginnote} |
| 131 |
|
| 132 |
\usepackage{svg} |
| 133 |
\usepackage{svg-extract} |
| 134 |
\svgpath{{./examples/}} |
| 135 |
\svgsetup{extractpreamble=svg-preamble.tex,clean=true} |
| 136 |
|
| 137 |
\usepackage{xpatch} |
| 138 |
\ifdefined\includesvg |
| 139 |
\xpretocmd{\includesvg}{\MakePercentComment}{}{} |
| 140 |
\xapptocmd{\includesvg}{\MakePercentIgnore}{}{} |
| 141 |
\fi |
| 142 |
\ifdefined\includeinkscape |
| 143 |
\xpretocmd{\includeinkscape}{\MakePercentComment}{}{} |
| 144 |
\xapptocmd{\includeinkscape}{\MakePercentIgnore}{}{} |
| 145 |
\fi |
| 146 |
\ifdefined\pdfsuppresswarningpagegroup |
| 147 |
\pdfsuppresswarningpagegroup=1 |
| 148 |
\fi |
| 149 |
|
| 150 |
\usepackage{listings} |
| 151 |
\lstset{% |
| 152 |
inputencoding=utf8,extendedchars=true,% |
| 153 |
literate=% |
| 154 |
{ä}{{\"a}}1 {ö}{{\"o}}1 {ü}{{\"u}}1 |
| 155 |
{Ä}{{\"A}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1 |
| 156 |
{ß}{{\ss}}1 {~}{{\textasciitilde}}1 |
| 157 |
{»}{{\guillemetright}}1 {«}{{\guillemetleft}}1 |
| 158 |
} |
| 159 |
\newcommand*\svglstbelowskip{\medskipamount} |
| 160 |
\AtBeginDocument{% |
| 161 |
\renewcommand*\svglstbelowskip{\glueexpr\medskipamount-\parskip\relax}% |
| 162 |
} |
| 163 |
\lstdefinestyle{svg}{% |
| 164 |
basicstyle=\small\ttfamily,% |
| 165 |
columns=flexible,% |
| 166 |
frame=single,% |
| 167 |
backgroundcolor=\color{yellow!10},% |
| 168 |
xleftmargin=\fboxsep,% |
| 169 |
xrightmargin=\fboxsep,% |
| 170 |
gobble=2,% |
| 171 |
escapechar=§,% |
| 172 |
belowskip=\svglstbelowskip,% |
| 173 |
} |
| 174 |
\lstnewenvironment{svgexample}[1][]{% |
| 175 |
\lstset{style=svg,#1}% |
| 176 |
}{} |
| 177 |
\usepackage{enumitem} |
| 178 |
\newlist{DescribeValues}{description}{1} |
| 179 |
\setlist[DescribeValues]{font=\normalfont\val,style=nextline,noitemsep} |
| 180 |
|
| 181 |
\usepackage{subcaption} |
| 182 |
\usepackage{relsize} |
| 183 |
|
| 184 |
\usepackage{bookmark} |
| 185 |
\usepackage[babel]{microtype} |
| 186 |
|
| 187 |
%\EnableCrossrefs |
| 188 |
\CodelineIndex |
| 189 |
\RecordChanges |
| 190 |
\GetFileInfo{svg.dtx} |
| 191 |
|
| 192 |
\makeatletter |
| 193 |
\newcommand*\notebox[2][\svglstbelowskip]{% |
| 194 |
\ifhmode% |
| 195 |
\vskip\svglstbelowskip% |
| 196 |
\else% |
| 197 |
\addpenalty{\@beginparpenalty}% |
| 198 |
\addvspace{\svglstbelowskip}% |
| 199 |
\fi% |
| 200 |
\noindent% |
| 201 |
\fbox{\parbox{\dimexpr\linewidth-(\fboxsep+\fboxrule)*2\relax}{#2}}% |
| 202 |
\par\vskip#1\noindent\ignorespaces% |
| 203 |
} |
| 204 |
\makeatother |
| 205 |
|
| 206 |
\begin{document} |
| 207 |
\title{The packages \pkg{svg} and \pkg{svg-extract}} |
| 208 |
\author{% |
| 209 |
Philip Ilten (2012--2016)\\% |
| 210 |
Falk Hanisch (2017--)\\% |
| 211 |
\url{https://github.com/mrpiggi/svg}\\% |
| 212 |
\mailto{[email protected]}% |
| 213 |
} |
| 214 |
\date{\fileversion\nobreakspace(\filedate)} |
| 215 |
\providerobustcmd*\default[1]{\val{\textit{#1}}} |
| 216 |
\maketitle% |
| 217 |
\begin{abstract} |
| 218 |
\noindent |
| 219 |
The \pkg{svg} package is intended for the automated integration of |
| 220 |
SVG~graphics into \LaTeX~documents. The capabilities provided by |
| 221 |
\app{Inkscape}---or more precisely its command~line~interface---are used |
| 222 |
to export the text within a SVG~graphic to a separate file, which is |
| 223 |
then rendered by \LaTeX{}. The two commands \cs{includesvg} and |
| 224 |
\cs{includeinkscape} are provided as central user\hbox{-}interface, |
| 225 |
which are very similar to the \cs{includegraphics} command of the |
| 226 |
\pkg{graphicx} package. |
| 227 |
|
| 228 |
In addition, the package \pkg{svg-extract} allows the extraction of these |
| 229 |
graphics into independent files in different graphic formats, exactly as it |
| 230 |
is rendered within the \LaTeX~document. For the creation of these graphics |
| 231 |
in the well\hbox{-}known formats PDF, EPS and~PS, \LaTeX{} and possibly |
| 232 |
conversion tools shipped with the distribution are used. If the graphics |
| 233 |
are required in other file formats, either \app{ImageMagick} or |
| 234 |
\app{Ghostscript} can be invoked. |
| 235 |
|
| 236 |
\notebox[0pt]{% |
| 237 |
The command~line~interface~(CLI) of \app{Inkscape}\,1.0 has changed in |
| 238 |
comparison to previous versions. In order to provide a comfortable |
| 239 |
user\hbox{-}interface for invoking \app{Inkscape}, the used version is |
| 240 |
detected and if necessary switch to the outdated syntax of the CLI. If |
| 241 |
this approach fails for some reason, you can set the version of |
| 242 |
\app{Inkscape} manually with \opt{inkscapeversion}|=|\val{0} or |
| 243 |
\opt{inkscapeversion}|=|\val{1}.% |
| 244 |
}% |
| 245 |
\end{abstract} |
| 246 |
\tableofcontents |
| 247 |
\DocInput{\filename} |
| 248 |
\end{document} |
| 249 |
%</dtx> |
| 250 |
% \fi |
| 251 |
% |
| 252 |
% \changes{v1.0}{2004/11/05}{initial version by Philip Ilten}^^A |
| 253 |
% \changes{v2.00}{2016/09/23}{new maintainer: Falk Hanisch}^^A |
| 254 |
% \changes{v2.00}{2017/03/27}{re-implementation from scratch}^^A |
| 255 |
% \changes{v2.00}{2017/03/27}{package \pkg{subfig} not required anymore}^^A |
| 256 |
% \changes{v2.00}{2017/03/27}{support of subfigures stopped due to the huge |
| 257 |
% number of packages which deal with this topic and the large variety of |
| 258 |
% implementing this functionality; naming exported graphics after their |
| 259 |
% consecutive numbering can't be ensured for all variants of subfigures, so |
| 260 |
% it's neglected}^^A |
| 261 |
% \changes{v2.01}{2017/11/28}{usage of \cs{input}\marg{tex~filename} within |
| 262 |
% \app{Inkscape}~graphics locates files in all declared searched folders}^^A |
| 263 |
% \changes{v2.02}{2018/09/07}{package \pkg{trimspaces} required}^^A |
| 264 |
% \changes{v2.02}{2018/09/07}{multiple dots within file names possible}^^A |
| 265 |
% \changes{v2.02}{2018/09/07}{fixed errors with active double quotes from |
| 266 |
% \pkg{babel} in path arguments}^^A |
| 267 |
% \changes{v2.02a}{2018/10/17}{fix bug for package \pkg{polyglossia} which |
| 268 |
% fakes \pkg{babel} poorly}^^A |
| 269 |
% \changes{v2.02b}{2018/11/12}{fix bug for package \pkg{tikzscale} which |
| 270 |
% changes \cs{includegraphics} globally}^^A |
| 271 |
% \changes{v2.02c}{2019/10/10}{fix bugs with kernel (2019/10/01) regarding file |
| 272 |
% name parsing}^^A |
| 273 |
% \changes{v2.02d}{2019/10/22}{fix bugs with kernel (2019/10/01) regarding file |
| 274 |
% name parsing, see \url{https://github.com/mrpiggi/svg/issues/16}}^^A |
| 275 |
% \changes{v2.02d}{2019/10/22}{conditional invocation of \app{Inkscape} export |
| 276 |
% based on file modification date implemented for Xe\TeX{}}^^A |
| 277 |
% \changes{v2.02f}{2020/05/06}{command~line~interface of \app{Inkscape~1.0} |
| 278 |
% is supported}^^A |
| 279 |
% \changes{v2.02g}{2020/06/12}{fix for multiple dots in file names (\#27)}^^A |
| 280 |
% \changes{v2.02h}{2020/06/23}{fix for package \pkg{transparent} (\#28)}^^A |
| 281 |
% \changes{v2.02i}{2020/09/29}{update for package \pkg{scrlfile} v3.32 and |
| 282 |
% kernel (2020/10/01)}^^A |
| 283 |
% \changes{v2.02j}{2020/10/23}{bug fix for automatic version detection of |
| 284 |
% \app{Inkscape} with MiK\TeX}^^A |
| 285 |
% \changes{v2.02k}{2020/11/26}{MiK\TeX was updated, bug fix removed}^^A |
| 286 |
% |
| 287 |
% |
| 288 |
% |
| 289 |
% \part{User documentation} |
| 290 |
% \section{Introduction} |
| 291 |
% |
| 292 |
% The open source program \app{Inkscape} has provided an excellent resource for |
| 293 |
% the simple and easy creation of images and diagrams using a graphical |
| 294 |
% user\hbox{-}interface. The work by Johan\,B.\,C.~Engelen has further enhanced |
| 295 |
% the ability of \app{Inkscape} to split a SVG~file into a text component that |
| 296 |
% can be compiled with \LaTeX{}, and an image component that can be imported |
| 297 |
% as a PDF~file. For further information see the documentation of |
| 298 |
% \hrfn{http://www.ctan.org/pkg/svg-inkscape}{\pkg{svg-inkscape} on CTAN}. |
| 299 |
% The procedure described therein is taken up and consistently expanded. Thus, |
| 300 |
% it is now possible to include a SVG~file into a \LaTeX~document where the |
| 301 |
% text within the SVG~graphic will be rendered natively by \LaTeX{}. |
| 302 |
% |
| 303 |
% Both packages \pkg{svg} and \pkg{svg-extract} rely heavily upon executing |
| 304 |
% commands on shell using the \cs{ShellEscape} command---or respectively the |
| 305 |
% old known \cs{write18}---for executing the CLIs of the applications mentioned |
| 306 |
% above. So passing flag \file{-{}-shell-escape} to the \LaTeX~engine is |
| 307 |
% utterly essential when using package \pkg{svg} and/or \pkg{svg-extract}. The |
| 308 |
% executed commands and the possibilities to adapt their invocation with the |
| 309 |
% appropriate options are described later on in this documentation. All this is |
| 310 |
% done automatically with the \cs{includesvg} command. If you don't want to use |
| 311 |
% the \file{-{}-shell-escape} flag, either for security reasons or because |
| 312 |
% the export of the SVG~files is done in another way, there's also the command |
| 313 |
% \cs{includeinkscape} which includes files already exported by \app{Inkscape}. |
| 314 |
% |
| 315 |
% An working installation of \app{Inkscape} is required for the automated |
| 316 |
% integration of SVG~graphics, whereby the installation path must be |
| 317 |
% known to the operating system. This can be checked on shell by typing |
| 318 |
% \file{inkscape -V}. Moreover, there are some required packages which are |
| 319 |
% loaded by packages \pkg{svg} and \pkg{svg-extract} to provide the |
| 320 |
% functionality. These are: |
| 321 |
% \begin{description}[parsep=\glueexpr\smallskipamount/2\relax] |
| 322 |
% \item[\pkg{iftex}] |
| 323 |
% for flow control depending on the used \LaTeX~engine |
| 324 |
% \item[\pkg{scrbase}] |
| 325 |
% for the definition and handling of options in key-value-syntax |
| 326 |
% \item[\pkg{pdftexcmds}, \pkg{shellesc}] |
| 327 |
% to allocate the same primitives independent of the used \LaTeX~engine |
| 328 |
% \item[\pkg{ifplatform}] |
| 329 |
% to control the file~access depending on the operating system |
| 330 |
% \item[\pkg{trimspaces}] |
| 331 |
% to remove unwanted spaces in file paths |
| 332 |
% \item[\pkg{graphicx}] |
| 333 |
% for including the graphic~files after the \app{Inkscape}~export |
| 334 |
% \item[\pkg{xcolor}, \pkg{transparent}] |
| 335 |
% are possibly needed by the separate \LaTeX~files created by \app{Inkscape} |
| 336 |
% \item[\pkg{xr}] |
| 337 |
% is used by \pkg{svg-extract} in order to include labels within the |
| 338 |
% independent graphic~files |
| 339 |
% \end{description} |
| 340 |
% |
| 341 |
% If you want to pass options to package \pkg{graphicx}, you must either load |
| 342 |
% it before package \pkg{svg} |
| 343 |
% \begin{svgexample} |
| 344 |
% \usepackage§\oarg{options}§{graphicx} |
| 345 |
% §\dots§ |
| 346 |
% \usepackage§\oarg{options}§{svg} |
| 347 |
% \end{svgexample} |
| 348 |
% or use \cs{PassOptionsToPackage}. |
| 349 |
% \begin{svgexample} |
| 350 |
% \PassOptionsToPackage§\marg{options}§{graphicx} |
| 351 |
% §\dots§ |
| 352 |
% \documentclass§\oarg{options}\marg{class}§ |
| 353 |
% §\dots§ |
| 354 |
% \usepackage§\oarg{options}§{svg} |
| 355 |
% \end{svgexample} |
| 356 |
% The usage of packages \pkg{xcolor} and \pkg{transparent} can be switched off |
| 357 |
% while loading package \pkg{svg}. See the two options \opt{usexcolor} and |
| 358 |
% \opt{usetransparent} below. |
| 359 |
% |
| 360 |
% |
| 361 |
% |
| 362 |
% \section{Usage of package \pkg{svg}\label{sec:inkscape}} |
| 363 |
% |
| 364 |
% The purpose of this package is to include standalone SVG~graphics into a |
| 365 |
% \LaTeX~document. The command \cs{includesvg} is defined which does all |
| 366 |
% necessary steps for this task. It first launches the export of a SVG~file |
| 367 |
% to a supported file~format with Inkscape, if necessary, and includes the |
| 368 |
% exported graphic~file afterwards. The usage and the syntax is quite similar |
| 369 |
% to the command \cs{includegraphics} from the \pkg{graphicx} package. In fact, |
| 370 |
% the inclusion of the exported graphic~file is done with \cs{includegraphics}. |
| 371 |
% |
| 372 |
% \DescribeOptions{usexcolor,usetransparent,noxcolor,notransparent}^^A |
| 373 |
% The packages \pkg{xcolor} and \pkg{transparent} are loaded by default at the |
| 374 |
% end of package \pkg{svg}. The listed options are intended to prevent these |
| 375 |
% packages from loading. They are the only options which have to be given while |
| 376 |
% loading the \pkg{svg} package. All supported boolean values |
| 377 |
% (\val{true/on/yes/false/off/no}) can be assigned to \opt{usexcolor} and |
| 378 |
% \opt{usetransparent}, while \opt{noxcolor} and \opt{notransparent} don't |
| 379 |
% accept any value. |
| 380 |
% \begin{svgexample} |
| 381 |
% \usepackage§\oarg{options}§{svg} |
| 382 |
% \end{svgexample} |
| 383 |
% \notebox[0pt]{^^A |
| 384 |
% Due to the way the \LaTeX~kernel parses package options, problems may occur |
| 385 |
% if any option other than those just mentioned above~-- meaning the options |
| 386 |
% explained hereafter~-- are passed through the optional argument of |
| 387 |
% \cs{usepackage}\oarg{options}|\{svg\}|. It is strongly recommended to use |
| 388 |
% \cs{svgsetup}\marg{options} for these after loading the package instead.^^A |
| 389 |
% } |
| 390 |
% |
| 391 |
% |
| 392 |
% \subsection{General settings} |
| 393 |
% |
| 394 |
% \DescribeMacro{\svgsetup}^^A |
| 395 |
% All other options described in detail below can also be changed after loading |
| 396 |
% the package either in the preamble or within the document. They don't have to |
| 397 |
% be given as optional argument to \cs{usepackage}\oarg{options}|{svg}| but can |
| 398 |
% be set by using macro \cs{svgsetup}\marg{options} where \meta{options} is a |
| 399 |
% comma separated list of options. These settings are done in the current scope |
| 400 |
% which means either globally or within the current group. |
| 401 |
% \begin{svgexample} |
| 402 |
% \svgsetup§\marg{options}§ |
| 403 |
% \end{svgexample} |
| 404 |
% Further, with the optional argument of commands |
| 405 |
% \cs{includesvg}\oarg{options}\marg{svg~filename} or |
| 406 |
% \cs{includeinkscape}\oarg{options}\marg{graphic~filename}, it's possible to |
| 407 |
% reset any setting locally for a certain file. |
| 408 |
% |
| 409 |
% \DescribeMacro{\svgpath}^^A |
| 410 |
% Most likely you want to organize your SVG~files in a separate folder either |
| 411 |
% as a subfolder in the working directory or elsewhere in your local folder |
| 412 |
% structure. For this purpose, a list of root paths to SVG~files can be |
| 413 |
% specified using the \cs{svgpath} command in the same way as \cs{graphicspath} |
| 414 |
% is used. Every path has to be given in a group of braces |{}|---even if there |
| 415 |
% is only one---and should terminate with a slash. For example: |
| 416 |
% \begin{svgexample} |
| 417 |
% \svgpath{{svg/}{/usr/local/svg/}} |
| 418 |
% \end{svgexample} |
| 419 |
% would cause the system to look first in the subdirectory \file{svg/} and |
| 420 |
% afterwards in the absolute path \file{/usr/local/svg/}. Further, if no path |
| 421 |
% was specified with \cs{svgpath} or the desired file wasn't found, all |
| 422 |
% directories given with \cs{graphicspath} are searched too. Please keep in |
| 423 |
% mind that the current working directory is browsed first in any case. |
| 424 |
% It is recommended to avoid umlauts or any other Non\hbox{-}ASCII characters |
| 425 |
% as well as any spaces and/or quotes respectively \cs{dq} both in paths and |
| 426 |
% file~names. Especially when DVI~output is active using quotes will certainly |
| 427 |
% cause an error. |
| 428 |
% |
| 429 |
% |
| 430 |
% |
| 431 |
% \subsection{Options for the invocation of \app{Inkscape}} |
| 432 |
% |
| 433 |
% \DescribeOption{inkscape}^^A |
| 434 |
% This option controls, when the export with \app{Inkscape} is invoked and is |
| 435 |
% \default{true} by default. |
| 436 |
% \begin{DescribeValues}^^A |
| 437 |
% \item[false/off/no] |
| 438 |
% \app{Inkscape} won't be invoked in any case, no export is done. |
| 439 |
% \item[\default{true}/on/yes/newer/onlynewer] |
| 440 |
% The export with \app{Inkscape} will only be done, if the exported |
| 441 |
% graphic~file either does not exist or the file~modification date of the |
| 442 |
% SVG~file is newer than that of the exported graphic~file. Thus the |
| 443 |
% compilation time of the \LaTeX~document can be reduced to the necessary |
| 444 |
% minimum. |
| 445 |
% \item[forced/force/overwrite] |
| 446 |
% The \app{Inkscape}~export will definitely be done, any already existing |
| 447 |
% exported file will overwritten regardlessly. |
| 448 |
% \end{DescribeValues} |
| 449 |
% |
| 450 |
% In addition to controlling the export behavior, the option \opt{inkscape} can |
| 451 |
% also be used to make additional settings, which then acts as a wrapper for |
| 452 |
% the options described below. |
| 453 |
% |
| 454 |
% \begin{DescribeValues}^^A |
| 455 |
% \item[pdf/eps/ps/png] |
| 456 |
% see \opt{inkscapeformat}|=|\val{pdf/eps/ps/png} |
| 457 |
% \item[latex/nolatex] |
| 458 |
% see \opt{inkscapelatex}|=|\val{true/false} |
| 459 |
% \item[drawing/page] |
| 460 |
% see \opt{inkscapearea}|=|\val{drawing/page} |
| 461 |
% \item[\meta{integer}dpi] |
| 462 |
% see \opt{inkscapedpi}|=|\val{\meta{integer}} |
| 463 |
% \end{DescribeValues} |
| 464 |
% |
| 465 |
% \DescribeOption{inkscapepath}^^A |
| 466 |
% The option \opt{inkscapepath} specifies, where the resulting files of the |
| 467 |
% \app{Inkscape}~export should be located. The default setting is |
| 468 |
% \default{basesubdir}, which uses the subfolder \file{./svg-inkscape/} |
| 469 |
% within the current working directory. |
| 470 |
% \begin{DescribeValues}^^A |
| 471 |
% \item[svgdir/svgpath] |
| 472 |
% The PDF/EPS/PS/PNG~graphic~files as well as the \LaTeX~files generated by |
| 473 |
% \app{Inkscape} will be located in the same directory as the corresponding |
| 474 |
% SVG~file. |
| 475 |
% \item[svgsubdir/svgsubpath] |
| 476 |
% Within the folder of the encountered SVG~file, all exported files will be |
| 477 |
% located in a subfolder named \file{svg-inkscape/}. |
| 478 |
% \item[basedir/basepath/jobdir/jobpath] |
| 479 |
% All exported files will be located in the current working directory. |
| 480 |
% \item[\default{basesubdir}/basesubpath/jobsubdir/jobsubpath] |
| 481 |
% A subfolder named \file{svg-inkscape/} within the current working directory |
| 482 |
% will be used for files generated by \app{Inkscape}. |
| 483 |
% \item[/path/to/somewhere/] |
| 484 |
% It is also possible to give a custom path, either relative to the current |
| 485 |
% working directory (\file{./relative/path/}) or as an absolute path. |
| 486 |
% \end{DescribeValues} |
| 487 |
% |
| 488 |
% \DescribeOption{inkscapeexe}^^A |
| 489 |
% For including a SVG~file, \app{Inkscape} is used to separate the text and |
| 490 |
% image from the SVG~file itself. In order to use the command~line~interface |
| 491 |
% on shell, the path where the executable is located has to be known to the |
| 492 |
% operating system and is assumed to be \val{inkscape} by default. |
| 493 |
% |
| 494 |
% You can check if the default setting is valid for your system by typing |
| 495 |
% \file{inkscape -V} into the terminal. If this fails and nothing is returned, |
| 496 |
% you should add the binary directory of \app{Inkscape} to the environment |
| 497 |
% variable \file{PATH} on your operating system. For the case, that this is not |
| 498 |
% possible or you aren't willing to do so, you can alternatively pass option |
| 499 |
% \opt{inkscapeexe} to \cs{svgsetup} \emph{within the document preamble} to set |
| 500 |
% the absolute path where the executable of \app{Inkscape} is located. |
| 501 |
% |
| 502 |
% \notebox[0pt]{^^A |
| 503 |
% Especially if the executable path to be defined \emph{contains spaces}, it |
| 504 |
% \emph{must not} be passed as a package option but to |
| 505 |
% \cs{svgsetup}|\{inkscapeexe=\dots\}| instead!^^A |
| 506 |
% } |
| 507 |
% |
| 508 |
% \DescribeOption{inkscapeversion}^^A |
| 509 |
% \changes{v2.02f}{2020/05/06}{option {inkscapeversion} for explicitly setting |
| 510 |
% \app{Inkscape}-CLI version; automatic detection implemented}^^A |
| 511 |
% The command~line~interface of \app{Inkscape} changed slightly from version |
| 512 |
% \val{0.9x} to \val{1.x} and makes it necessary to distinguish between the two |
| 513 |
% versions. By default, \opt{inkscapeversion}|=|\val{auto} is set and the used |
| 514 |
% version is automatically detected. This is done by calling \app{Inkscape}-CLI |
| 515 |
% with parameter~\prm{-V} on shell---see option \opt{inkscapeexe} described |
| 516 |
% above. The returned result is evaluated by either piping \val{stdout} or |
| 517 |
% eventually---if this fails---writing to a temporary file and read this back |
| 518 |
% in (pipes with a potentially quoted path can not be used with MiK\TeX).^^A |
| 519 |
% \footnote{^^A |
| 520 |
% If this fails too, the \app{Inkscape} version is guessed when macro |
| 521 |
% \cs{svg@ink@run} is used the very first time.^^A |
| 522 |
% } |
| 523 |
% It is also possible to switch off the automatic detection routine by setting |
| 524 |
% the desired version manually with either \opt{inkscapeversion}|=|\val{0} to |
| 525 |
% legacy mode or \opt{inkscapeversion}|=|\val{1} to the current CLI~version. |
| 526 |
% |
| 527 |
% \DescribeOption{inkscapename}^^A |
| 528 |
% \app{Inkscape}~export file~names are derived from the SVG~file~name by |
| 529 |
% default. However, the name of the exported file can be customized with |
| 530 |
% \opt{inkscapename}|=|\file{\meta{filename}}. It is possible to use counters |
| 531 |
% for specifying the name of the exported file. Repeatedly specifying the same |
| 532 |
% file~name will overwrite previously created files. |
| 533 |
% |
| 534 |
% \DescribeOption{inkscapeformat}^^A |
| 535 |
% With this option, the \app{Inkscape}~export~format can be controlled. Valid |
| 536 |
% values are \val{pdf}, \val{eps}, \val{ps} and \val{png}, where a \LaTeX~export |
| 537 |
% is not possible for \val{png} and option \opt{inkscapelatex} won't have any |
| 538 |
% effect. By default, \opt{inkscapeformat}|=|\val{pdf} is set unless DVI~output |
| 539 |
% was detected. In this case \opt{inkscapeformat}|=|\val{eps} is the default |
| 540 |
% setting. |
| 541 |
% |
| 542 |
% \DescribeOption{inkscapelatex}^^A |
| 543 |
% If option \opt{inkscapelatex}|=|\val{true} is set, the output is split into |
| 544 |
% a separate PDF/EPS/PS~file (see option \opt{inkscapeformat}) and a |
| 545 |
% corresponding \LaTeX~file. This is the default setting. Setting |
| 546 |
% \opt{inkscapelatex}|=|\val{false} will result in a single PDF/EPS/PS~file, |
| 547 |
% where any contained text won't be rendered by \LaTeX{}. |
| 548 |
% |
| 549 |
% \DescribeOption{inkscapearea}^^A |
| 550 |
% This option controls which area of the SVG~file should be exported, |
| 551 |
% \default{drawing} is set by default. |
| 552 |
% \begin{DescribeValues}^^A |
| 553 |
% \item[\default{drawing}/crop] |
| 554 |
% The area exported corresponds to the bounding box of all objects in a |
| 555 |
% drawing, including any that are not on the page. |
| 556 |
% \item[page/nocrop] |
| 557 |
% The area exported will correspond to the defined page~area within the |
| 558 |
% SVG~file. |
| 559 |
% \end{DescribeValues} |
| 560 |
% |
| 561 |
% \DescribeOption{inkscapedpi}^^A |
| 562 |
% The resolution used either for PNG~export or for fallback rasterization of |
| 563 |
% filtered objects when exporting to PDF/EPS/PS~file. For PNG~export it is set |
| 564 |
% to 300\,dpi by default, if no value was given. The given value should be a |
| 565 |
% positive integer. The default behaviour can be reversed after a given value |
| 566 |
% with \opt{inkscapedpi}|=|\val{\cs{relax}}. |
| 567 |
% |
| 568 |
% \DescribeOption{inkscapeopt}^^A |
| 569 |
% You can use this option to pass additional switches to the \app{Inkscape} |
| 570 |
% command~line~interface. For further information see the documentation of |
| 571 |
% \hrfn{https://inkscape.org/de/doc/inkscape-man.html}{\app{Inkscape}}. |
| 572 |
% |
| 573 |
% \DescribeOption{svgextension}^^A |
| 574 |
% \changes{v2.01}{2017/11/27}{option \opt{svgextension} added in order to |
| 575 |
% change the format of files exported by \app{Inkscape} from \file{svg} to |
| 576 |
% a custom one}^^A |
| 577 |
% The package assumes SVG~files with \file{.svg} extension as source for the |
| 578 |
% \app{Inkscape} export. This option can be used to change this behaviour. |
| 579 |
% For example, in order to process \file{.dia} files instead of \file{.svg} you |
| 580 |
% could use |
| 581 |
% \begin{svgexample} |
| 582 |
% \includesvg[svgextension=dia,§\meta{additional~options}§]§\marg{filename}§ |
| 583 |
% \end{svgexample} |
| 584 |
% |
| 585 |
% |
| 586 |
% |
| 587 |
% \subsection{Options for the graphic inclusion} |
| 588 |
% |
| 589 |
% \DescribeOptions{width,height,distort,scale}^^A |
| 590 |
% \changes{v2.02}{2018/09/07}{option \opt{distort} (or \opt{keepaspectratio}) |
| 591 |
% added for distortion of included graphics}^^A |
| 592 |
% The width of the included graphic~file can be specified via the \opt{width} |
| 593 |
% option and the height by the \opt{height} option. If both the width and |
| 594 |
% height are specified, the figure will be scaled such that neither of the |
| 595 |
% specified dimensions is exceeded, unless option \opt{distort}|=|\val{true} is |
| 596 |
% given.\footnote{to provide compatibility for package \pkg{graphicx}, it's |
| 597 |
% possible to use \prm{keepaspectratio}|=|\val{true} as alias for |
| 598 |
% \opt{distort}|=|\val{false} and the other way round} |
| 599 |
% If \opt{width} and/or \opt{height} once have been set, this can be undone |
| 600 |
% by setting them to \val{0pt} or \cs{relax}. If neither \opt{width} nor |
| 601 |
% \opt{height} are set, the included graphic~file can also be scaled by setting |
| 602 |
% \opt{scale} to a positive real number. |
| 603 |
% |
| 604 |
% \DescribeOptions{pretex,apptex}^^A |
| 605 |
% Commands prior and post to the inclusion of the graphic~file may be desired, |
| 606 |
% such as font or color commands. The options \opt{pretex} and \opt{apptex} are |
| 607 |
% provided where the \LaTeX~code given to \opt{pretex} is included before the |
| 608 |
% graphic~file and \opt{apptex} right afterwards. For example, to change the |
| 609 |
% size of the included text one could use: |
| 610 |
% \begin{svgexample} |
| 611 |
% \includesvg[pretex=\tiny,§\meta{additional~options}§]§\marg{svg~filename}§ |
| 612 |
% \end{svgexample} |
| 613 |
% |
| 614 |
% \DescribeOption{draft}^^A |
| 615 |
% This option can be used with boolean values and is equal to the identically |
| 616 |
% named option of the \pkg{graphicx} package. If the \opt{draft} option is |
| 617 |
% given to \pkg{graphicx}, it's activated for \pkg{svg} as well. |
| 618 |
% |
| 619 |
% \DescribeOption{lastpage}^^A |
| 620 |
% A \hrfn{https://bugs.launchpad.net/ubuntu/+source/inkscape/+bug/1417470}{bug} |
| 621 |
% concerning the \LaTeX~export has been reported for \app{Inkscape}\,0.91. It |
| 622 |
% may happen that within the exported \LaTeX~file, it's attempted to include |
| 623 |
% more pages of the PDF~graphics than actually exist. The \pkg{svg} package |
| 624 |
% attempts to bypass the resulting error. |
| 625 |
% |
| 626 |
% Consequently, the total number of pages is read and only existing PDF~pages |
| 627 |
% are included, if both options \opt{inkscapeformat}|=|\val{pdf} and |
| 628 |
% \opt{lastpage}|=|\val{true} are set. This is the default setting |
| 629 |
% (unless DVI~output is active) and can be switched off with |
| 630 |
% \opt{lastpage}|=|\val{false}. It's also possible to set the number of the |
| 631 |
% last page included of a PDF~graphic manually as optional parameter for |
| 632 |
% \cs{includesvg} or \cs{includeinkscape}. For details, see the description of |
| 633 |
% the respective commands. |
| 634 |
% |
| 635 |
% |
| 636 |
% |
| 637 |
% \subsection{Including SVG~files} |
| 638 |
% |
| 639 |
% \DescribeMacro{\includesvg}^^A |
| 640 |
% The command \cs{includesvg} to include a SVG~file is quite similar to the |
| 641 |
% \cs{includegraphics} command provided by the \pkg{graphicx} package. |
| 642 |
% \begin{svgexample} |
| 643 |
% \includesvg§\oarg{parameters}\marg{svg~filename}§ |
| 644 |
% \end{svgexample} |
| 645 |
% |
| 646 |
% \begin{DescribeParameterParent}{Macro}{\includesvg}^^A |
| 647 |
% \DescribeParameters{inkscape,inkscapeformat,inkscapelatex,inkscapearea,^^A |
| 648 |
% inkscapedpi,inkscapeopt,svgextension,width,height,distort,scale,^^A |
| 649 |
% pretex,apptex,draft}^^A |
| 650 |
% It is used right in the same way but where \meta{svg~filename} is the |
| 651 |
% file~name of the SVG~file, where any given file~extension will be replaced |
| 652 |
% with \file{.svg} ruthlessly. In order to change the source file format for |
| 653 |
% the \app{Inkscape} export, you have to use parameter \prm{svgextension}. |
| 654 |
% |
| 655 |
% If the given file is not located in the current working directory but |
| 656 |
% elsewhere on your file~system, the command \cs{svgpath} could be used to |
| 657 |
% specify this path. |
| 658 |
% \ToDo{reference to general note at the very beginning instead}[v2.03]^^A |
| 659 |
% It is recommended to avoid umlauts or any other Non\hbox{-}ASCII characters |
| 660 |
% as well as any spaces and/or quotes respectively \cs{dq} both in paths and |
| 661 |
% file~names. Especially when DVI~output is active using quotes will certainly |
| 662 |
% cause an error. |
| 663 |
% |
| 664 |
% The command \cs{includesvg} is intended to do an automated export with |
| 665 |
% \app{Inkscape} at first, where the given SVG~file is exported to a |
| 666 |
% PDF/EPS/PS/PNG~file (see~\opt{inkscapeformat}) and perhaps a correlating |
| 667 |
% \LaTeX~file (see~\opt{inkscapelatex}). The export with \app{Inkscape} is only |
| 668 |
% invoked, if the SVG~file is newer than the exported graphic~file or latter |
| 669 |
% doesn't exist at all. Once the export has been done, the graphic~file and |
| 670 |
% maybe the \LaTeX~file are included. |
| 671 |
% |
| 672 |
% All previously described options can also be used as optional parameters to |
| 673 |
% \cs{includesvg} and do have the same effect as described before. However, the |
| 674 |
% optional parameters specified have an effect only once when \cs{includesvg} |
| 675 |
% is executed and remain unchanged afterwards. |
| 676 |
% |
| 677 |
% \DescribeParameter{lastpage}^^A |
| 678 |
% In addition to the use of boolean values, the parameter \prm{lastpage} can |
| 679 |
% also be assigned a specific (integer) page number, which defines the last |
| 680 |
% used page of a PDF~graphic. This, just like the identically named option, has |
| 681 |
% an effect only when \prm{inkscapeformat}|=|\val{pdf} is set. |
| 682 |
% |
| 683 |
% \DescribeParameters{angle,origin}^^A |
| 684 |
% Both parameters correlate to the identically named parameters of the |
| 685 |
% \cs{includegraphics} command provided by the \pkg{graphicx} package. However, |
| 686 |
% unlike to \cs{includegraphics}, they \prm{angle} and \prm{origin} are |
| 687 |
% \emph{always evaluated after} \prm{widht}, \prm{height}, \prm{distort} and |
| 688 |
% \prm{scale} by \cs{includesvg}, regardless of the used order of the given |
| 689 |
% parameters. This is mainly due to the inclusion of the \LaTeX~files |
| 690 |
% corresponding to the graphic~files generated by \app{Inkscape}. |
| 691 |
% \end{DescribeParameterParent} |
| 692 |
% |
| 693 |
% |
| 694 |
% |
| 695 |
% \subsection{Including already exported SVG~files} |
| 696 |
% |
| 697 |
% \DescribeMacro{\includeinkscape}^^A |
| 698 |
% If you don't want to make use of the automated export with \app{Inkscape} but |
| 699 |
% the user\hbox{-}interface provided by the \pkg{svg} package, you can use |
| 700 |
% \cs{includeinkscape} instead of \cs{includesvg}. |
| 701 |
% \begin{svgexample} |
| 702 |
% \includeinkscape§\oarg{parameters}\marg{graphic~filename}§ |
| 703 |
% \end{svgexample} |
| 704 |
% |
| 705 |
% \begin{DescribeParameterParent}{Macro}{\includeinkscape}^^A |
| 706 |
% \DescribeParameters{inkscapeformat,inkscapelatex,width,height,distort,^^A |
| 707 |
% scale,pretex,apptex,draft,lastpage,angle,origin}^^A |
| 708 |
% You can use it similar to \cs{includesvg} but \meta{graphic~filename} has to |
| 709 |
% be the filename of the already exported graphic file. If a valid |
| 710 |
% file~extension (\file{.pdf/.eps/.ps/.png}) is given, the current setting for |
| 711 |
% \opt{inkscapeformat} is overwritten. It's even possible to specify a |
| 712 |
% file~extension like \file{.pdf\_tex} to activate \opt{inkscapelatex}. |
| 713 |
% Furthermore, all optional parameters for \cs{includeinkscape} do have the |
| 714 |
% same effect as described before for command \cs{includesvg} once when |
| 715 |
% \cs{includeinkscape} is executed and remain unchanged afterwards. |
| 716 |
% \end{DescribeParameterParent} |
| 717 |
% |
| 718 |
% |
| 719 |
% |
| 720 |
% \section{Usage of package \pkg{svg-extract}} |
| 721 |
% |
| 722 |
% This package allows the extraction of independent graphic~files out of |
| 723 |
% SVG~files which have been included and rendered with \LaTeX{} by the |
| 724 |
% \pkg{svg} package. This is particularly useful when attempting to provide |
| 725 |
% images to journals or collaborators, and one wishes the image to appear |
| 726 |
% exactly as it does within the original \LaTeX~document. |
| 727 |
% |
| 728 |
% In order to extract to PDF, EPS, or PS~files the programs \file{pstoeps}, |
| 729 |
% \file{pstopdf} and \file{pdftops} are used which are usually provided by most |
| 730 |
% of the \LaTeX~distributions. In addition, the command~line~interfaces of |
| 731 |
% \app{ImageMagick} and \app{Ghostscript} can be invoked for converting images |
| 732 |
% in formats like PNG, JPG, TIF or something else. It's also possible to create |
| 733 |
% PDF, EPS or PS~files with one of the two programs. Therefor the desired |
| 734 |
% program---\file{magick} and/or \file{gswin32c}/\file{gswin64c} on Windows |
| 735 |
% respectively \file{convert} and/or \file{gs} on unix-like operating |
| 736 |
% systems---must be installed. By typing \file{\meta{program}~-{}-version} on |
| 737 |
% shell, this can be checked. |
| 738 |
% |
| 739 |
% If you want to extract independent graphic~files from included SVG~files, you |
| 740 |
% only have to load \pkg{svg-extract}. All actions for the extraction process |
| 741 |
% will be done by using \cs{includesvg} or \cs{includeinkscape}. Without any |
| 742 |
% additional settings, the extraction will render the SVG~file to the specified |
| 743 |
% output formats(s) of choice using the same settings as specified within the |
| 744 |
% two commands. Consequently, the scale between the image and text in the |
| 745 |
% extracted files will remain identical to the scale within the document from |
| 746 |
% which the SVG~file was extracted. |
| 747 |
% |
| 748 |
% In contrast to package \pkg{svg}, the console commands for graphic extraction |
| 749 |
% are executed with each LaTeX run by package \pkg{svg-extract} when |
| 750 |
% \file{-{}-shell-escape} mode is activated. This behaviour can be switched off |
| 751 |
% with option \opt{extract}|=|\val{false}. |
| 752 |
% |
| 753 |
% \minisec{Important changes} |
| 754 |
% |
| 755 |
% In version~v1.0 of package \pkg{svg} the extracted files were named like the |
| 756 |
% numbering of the current \env{subfig} environment by default. As package |
| 757 |
% \pkg{subfig} sometime causes problems and because of the large amount of |
| 758 |
% different \LaTeX~packages which all provide the possibility to include |
| 759 |
% subfigures with very different implementations, this feature can't be provided |
| 760 |
% reliably by \pkg{svg-extract}. See option \opt{extractname} for further |
| 761 |
% information. |
| 762 |
% |
| 763 |
% |
| 764 |
% |
| 765 |
% \subsection{General settings} |
| 766 |
% |
| 767 |
% \DescribeOptions{on,off}^^A |
| 768 |
% This options have to be given while loading the \pkg{svg-extract} package and |
| 769 |
% are intended to toggle the functionality of this package. As both extracting |
| 770 |
% and converting independent graphic~files is invoked with every \LaTeX~run |
| 771 |
% when \file{-{}-shell-escape} is activated, the option \opt{off} can be given |
| 772 |
% to save compilation time, once the creation of all desired images has been |
| 773 |
% done and they no longer need to be re-generated. The option \opt{on} can be |
| 774 |
% used to reactivate functionality of this package. This can also be done by |
| 775 |
% using \opt{extract}|=|\val{true}/\val{false}. |
| 776 |
% |
| 777 |
% \DescribeMacros{\svgsetup,\includesvg,\includeinkscape}^^A |
| 778 |
% With package \pkg{svg-extract} the applicable options for |
| 779 |
% \cs{svgsetup}\marg{options} as well as parameters for the already described |
| 780 |
% macros \cs{includesvg}\oarg{parameters}\marg{svg~filename} and |
| 781 |
% \cs{includeinkscape}\oarg{parameters}\marg{graphic~filename} are extended. |
| 782 |
% They can be used to control the process of graphic extraction and converting. |
| 783 |
% |
| 784 |
% All options described below can be passed to \cs{svgsetup}\marg{options} and |
| 785 |
% are then valid in the current scope. There also exist identically named |
| 786 |
% parameters for the optional arguments of |
| 787 |
% \begin{svgexample} |
| 788 |
% \includesvg§\oarg{parameters}\marg{svg~filename}§ |
| 789 |
% \includeinkscape§\oarg{parameters}\marg{graphic~filename}§ |
| 790 |
% \end{svgexample} |
| 791 |
% These have an effect only once, when the specific command is executed. |
| 792 |
%^^A \begingroup^^A |
| 793 |
%^^A \newcommand*\parameterlist{}^^A |
| 794 |
%^^A \listadd\parameterlist{extract}^^A |
| 795 |
%^^A \listadd\parameterlist{extractpreamble}^^A |
| 796 |
%^^A \listadd\parameterlist{extractformat}^^A |
| 797 |
%^^A \listadd\parameterlist{extractwidth}^^A |
| 798 |
%^^A \listadd\parameterlist{extractheight}^^A |
| 799 |
%^^A \listadd\parameterlist{extractdistort}^^A |
| 800 |
%^^A \listadd\parameterlist{extractscale}^^A |
| 801 |
%^^A \listadd\parameterlist{extractangle}^^A |
| 802 |
%^^A \listadd\parameterlist{extractpretex}^^A |
| 803 |
%^^A \listadd\parameterlist{extractapptex}^^A |
| 804 |
%^^A \listadd\parameterlist{extractruns}^^A |
| 805 |
%^^A \listadd\parameterlist{latexexe}^^A |
| 806 |
%^^A \listadd\parameterlist{latexopt}^^A |
| 807 |
%^^A \listadd\parameterlist{latexext}^^A |
| 808 |
%^^A \listadd\parameterlist{dvipsopt}^^A |
| 809 |
%^^A \listadd\parameterlist{pstoepsopt}^^A |
| 810 |
%^^A \listadd\parameterlist{pstopdfopt}^^A |
| 811 |
%^^A \listadd\parameterlist{pdftoepsopt}^^A |
| 812 |
%^^A \listadd\parameterlist{pdftopsopt}^^A |
| 813 |
%^^A \listadd\parameterlist{convert}^^A |
| 814 |
%^^A \listadd\parameterlist{convertformat}^^A |
| 815 |
%^^A \listadd\parameterlist{convertdpi}^^A |
| 816 |
%^^A \listadd\parameterlist{magicksetting}^^A |
| 817 |
%^^A \listadd\parameterlist{magickoperator}^^A |
| 818 |
%^^A \listadd\parameterlist{gsopt}^^A |
| 819 |
%^^A \listadd\parameterlist{gsdevice}^^A |
| 820 |
%^^A \listadd\parameterlist{clean}^^A |
| 821 |
%^^A \listadd\parameterlist{exclude}^^A |
| 822 |
%^^A \def\buffer{}\def\do#1{\buffer\prm{#1}\def\buffer{, }}^^A |
| 823 |
%^^A These parameters are: \dolistloop{\parameterlist}. |
| 824 |
%^^A \renewcommand*\marginpar[2][]{}^^A |
| 825 |
%^^A \def\do#1{\DescribeParameter{#1}}^^A |
| 826 |
%^^A \begin{DescribeParameterParent}{Macro}{\includesvg}^^A |
| 827 |
%^^A \dolistloop{\parameterlist}^^A |
| 828 |
%^^A \end{DescribeParameterParent}^^A |
| 829 |
%^^A \begin{DescribeParameterParent}{Macro}{\includeinkscape}^^A |
| 830 |
%^^A \dolistloop{\parameterlist}^^A |
| 831 |
%^^A \end{DescribeParameterParent}^^A |
| 832 |
%^^A \endgroup^^A |
| 833 |
% |
| 834 |
% |
| 835 |
% |
| 836 |
% \subsection{Extract independent graphic files\label{sec:extract}} |
| 837 |
% |
| 838 |
% \DescribeOption{extract}^^A |
| 839 |
% This option can be used with boolean values. Using \opt{extract}|=|\val{true} |
| 840 |
% activates the functionality for both extracting and converting which is the |
| 841 |
% default setting, whereas \opt{extract}|=|\val{false} turns it off completely. |
| 842 |
% |
| 843 |
% \DescribeOption{extractpath}^^A |
| 844 |
% The path where the extracted and converted files are located can be specified |
| 845 |
% with option \opt{extractpath}, whereas \default{basesubdir} is set by default. |
| 846 |
% \begin{DescribeValues}^^A |
| 847 |
% \item[svgdir/svgpath] |
| 848 |
% The extracted and converted independent graphic~files are located in the |
| 849 |
% same directory as the corresponding SVG~file. |
| 850 |
% \item[svgsubdir/svgsubpath] |
| 851 |
% Within the folder of the encountered SVG~file, all extracted and converted |
| 852 |
% files will be located in a subfolder named \file{svg-extract/}. |
| 853 |
% \item[basedir/basepath/jobdir/jobpath] |
| 854 |
% All extracted and converted files will be located in the current working |
| 855 |
% directory. |
| 856 |
% \item[\default{basesubdir}/basesubpath/jobsubdir/jobsubpath] |
| 857 |
% A subfolder named \file{svg-extract/} within the current working directory |
| 858 |
% will be used for all extracted and converted files. |
| 859 |
% \item[/path/to/somewhere/] |
| 860 |
% It is also possible to give a custom path, either relative to the current |
| 861 |
% working directory (\file{./relative/path/}) or as an absolute path. |
| 862 |
% \end{DescribeValues} |
| 863 |
% |
| 864 |
% \DescribeOption{extractname}^^A |
| 865 |
% It's also possible to change the name for extracted and converted files. The |
| 866 |
% default setting is \opt{extractname}|=|\val{filenamenumbered}. The appended |
| 867 |
% file extension is derived from option \opt{extractformat}. |
| 868 |
% \begin{DescribeValues}^^A |
| 869 |
% \item[filename/name] |
| 870 |
% The name of the exported \app{Inkscape}~file is used and the suffix |
| 871 |
% \file{-extract} is attached. |
| 872 |
% \item[\default{filenamenumbered}/namenumbered/numberedfilename/numberedname] |
| 873 |
% Same as above, but a prefix with the current enumerated count of SVG~files |
| 874 |
% is used instead of the suffix. |
| 875 |
% \item[numbered/section/numberedsection/sectionnumbered] |
| 876 |
% The file~name is composed by the current enumerated count of SVG~files and |
| 877 |
% the present outline numbering. |
| 878 |
% \item[\file{\meta{filename}}] |
| 879 |
% You can use any file~name. It's possible to use counters for specifying the |
| 880 |
% name of the extracted file. Repeatedly specifying the same file~name will |
| 881 |
% overwrite previously created files. |
| 882 |
% \end{DescribeValues} |
| 883 |
% |
| 884 |
% \DescribeOption{extractformat}^^A |
| 885 |
% The included SVG~file can be extracted from the document into an independent |
| 886 |
% graphic~file of type PDF, EPS or PS. The option can be used with either a |
| 887 |
% single value (\opt{extractformat}|=|\val{pdf}) or a comma separated list. |
| 888 |
% For example, |
| 889 |
% \begin{svgexample} |
| 890 |
% \includesvg[extractformat={pdf,eps,ps}]§\marg{svg~filename}§ |
| 891 |
% \end{svgexample} |
| 892 |
% will extract the SVG~file to both PDF and EPS~formats and generates two |
| 893 |
% independent graphic~files. By default, \opt{extractformat}|=|\val{pdf} is set |
| 894 |
% unless DVI~output was detected. In this case \opt{extractformat}|=|\val{eps} |
| 895 |
% is the default setting. |
| 896 |
% |
| 897 |
% \DescribeOptions{extractwidth,extractheight,extractdistort,extractscale,^^A |
| 898 |
% extractpretex,extractapptex}^^A |
| 899 |
% \changes{v2.02}{2018/09/07}{option \opt{extractdistort} added for distortion |
| 900 |
% of extracted graphics}^^A |
| 901 |
% These options can be used to overwrite the settings given for the appearance |
| 902 |
% of a SVG~file within the document. For example, a SVG~file should cover the |
| 903 |
% entire text width within the document but be extracted to a fixed width. This |
| 904 |
% can be done with: |
| 905 |
% \begin{svgexample} |
| 906 |
% \includesvg[width=\textwidth,extractwidth=500pt]§\marg{svg~filename}§ |
| 907 |
% \end{svgexample} |
| 908 |
% Assigning the value \val{inherit} to one of these options---which is set by |
| 909 |
% default---leads to the usage of the corresponding option of package \pkg{svg} |
| 910 |
% (\opt{width}/\opt{height}/\opt{scale}/\opt{pretex}/\opt{apptex}), whereas |
| 911 |
% \opt{extract\dots}|=|\val{\cs{relax}} can be used to ignore a parent option |
| 912 |
% utterly. |
| 913 |
% |
| 914 |
% \DescribeOptions{extractpreamble,extractpreambleend}^^A |
| 915 |
% Within the included and extracted SVG~files any \LaTeX~macro can be used |
| 916 |
% either defined by the user---this should be done in the preamble of the |
| 917 |
% \LaTeX~document in which the SVG~file is to be included---or provided by a |
| 918 |
% package which is loaded. As the extraction process of the SVG~files needs an |
| 919 |
% auxiliary \LaTeX~file all used packages and commands have to be known within |
| 920 |
% this file. Consequently, the preamble of the current \LaTeX~document is used |
| 921 |
% for the extraction of the SVG~file by default. |
| 922 |
% |
| 923 |
% However, it is possible to specify a different \emph{preamble~file} with the |
| 924 |
% option \opt{extractpreamble} where the file to use as the preamble is given |
| 925 |
% as the argument---including maybe path, but file~name and file~extension in |
| 926 |
% any case. The given preamble file is searched similar to SVG~files meaning, |
| 927 |
% every path given with \cs{svgpath} or \cs{graphicspath} is examined. The |
| 928 |
% default definition of \opt{extractpreamble} is \file{\cs{jobname}.tex}---more |
| 929 |
% precisely the file~extension given by option \opt{latexext} is used---and |
| 930 |
% should suffice for most cases. The preamble up to the line defined by the |
| 931 |
% option \opt{extractpreambleend} will be used, which is set to a default with |
| 932 |
% \cs{begin}|{document}|. |
| 933 |
% |
| 934 |
% \DescribeMacros{\svghidepreamblestart,\svghidepreambleend}^^A |
| 935 |
% In case, the preamble of the current \LaTeX~document is used, there are maybe |
| 936 |
% packages included or some parts within the preamble, which should not be used |
| 937 |
% within the separate auxiliary \LaTeX~file. These parts can be excluded if |
| 938 |
% they are enclosed by \cs{svghidepreamblestart} and \cs{svghidepreambleend}. |
| 939 |
% |
| 940 |
% For example, your current \LaTeX~document uses package \pkg{showframe} which |
| 941 |
% causes some problems with the extraction of independent graphic~files. So you |
| 942 |
% want to get rid of it within the auxiliary \LaTeX~file. This can be done with: |
| 943 |
% \begin{svgexample} |
| 944 |
% \documentclass§\marg{documentclassname}§ |
| 945 |
% §\dots§ |
| 946 |
% \usepackage{svg-extract} |
| 947 |
% §\dots§ |
| 948 |
% \svghidepreamblestart |
| 949 |
% \usepackage{showframe} |
| 950 |
% \svghidepreambleend |
| 951 |
% §\dots§ |
| 952 |
% \end{svgexample} |
| 953 |
% |
| 954 |
% \DescribeOption{extractruns}^^A |
| 955 |
% When extracting independent graphic~files by compiling the generated auxiliary |
| 956 |
% \LaTeX~file, it's maybe necessary to do multiple \LaTeX~iterations on this. |
| 957 |
% The number of iterations is controlled with option \opt{extractruns}. It is |
| 958 |
% set to \opt{extractruns}|=|\val{2} by default. |
| 959 |
% |
| 960 |
% \DescribeOptions{latexexe,latexopt,latexext}^^A |
| 961 |
% For the extraction of an independent graphic~file, the \LaTeX~program is used |
| 962 |
% which is set by the \opt{latexexe} option. Depending on the \LaTeX~engine |
| 963 |
% used for the current \LaTeX~document, it is set to either \app{pdflatex}, |
| 964 |
% \app{lualatex}, \app{xelatex} or \app{latex} by default. It's also possible |
| 965 |
% to specify additional flags or switches for the \LaTeX~iterations, which are |
| 966 |
% performed during the extraction process by the \opt{latexopt} option. If you |
| 967 |
% are used to utilize a different extension for \LaTeX~files than \file{.tex}, |
| 968 |
% option \opt{latexext} can be used like \opt{latexext}|=|\val{ltx}. |
| 969 |
% |
| 970 |
% \DescribeOptions{dvipsopt,pstoepsopt,pstopdfopt,pdftoepsopt,pdftopsopt}^^A |
| 971 |
% Depending on the used \LaTeX~engine, the file~type of the extracted |
| 972 |
% graphic differs. In order to create all formats, requested with option |
| 973 |
% \opt{extractformat}, several converting tools provided by most of the |
| 974 |
% \LaTeX~distributions are maybe invoked. These are \file{dvips}, |
| 975 |
% \file{ps2eps}, \file{ps2pdf} and/or \file{pdftops} and can't be changed. It's |
| 976 |
% only possible to specify additional switches for every single tool with |
| 977 |
% \opt{dvipsopt}, \opt{pstoepsopt}, \opt{pstopdfopt}, \opt{pdftoepsopt} and |
| 978 |
% \opt{pdftopsopt}. |
| 979 |
% |
| 980 |
% \DescribeOption{clean}^^A |
| 981 |
% During the extraction process many files are generated for each SVG~file |
| 982 |
% extraction. So it's oftentimes desirable to automatically remove these |
| 983 |
% temporary files. Using the option \opt{clean}|=|\val{true} will remove any |
| 984 |
% generated files created other than the extracted output format(s) requested. |
| 985 |
% Setting \opt{clean}|=|\val{false} is useful for debugging and set by default. |
| 986 |
% Additionally, it's possible to use option \opt{clean} with a list of |
| 987 |
% file~extensions in order to specify auxiliary files generated by package |
| 988 |
% \pkg{svg-extract} to be deleted, for example \opt{clean}|=|\val{\{log,aux\}}. |
| 989 |
% |
| 990 |
% \DescribeOption{exclude}^^A |
| 991 |
% Sometimes it may be necessary to extract and/or convert a SVG~file without |
| 992 |
% including it. If the flag \opt{exclude} is specified, the SVG~file will not |
| 993 |
% be rendered in the current \LaTeX~document, but will be extracted and/or |
| 994 |
% converted to the requested output format(s). |
| 995 |
% |
| 996 |
% \DescribeMacros{\includesvg,\includeinkscape}^^A |
| 997 |
% As previously mentioned, for extracting independent graphic files it is |
| 998 |
% sufficient to load package \pkg{svg-extract} and afterwards everything |
| 999 |
% necessary is done by just using \cs{includesvg} or \cs{includeinkscape}. |
| 1000 |
% |
| 1001 |
% \begin{DescribeParameterParent}{Macro}{\includesvg}^^A |
| 1002 |
% \DescribeParameter{extractangle}^^A |
| 1003 |
% \begin{DescribeParameterParent}{Macro}{\includeinkscape}^^A |
| 1004 |
% \renewcommand*\marginpar[2][]{}^^A |
| 1005 |
% \DescribeParameter{extractangle}^^A |
| 1006 |
% \changes{v2.02}{2018/09/07}{parameter \prm{extractangle} for \cs{includesvg} |
| 1007 |
% and \cs{includeinkscape} implemented in order to rotate graphics during |
| 1008 |
% extractions}^^A |
| 1009 |
% With this additional parameter the graphic is rotated during the extraction |
| 1010 |
% process. The value is not inherited from \prm{angle} if it was given by |
| 1011 |
% default. This can be achieved by setting: |
| 1012 |
% \begin{svgexample} |
| 1013 |
% \includesvg[angle=§\meta{angle}§,extractangle=inherit]§\marg{svg~filename}§ |
| 1014 |
% \end{svgexample} |
| 1015 |
% \end{DescribeParameterParent} |
| 1016 |
% \end{DescribeParameterParent} |
| 1017 |
% |
| 1018 |
% |
| 1019 |
% |
| 1020 |
% \subsection{Convert extracted graphic files\label{sec:convert}} |
| 1021 |
% |
| 1022 |
% Based on the extraction of independent graphic~files, the \pkg{svg-extract} |
| 1023 |
% packages also provides the possibility to convert these extracted graphics in |
| 1024 |
% another format than PDF, EPS or PS with either \app{ImageMagick}---which is |
| 1025 |
% set by default---or \app{Ghostscript}. |
| 1026 |
% |
| 1027 |
% \DescribeOption{convert}^^A |
| 1028 |
% This option can be used to control the invocation of the conversion process. |
| 1029 |
% By default, \opt{convert}|=|\val{false} is set. For Windows, there exist two |
| 1030 |
% different versions of \app{Ghostscript}, either 64\,bit or 32\,bit. If |
| 1031 |
% it is selected as converting tool the 64\,bit~executable is set by default. |
| 1032 |
% Please note, that option \opt{extract} has to be activated. |
| 1033 |
% \begin{DescribeValues}^^A |
| 1034 |
% \item[\default{false}/off/no] |
| 1035 |
% No conversion is done. |
| 1036 |
% \item[true/on/yes] |
| 1037 |
% The conversion will be done with the current chosen converting tool. |
| 1038 |
% \item[magick/imagemagick/convert] |
| 1039 |
% The conversion is activated and \app{ImageMagick} is selected. |
| 1040 |
% \item[gs/ghostscript] |
| 1041 |
% The conversion is activated and \app{Ghostscript} is selected. |
| 1042 |
% \item[gs64/ghostscript64] |
| 1043 |
% This value activates \app{Ghostscript} as conversion tool and sets |
| 1044 |
% \opt{gsexe}|=|\val{gswin64c}. On unix-like operating systems, the value for |
| 1045 |
% \opt{gsexe} remains unchanged. |
| 1046 |
% \item[gs32/ghostscript32] |
| 1047 |
% The same as for the latter case applies, only option |
| 1048 |
% \opt{gsexe}|=|\val{gswin32c} is set on Windows. |
| 1049 |
% \end{DescribeValues} |
| 1050 |
% |
| 1051 |
% \DescribeOption{convertformat}^^A |
| 1052 |
% With this option, the desired output format(s) can be given. Multiple graphic |
| 1053 |
% formats can be specified in a list, for example something like |
| 1054 |
% \opt{convertformat}|=|\val{\{png,jpg,tif\}}. The value specified in |
| 1055 |
% \opt{extractformat} is used as the source format for the conversion. If |
| 1056 |
% \opt{extractformat} itself contains a file~list, the first value within this |
| 1057 |
% list is considered. If \opt{extractformat} is defined empty, the file |
| 1058 |
% generated anyway during the extraction is used. |
| 1059 |
% |
| 1060 |
% \minisec{Settings for specific converting formats} |
| 1061 |
% |
| 1062 |
% Maybe it's desired to apply varying settings for different output formats. |
| 1063 |
% Therefor some options described below can either be set for all converted |
| 1064 |
% files or for a specific output format. In particular, these are the options |
| 1065 |
% \opt{convertdpi} as well as \opt{magicksetting}, \opt{magickoperator}, |
| 1066 |
% \opt{gsdevice} and \opt{gsopt}. All these mentioned options can be used like |
| 1067 |
% either \opt{\meta{option}}|=|\val{\meta{value}} or |
| 1068 |
% \opt{\meta{option}}|=|\val{\{\meta{outputformat}=\meta{value}\}} and even |
| 1069 |
% \opt{\meta{option}}|=|\val{\{\meta{outputformat}+=\meta{value}\}} where the |
| 1070 |
% desired output~format is trailed with |+| as inner key. |
| 1071 |
% |
| 1072 |
% The first variant is applied to all output formats in general. If one of |
| 1073 |
% these mentioned options is evaluated and an output format specific value was |
| 1074 |
% given like in the second variant, the general setting is overwritten. If the |
| 1075 |
% general setting should be used and extended by an additional output format |
| 1076 |
% specific settings, then the third variant is to be used. In this case, no |
| 1077 |
% output format specific setting (second variant) must not have been used. |
| 1078 |
% |
| 1079 |
% If you want to reverse any setting, you only have to use \cs{relax} as a |
| 1080 |
% value, either for a general option (\opt{\meta{option}}|=|\val{\cs{relax}}) |
| 1081 |
% or a specific one |
| 1082 |
% (\opt{\meta{option}}|=|\val{\{\meta{outputformat}[+]=\cs{relax}\}}). |
| 1083 |
% |
| 1084 |
% \DescribeOption{convertdpi}^^A |
| 1085 |
% This option controls the used density for all file~formats or a specific one, |
| 1086 |
% whether \app{ImageMagick} or \app{Ghostscript} is used for the graphic |
| 1087 |
% conversion. The desired resolution of the converted file is given in dots per |
| 1088 |
% inch~(DPI) either as a scalar value (e.g.~\opt{convertdpi}|=|\val{600}) or |
| 1089 |
% with different resolutions in x- and y\hbox{-}direction |
| 1090 |
% (e.g.~\opt{convertdpi}|=|\val{600x400}). |
| 1091 |
% |
| 1092 |
% As described before, it's also possible to declare a specific resolution for |
| 1093 |
% each desired converting format. For example, you want to set different |
| 1094 |
% resolution for PNG and JPG~formats and something for all other formats: |
| 1095 |
% \begin{svgexample} |
| 1096 |
% \svgsetup{% |
| 1097 |
% convertdpi={png=600},% |
| 1098 |
% convertdpi={jpg=150},% |
| 1099 |
% convertdpi=300% |
| 1100 |
% }% |
| 1101 |
% \end{svgexample} |
| 1102 |
% If a setting for a specific output format is given, any unspecific setting is |
| 1103 |
% overwritten, when the conversion to this format is done. With |
| 1104 |
% \opt{convertdpi}|=|\val{\{\meta{outputformat}=\cs{relax}\}} a specific |
| 1105 |
% setting can be reversed. |
| 1106 |
% |
| 1107 |
% Please note that not every graphic format support different resolutions in x- |
| 1108 |
% and y\hbox{-}direction. So using a value like \opt{convertdpi}|=|\val{600x400} |
| 1109 |
% may not necessarily lead to the desired result. However, this is then due to |
| 1110 |
% the used conversion tool and not to the processing of the option. |
| 1111 |
% |
| 1112 |
% |
| 1113 |
% |
| 1114 |
% \subsubsection{Settings for the invocation of \app{ImageMagick}} |
| 1115 |
% |
| 1116 |
% \DescribeOptions{magickexe,magicksetting,magickoperator}^^A |
| 1117 |
% The conversion with \app{ImageMagick} via the \file{magick} or \file{convert} |
| 1118 |
% command~line~interface can be controlled with these options. The option |
| 1119 |
% \opt{magickexe} determines the used executable and is set to \file{magick} on |
| 1120 |
% Windows and otherwise to \file{convert} by default. Additionally, there are |
| 1121 |
% the two options \opt{magicksetting} and \opt{magickoperator} which can be |
| 1122 |
% used to define \emph{settings} and \emph{operators} for the conversion |
| 1123 |
% process. As described before, the two options \opt{magicksetting} and |
| 1124 |
% \opt{magickoperator} can be set for all output formats or a \emph{specific} |
| 1125 |
% one either resetting or extending the general settings. For further |
| 1126 |
% information see the documentation of |
| 1127 |
% \hrfn{http://www.imagemagick.org/script/command-line-processing.php}^^A |
| 1128 |
% {\app{ImageMagick} command~line~interface}. |
| 1129 |
% |
| 1130 |
% |
| 1131 |
% |
| 1132 |
% \subsubsection{Settings for the invocation of \app{Ghostscript}} |
| 1133 |
% |
| 1134 |
% \DescribeOptions{gsexe,gsdevice,gsopt}^^A |
| 1135 |
% The conversion with \app{Ghostscript} is done with command~line~interface |
| 1136 |
% \file{gswin64c} or \file{gswin32c} on Windows and \file{gs} on unix-like |
| 1137 |
% operating systems. The executable can be changed with option \opt{gsexe}. |
| 1138 |
% Because \app{Ghostscript} requires the specification of a device, there are |
| 1139 |
% some predefined for the most common output formats. These are: |
| 1140 |
% \begin{svgexample} |
| 1141 |
% \svgsetup{% |
| 1142 |
% gsdevice={png=png16m},gsdevice={jpeg=jpeg},gsdevice={jpg=jpeg},% |
| 1143 |
% gsdevice={tif=tiff48nc},gsdevice={tiff=tiff48nc},% |
| 1144 |
% gsdevice={eps=eps2write},gsdevice={ps=ps2write}% |
| 1145 |
% }% |
| 1146 |
% \end{svgexample} |
| 1147 |
% Furthermore, with \opt{gsopt} additional switches for \app{Ghostscript} can |
| 1148 |
% be set. As described before, both \opt{gsdevice} and \opt{gsopt} can be |
| 1149 |
% defined in general or for specific output formats. For further information |
| 1150 |
% see the documentation of |
| 1151 |
% \hrfn{https://ghostscript.com/doc/current/Use.htm}{\app{Ghostscript}}. |
| 1152 |
% |
| 1153 |
% |
| 1154 |
% |
| 1155 |
% \cleardoublepage |
| 1156 |
% \section{Example} |
| 1157 |
% |
| 1158 |
% As an minimal example\footnote{The image used here is a slightly modified |
| 1159 |
% version of the image used in the initial documentation on how to include a |
| 1160 |
% SVG~file in \LaTeX{} by Johan\,B.\,C.~Engelen available as package |
| 1161 |
% \href{http://www.ctan.org/pkg/svg-inkscape}{\pkg{svg-inkscape} on CTAN}.} |
| 1162 |
% take the following lines of code: |
| 1163 |
% \begin{svgexample} |
| 1164 |
% \documentclass{article} |
| 1165 |
% \usepackage[T1]{fontenc} |
| 1166 |
% \usepackage{svg} |
| 1167 |
% \usepackage[off]{svg-extract} |
| 1168 |
% \svgsetup{clean=true} |
| 1169 |
% %\pdfsuppresswarningpagegroup=1 |
| 1170 |
% \usepackage{relsize} |
| 1171 |
% \usepackage{subcaption} |
| 1172 |
% \begin{document} |
| 1173 |
% \begin{figure} |
| 1174 |
% \begin{minipage}{\dimexpr\linewidth/2\relax} |
| 1175 |
% \includesvg[width=\linewidth]{svg-example}% |
| 1176 |
% \subcaption{This text is too large!}% |
| 1177 |
% \end{minipage}% |
| 1178 |
% \begin{minipage}{\dimexpr\linewidth/2\relax} |
| 1179 |
% \includesvg[width=\linewidth,pretex=\relscale{0.6}]{svg-example}% |
| 1180 |
% \subcaption{This text fits better.}% |
| 1181 |
% \end{minipage} |
| 1182 |
% \caption{An example figure with \LaTeX~support\label{fig:example}}% |
| 1183 |
% \end{figure} |
| 1184 |
% \begin{figure}\centering |
| 1185 |
% \includesvg[% |
| 1186 |
% width=.5\linewidth,inkscapelatex=false,extractformat={pdf,eps}% |
| 1187 |
% ]{svg-example}% |
| 1188 |
% \caption{The same example figure without \LaTeX~support}% |
| 1189 |
% \end{figure} |
| 1190 |
% \end{document} |
| 1191 |
% \end{svgexample} |
| 1192 |
% \begin{figure}[tb] |
| 1193 |
% \null\hfill^^A |
| 1194 |
% \begin{minipage}{\dimexpr\linewidth*9/20\relax} |
| 1195 |
% \includesvg[width=\linewidth]{svg-example}^^A |
| 1196 |
% \subcaption{This text is too large!\label{fig:example-tex-a}}^^A |
| 1197 |
% \end{minipage}\hfill^^A |
| 1198 |
% \begin{minipage}{\dimexpr\linewidth*9/20\relax} |
| 1199 |
% \includesvg[width=\linewidth,pretex=\relscale{0.6}]{svg-example}^^A |
| 1200 |
% \subcaption{This text fits better.\label{fig:example-tex-b}}^^A |
| 1201 |
% \end{minipage} |
| 1202 |
% \hfill\null^^A |
| 1203 |
% \caption{An example figure with \LaTeX~support\label{fig:example-tex}}^^A |
| 1204 |
% \end{figure} |
| 1205 |
% \begin{figure}[tb]\centering |
| 1206 |
% \includesvg[^^A |
| 1207 |
% width=.5\linewidth,inkscapelatex=false,extractformat={pdf,eps}^^A |
| 1208 |
% ]{svg-example}^^A |
| 1209 |
% \caption{^^A |
| 1210 |
% The same example figure without \LaTeX~support\label{fig:example}^^A |
| 1211 |
% }^^A |
| 1212 |
% \end{figure} |
| 1213 |
% |
| 1214 |
% The output is shown in \autoref{fig:example-tex} and \autoref{fig:example}. |
| 1215 |
% Within this example the file \file{svg-example.svg} was included three times |
| 1216 |
% using the \cs{includesvg} command. |
| 1217 |
% |
| 1218 |
% If you are willing to compile the example, there are two aspects to consider. |
| 1219 |
% First, the included SVG~file \file{svg-example.svg} has to be located in the |
| 1220 |
% current folder and is located in \file{\meta{texmf}/doc/latex/svg/}. Second, |
| 1221 |
% you have to run the desired \LaTeX~engine with flag \file{-{}-shell-escape}. |
| 1222 |
% |
| 1223 |
% As you can see, \autoref{fig:example-tex-a} is created with default settings, |
| 1224 |
% except the width specification. The \app{Inkscape}~export with \LaTeX~support |
| 1225 |
% is done and the extraction of an independent graphic~file in PDF~format as |
| 1226 |
% the \pkg{svg-extract} package was loaded. |
| 1227 |
% |
| 1228 |
% However, the text is slightly overrunning the margins of the image, and so |
| 1229 |
% \autoref{fig:example-tex-b}---which again uses the same \app{Inkscape}~export |
| 1230 |
% results---decreases the font size of the text within the image relative |
| 1231 |
% using the \prm{pretex} option together with the \cs{relscale} command |
| 1232 |
% provided by the \pkg{relsize} package. |
| 1233 |
% |
| 1234 |
% In \autoref{fig:example} the same SVG~file was used but without the export |
| 1235 |
% of a separate \LaTeX~file containing all text elements. |
| 1236 |
% |
| 1237 |
% Feel free to use this given example to try out all the options and |
| 1238 |
% possibilities described in \autoref{sec:inkscape} for package \pkg{svg}. |
| 1239 |
% Especially if you want to use package \pkg{svg-extract} for the automated |
| 1240 |
% extraction of independent graphics (\autoref{sec:extract}) and their |
| 1241 |
% conversion to different graphic formats with \app{ImageMagick} and/or |
| 1242 |
% \app{Ghostscript} (\autoref{sec:convert}), this example can be easily used |
| 1243 |
% for the first steps. |
| 1244 |
% |
| 1245 |
% |
| 1246 |
% |
| 1247 |
% \section{Troubleshooting and reporting issues} |
| 1248 |
% |
| 1249 |
% When using the packages \pkg{svg} and \pkg{svg-extract}, the most likely |
| 1250 |
% occurring problems will be caused by calling the external programs. For this |
| 1251 |
% reason, a short package information is written into the log~file right before |
| 1252 |
% each call of an external program on shell. If a file should have been |
| 1253 |
% created, both packages check after the external call, whether this file |
| 1254 |
% exists or not and raise an error or at least a warning, if this file is |
| 1255 |
% missing. If you got such a message, please check the log~file for lines like: |
| 1256 |
% \begin{quote} |
| 1257 |
% |Package svg Info:| or |Package svg-extract Info:| |
| 1258 |
% \end{quote} |
| 1259 |
% Right afterwards, there should appear |runsystem(<command>)...excuted.| which |
| 1260 |
% you should try to execute manually at the terminal in the right directory. In |
| 1261 |
% most cases, the problem will be an invalid command call. If something goes |
| 1262 |
% wrong during the extraction/converting process of package \pkg{svg-extract}, |
| 1263 |
% it would make sense to set option \opt{clean}|=|\val{false} to not delete any |
| 1264 |
% auxiliary files that might be needed. |
| 1265 |
% |
| 1266 |
% If you are sure that the problem is not caused by the configuration of your |
| 1267 |
% operating system, you can send an error report either via email or create a |
| 1268 |
% new issue on GitHub. Both addresses can be found on the title. |
| 1269 |
% |
| 1270 |
% \minisec{When using pdf\LaTeX{} there are a lot of warnings} |
| 1271 |
% |
| 1272 |
% It may happen that several warnings like |
| 1273 |
% \begin{quote}\ttfamily\raggedright^^A |
| 1274 |
% pdfTeX warning:\,pdflatex.exe(file \meta{filename}.pdf):\,PDF inclusion: |
| 1275 |
% multiple pdfs with page group included in a single page^^A |
| 1276 |
% \end{quote} |
| 1277 |
% occur when including the PDF~graphics exported with \app{Inkscape}. This is |
| 1278 |
% related to the handling of transparency effects within PDF~files. Since |
| 1279 |
% pdf\TeX~version 1.40.15 or later, you can get rid of these messages by using |
| 1280 |
% \cs{pdfsuppresswarningpagegroup}|=|\val{1}. See also the discussion on |
| 1281 |
% \hrfn{http://tex.stackexchange.com/questions/76273/}{LaTeX Stack Exchange} |
| 1282 |
% for more information. |
| 1283 |
% |
| 1284 |
% |
| 1285 |
% |
| 1286 |
% \section{Include SVG files created with \app{ROOT}} |
| 1287 |
% |
| 1288 |
% This section was originally written by Philip Ilten. In the hope that since |
| 1289 |
% then nothing has changed fundamentally in the described procedure. This |
| 1290 |
% passage remains in the documentation, even if it will almost certainly be |
| 1291 |
% relevant to experimental particle physicists only, who frequently use the |
| 1292 |
% analysis package \app{ROOT}. |
| 1293 |
% |
| 1294 |
% \app{ROOT} has the ability to export directly to a SVG~file, which means that |
| 1295 |
% it is possible to completely by-pass all of \app{ROOT}'s internal text |
| 1296 |
% rendering machinery, and let \LaTeX{} handle the text natively. This means |
| 1297 |
% that all of the ugly fonts that are rendered by \app{ROOT} can now be |
| 1298 |
% completely avoided, with the additional bonus of being able to add references |
| 1299 |
% within plots. So how does one go about using this package with \app{ROOT}? |
| 1300 |
% \begin{enumerate} |
| 1301 |
% \item |
| 1302 |
% Create the plot with \app{ROOT} as normal, but turn off all |
| 1303 |
% \LaTeX~interpretation of text strings. This is a bit tricky, but can be |
| 1304 |
% accomplished by setting the font in \app{ROOT} to a precision of zero as |
| 1305 |
% described in the documentation for |
| 1306 |
% \hrfn{http://root.cern.ch/root/html/TAttText.html}{\texttt{TAttFill}}. |
| 1307 |
% Remember that the font is set by using the function |
| 1308 |
% |(TAttFill*)->SetTextFont(i)| with |
| 1309 |
% \[\texttt{i}=\textrm{(font type)} \times 10 + \textrm{(font precision)}\] |
| 1310 |
% In the following lines of code, a |TStyle| is defined which sets the font |
| 1311 |
% to type ``Courier New'' with a precision of zero. |
| 1312 |
% \begin{svgexample}[backgroundcolor=\color{red!10}] |
| 1313 |
% TStyle *style = new TStyle("style","style"); int FONT = 80; |
| 1314 |
% style->SetTextFont(FONT); |
| 1315 |
% style->SetLabelFont(FONT,"XYZ"); |
| 1316 |
% style->SetTitleFont(FONT,"XYZ"); |
| 1317 |
% style->SetTitleFont(FONT,""); |
| 1318 |
% gROOT->SetStyle("style"); |
| 1319 |
% gROOT->ForceStyle(); |
| 1320 |
% \end{svgexample} |
| 1321 |
% Now, you can just use the well\hbox{-}known standard \LaTeX~syntax for |
| 1322 |
% creating labels, etc. Note however, that backslashes have to be escaped due |
| 1323 |
% to interpretation of special characters by \app{C++}. |
| 1324 |
% \item Print the plot as a SVG~file. |
| 1325 |
% \begin{svgexample}[backgroundcolor=\color{red!10}] |
| 1326 |
% gPad->Print("foo.svg"); |
| 1327 |
% \end{svgexample} |
| 1328 |
% \item Include the SVG~file within the document using this package. |
| 1329 |
% \begin{svgexample} |
| 1330 |
% \usepackage{svg} |
| 1331 |
% \usepackage{svg-extract} |
| 1332 |
% \svgsetup{clean=true} |
| 1333 |
% §\dots§ |
| 1334 |
% \includesvg[width=\linewidth]{foo} |
| 1335 |
% \end{svgexample} |
| 1336 |
% \end{enumerate} |
| 1337 |
% |
| 1338 |
% Consider the following example image produced by \app{ROOT} in |
| 1339 |
% \autoref{fig:root}. This figure was generated by the \app{ROOT} macro |
| 1340 |
% \file{root.C}, provided within \file{\meta{texmf}/doc/latex/svg/}, |
| 1341 |
% which produces the file~\file{root.svg} when run. The code used to produce |
| 1342 |
% this SVG~file from within \app{ROOT} is |
| 1343 |
% \lstinputlisting[style=svg,backgroundcolor=\color{red!10}]{examples/root.C} |
| 1344 |
% where the text produced within the \app{ROOT} plot is set to a precision of |
| 1345 |
% zero. |
| 1346 |
% |
| 1347 |
% The plot was then included within this document using the following |
| 1348 |
% \LaTeX~code |
| 1349 |
% \begin{svgexample} |
| 1350 |
% \begin{figure} |
| 1351 |
% \centering% |
| 1352 |
% \includesvg[% |
| 1353 |
% inkscapearea=page,height=6cm,pretex=\tiny,convertformat=png% |
| 1354 |
% ]{root}% |
| 1355 |
% \caption{% |
| 1356 |
% Rendering of a \app{ROOT} plot---no more \emph{Comic CERNs}% |
| 1357 |
% \label{fig:root}% |
| 1358 |
% }% |
| 1359 |
% \end{figure} |
| 1360 |
% \end{svgexample} |
| 1361 |
% \begin{figure} |
| 1362 |
% \centering^^A |
| 1363 |
% \includesvg[^^A |
| 1364 |
% inkscapearea=page,height=6cm,pretex=\tiny,convertformat=png^^A |
| 1365 |
% ]{root}^^A |
| 1366 |
% \caption{^^A |
| 1367 |
% Rendering of a \app{ROOT} plot---no more \emph{Comic CERNs} |
| 1368 |
% \label{fig:root}^^A |
| 1369 |
% }^^A |
| 1370 |
% \end{figure} |
| 1371 |
% which includes the graphic as well as the \LaTeX~file exported by |
| 1372 |
% \app{Inkscape}, produces the extracted PDF~image~(\file{root.pdf}) and |
| 1373 |
% converts this to a PNG~image~(\file{root.png}) by using \app{ImageMagick}. |
| 1374 |
% Enjoy plots from \app{ROOT} with natively rendered \LaTeX{}! |
| 1375 |
% |
| 1376 |
% \StopEventually{^^A |
| 1377 |
% \cleardoublepage\PrintIndex^^A |
| 1378 |
% \cleardoublepage\PrintChanges^^A |
| 1379 |
% \cleardoublepage\PrintToDos^^A |
| 1380 |
% } |
| 1381 |
% |
| 1382 |
% \iffalse |
| 1383 |
%<*package&base> |
| 1384 |
% \fi |
| 1385 |
% |
| 1386 |
% |
| 1387 |
% |
| 1388 |
% \cleardoublepage |
| 1389 |
% \appendix |
| 1390 |
% \part{Implementation} |
| 1391 |
% \section{Initialization} |
| 1392 |
% \subsection{Packages} |
| 1393 |
% |
| 1394 |
% The package \pkg{svg} mainly requires \pkg{scrbase} for options processing |
| 1395 |
% and \pkg{graphicx} for the inclusion of the exported graphic~files. |
| 1396 |
% |
| 1397 |
% The packages \pkg{iftex} and \pkg{pdftexcmds} are needed to detect the used |
| 1398 |
% \LaTeX~engine on the one hand and enabling pdf\TeX{} primitives independent |
| 1399 |
% of the used \LaTeX~engine on the other hand. Additionally, \pkg{trimspaces} |
| 1400 |
% is responsible for string manipulation. Both packages \pkg{shellesc} and |
| 1401 |
% \pkg{ifplatform} are used for engine independent access to systems commands |
| 1402 |
% and files. The package \pkg{svg-extract} only needs package \pkg{svg} itself, |
| 1403 |
% which is loaded during initialization. |
| 1404 |
% \begin{macrocode} |
| 1405 |
%<*main> |
| 1406 |
\RequirePackage{iftex}[2020/03/06] |
| 1407 |
\RequirePackage{scrbase}[2020/09/21] |
| 1408 |
\RequirePackage{pdftexcmds}[2019/11/24] |
| 1409 |
\RequirePackage{trimspaces}[2009/09/17] |
| 1410 |
\RequirePackage{graphicx}[2019/11/30] |
| 1411 |
\RequirePackage{shellesc}[2019/11/08] |
| 1412 |
% \end{macrocode} |
| 1413 |
% In order to do not raise a warning, package \pkg{ifplatform} is only used if |
| 1414 |
% \file{-{}-shell-escape} flag is enabled. |
| 1415 |
% \begin{macrocode} |
| 1416 |
\ifnum\pdf@shellescape=\@ne\relax |
| 1417 |
\RequirePackage{ifplatform}[2017/10/13] |
| 1418 |
\fi |
| 1419 |
%</main> |
| 1420 |
% \end{macrocode} |
| 1421 |
% |
| 1422 |
% |
| 1423 |
% |
| 1424 |
% \subsection{Dealing with catcodes} |
| 1425 |
% |
| 1426 |
% The catcode for double quotes are temporarily changed and restored at the |
| 1427 |
% very end of both packages. |
| 1428 |
% \begin{macrocode} |
| 1429 |
\edef\svg@catcodecodes@restore{% |
| 1430 |
\catcode`\noexpand\"\the\catcode`\"\relax% |
| 1431 |
} |
| 1432 |
\@makeother\"% |
| 1433 |
\AtEndOfPackage{\svg@catcodecodes@restore} |
| 1434 |
% \end{macrocode} |
| 1435 |
% |
| 1436 |
% \iffalse |
| 1437 |
%<*main> |
| 1438 |
% \fi |
| 1439 |
% |
| 1440 |
% |
| 1441 |
% |
| 1442 |
% \subsection{General macros} |
| 1443 |
% |
| 1444 |
% \begin{macro}{\svg@tempa} |
| 1445 |
% \begin{macro}{\svg@tempb} |
| 1446 |
% \begin{macro}{\if@svg@tempswa} |
| 1447 |
% Internal temporary macros. |
| 1448 |
% \begin{macrocode} |
| 1449 |
\newcommand*\svg@tempa{} |
| 1450 |
\newcommand*\svg@tempb{} |
| 1451 |
\newif\if@svg@tempswa |
| 1452 |
% \end{macrocode} |
| 1453 |
% \end{macro}^^A \if@svg@tempswa |
| 1454 |
% \end{macro}^^A \svg@tempb |
| 1455 |
% \end{macro}^^A \svg@tempa |
| 1456 |
% |
| 1457 |
% |
| 1458 |
% |
| 1459 |
% \subsubsection{Macros for process control} |
| 1460 |
% |
| 1461 |
% \begin{macro}{\svg@ifwindowsdetected} |
| 1462 |
% Do some Windows specific stuff if it was detected. |
| 1463 |
% \begin{macrocode} |
| 1464 |
\newcommand*\svg@ifwindowsdetected{\@secondoftwo} |
| 1465 |
\AfterPackage*{ifplatform}{% |
| 1466 |
\renewcommand*\svg@ifwindowsdetected{% |
| 1467 |
\ifwindows% |
| 1468 |
\expandafter\@firstoftwo% |
| 1469 |
\else% |
| 1470 |
\expandafter\@secondoftwo% |
| 1471 |
\fi% |
| 1472 |
}% |
| 1473 |
} |
| 1474 |
% \end{macrocode} |
| 1475 |
% \end{macro}^^A \svg@ifwindowsdetected |
| 1476 |
% \begin{macro}{\svg@ifvalueisrelax} |
| 1477 |
% For some keys the usage of \val{\cs{relax}} as a value should lead to a |
| 1478 |
% special reaction, such as restoring to default behavior or resetting the key. |
| 1479 |
% Therefore, \cs{svg@ifvalueisrelax} checks, whether \val{\cs{relax}} was used |
| 1480 |
% as value or not. |
| 1481 |
% \begin{macrocode} |
| 1482 |
\newcommand*\svg@ifvalueisrelax[1]{% |
| 1483 |
\begingroup% |
| 1484 |
\def\svg@tempa{#1}% |
| 1485 |
\def\svg@tempb{\relax}% |
| 1486 |
\ifx\svg@tempa\svg@tempb% |
| 1487 |
\aftergroup\@firstoftwo% |
| 1488 |
\else% |
| 1489 |
\aftergroup\@secondoftwo% |
| 1490 |
\fi% |
| 1491 |
\endgroup% |
| 1492 |
} |
| 1493 |
% \end{macrocode} |
| 1494 |
% \end{macro}^^A \svg@ifvalueisrelax |
| 1495 |
% |
| 1496 |
% \iffalse |
| 1497 |
%</main> |
| 1498 |
%<*extract> |
| 1499 |
% \fi |
| 1500 |
% |
| 1501 |
% \begin{macro}{\svgx@ifkeyandval} |
| 1502 |
% \begin{macro}{\svgx@@ifkeyandval} |
| 1503 |
% It is checked whether a key was given as \val{\meta{key}=\meta{value}} or |
| 1504 |
% like \val{\meta{key}=\{\meta{format}=\meta{value}\}}. |
| 1505 |
% \begin{macrocode} |
| 1506 |
\newcommand*\svgx@@ifkeyandval{} |
| 1507 |
\newcommand*\svgx@ifkeyandval[3]{% |
| 1508 |
\def\svgx@@ifkeyandval##1=##2=##3\@nil{\IfArgIsEmpty{##3}{#3}{#2}}% |
| 1509 |
\svgx@@ifkeyandval#1==\@nil% |
| 1510 |
} |
| 1511 |
% \end{macrocode} |
| 1512 |
% \end{macro}^^A \svgx@@ifkeyandval |
| 1513 |
% \end{macro}^^A \svgx@ifkeyandval |
| 1514 |
% |
| 1515 |
% \iffalse |
| 1516 |
%</extract> |
| 1517 |
%<*main> |
| 1518 |
% \fi |
| 1519 |
% |
| 1520 |
% |
| 1521 |
% |
| 1522 |
% \subsubsection{String manipulation} |
| 1523 |
% |
| 1524 |
% Both packages \pkg{svg} and \pkg{svg-extract} should be able to handle |
| 1525 |
% user-defined input and output paths. As there is the possibility for users to |
| 1526 |
% provide paths with or without quotes to \LaTeX{}, this is taken into account. |
| 1527 |
% |
| 1528 |
% \begin{macro}{\svg@deactivate@dq} |
| 1529 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 1530 |
% \changes{v2.02a}{2018/10/17}{bug fix for \pkg{polyglossia}}^^A |
| 1531 |
% In order to avoid errors concerning file~names with package \pkg{babel} and |
| 1532 |
% its active double quotes, this command is defined. |
| 1533 |
% \begin{macrocode} |
| 1534 |
\newcommand*\svg@deactivate@dq{} |
| 1535 |
\AfterAtEndOfPackage*{babel}{% |
| 1536 |
\renewcommand*\svg@deactivate@dq{\bbl@deactivate{"}}% |
| 1537 |
\providecommand*\bbl@deactivate[1]{}% |
| 1538 |
} |
| 1539 |
% \end{macrocode} |
| 1540 |
% \end{macro}^^A \svg@deactivate@dq |
| 1541 |
% \begin{macro}{\svg@sanitize@dq} |
| 1542 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 1543 |
% Save expansion of the second argument in the macro from the first argument |
| 1544 |
% with deactivated double quotes. |
| 1545 |
% \begin{macrocode} |
| 1546 |
\newcommand*\svg@sanitize@dq[2]{% |
| 1547 |
\begingroup% |
| 1548 |
\svg@deactivate@dq% |
| 1549 |
\edef\svg@tempa{\endgroup\def\noexpand#1{#2}}% |
| 1550 |
\svg@tempa% |
| 1551 |
} |
| 1552 |
% \end{macrocode} |
| 1553 |
% \end{macro}^^A \svg@sanitize@dq |
| 1554 |
% \begin{macro}{\svg@quotes@check} |
| 1555 |
% \begin{macro}{\svg@quotes@@check} |
| 1556 |
% \begin{macro}{\if@svg@quotes@found} |
| 1557 |
% During the treatment of paths, it may be necessary to temporarily remove |
| 1558 |
% quotes and, if required, add them again later. For this purpose, the switch |
| 1559 |
% \cs{if@svg@quotes@found} as well as the commands \cs{svg@quotes@check} and |
| 1560 |
% \cs{svg@quotes@@check}, which controls the switch, are defined. As before, |
| 1561 |
% the string is passed in a macro to \cs{svg@quotes@check}. |
| 1562 |
% \begin{macrocode} |
| 1563 |
\newif\if@svg@quotes@found |
| 1564 |
\newcommand*\svg@quotes@check[1]{% |
| 1565 |
\expandafter\svg@quotes@@check#1"\@nil% |
| 1566 |
} |
| 1567 |
\newcommand*\svg@quotes@@check{} |
| 1568 |
\def\svg@quotes@@check#1"#2\@nil{% |
| 1569 |
\IfArgIsEmpty{#2}{\@svg@quotes@foundfalse}{\@svg@quotes@foundtrue}% |
| 1570 |
} |
| 1571 |
% \end{macrocode} |
| 1572 |
% \end{macro}^^A \if@svg@quotes@found |
| 1573 |
% \end{macro}^^A \svg@quotes@@check |
| 1574 |
% \end{macro}^^A \svg@quotes@check |
| 1575 |
% \begin{macro}{\svg@quotes@remove} |
| 1576 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@sanitize@dq}}^^A |
| 1577 |
% \changes{v2.02}{2018/09/07}{calling \cs{svg@quotes@check}}^^A |
| 1578 |
% \begin{macro}{\svg@quotes@@remove} |
| 1579 |
% These two commands are used to remove all occurring quotes within a string. |
| 1580 |
% The only argument passed to \cs{svg@quotes@remove} is not the string itself |
| 1581 |
% but a macro in which a string is stored. |
| 1582 |
% \begin{macrocode} |
| 1583 |
\newcommand*\svg@quotes@remove[2][]{% |
| 1584 |
\begingroup% |
| 1585 |
\IfArgIsEmpty{#1}{\def\svg@tempb{#2}}{\def\svg@tempb{#1}}% |
| 1586 |
\svg@sanitize@dq\svg@tempa{\svg@tempb}% |
| 1587 |
\expandafter\svg@quotes@check\expandafter{\svg@tempa}% |
| 1588 |
\expandafter\svg@quotes@@remove\svg@tempa""\@nil% |
| 1589 |
\edef\svg@tempb{% |
| 1590 |
\endgroup% |
| 1591 |
\def\noexpand#2{\svg@tempa}% |
| 1592 |
\if@svg@quotes@found% |
| 1593 |
\noexpand\@svg@quotes@foundtrue% |
| 1594 |
\else% |
| 1595 |
\noexpand\@svg@quotes@foundfalse% |
| 1596 |
\fi% |
| 1597 |
}% |
| 1598 |
\svg@tempb% |
| 1599 |
} |
| 1600 |
\newcommand*\svg@quotes@@remove{} |
| 1601 |
\def\svg@quotes@@remove#1"#2"#3\@nil{% |
| 1602 |
\IfArgIsEmpty{#2}{% |
| 1603 |
\edef\svg@tempa{#1}% |
| 1604 |
}{% |
| 1605 |
\svg@quotes@@remove#1#2#3""\@nil% |
| 1606 |
}% |
| 1607 |
} |
| 1608 |
% \end{macrocode} |
| 1609 |
% \end{macro}^^A \svg@quotes@@remove |
| 1610 |
% \end{macro}^^A \svg@quotes@remove |
| 1611 |
% \begin{macro}{\svg@remove@leadingchar} |
| 1612 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 1613 |
% This command removes the single character in given with the first argument |
| 1614 |
% from the expanded macro in the second argument. |
| 1615 |
% \begin{macrocode} |
| 1616 |
\newcommand*\svg@remove@leadingchar[2]{% |
| 1617 |
\begingroup% |
| 1618 |
\svg@sanitize@dq\svg@tempa{#2}% |
| 1619 |
\def\svg@tempb{% |
| 1620 |
\def\svg@tempa####1\@nil{\def\svg@tempa{####1}}% |
| 1621 |
\kernel@ifnextchar#1% |
| 1622 |
{\expandafter\svg@tempa\@gobble}% |
| 1623 |
{\svg@tempa}% |
| 1624 |
}% |
| 1625 |
\expandafter\svg@tempb\svg@tempa\@nil% |
| 1626 |
\edef\svg@tempb{% |
| 1627 |
\endgroup% |
| 1628 |
\def\noexpand#2{\svg@tempa}% |
| 1629 |
}% |
| 1630 |
\svg@tempb% |
| 1631 |
} |
| 1632 |
% \end{macrocode} |
| 1633 |
% \end{macro}^^A \svg@remove@leadingchar |
| 1634 |
% |
| 1635 |
% |
| 1636 |
% |
| 1637 |
% \subsubsection{File handling} |
| 1638 |
% |
| 1639 |
% \begin{macro}{\svg@filename@parse} |
| 1640 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@sanitize@dq}}^^A |
| 1641 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@remove@leadingchar}}^^A |
| 1642 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@extension@parse}}^^A |
| 1643 |
% As the internal \LaTeX{} command \cs{filename@parse} is not able to split a |
| 1644 |
% given file~name containing quotes, \cs{svg@filename@parse} is defined to |
| 1645 |
% resolve this problem. The optional argument can be used to give a specific |
| 1646 |
% file extension, which should be searched within \cs{filename@ext}. If found |
| 1647 |
% at the very end, the previous part is appended to \cs{filename@base}. |
| 1648 |
% \begin{macrocode} |
| 1649 |
\newcommand*\svg@filename@parse[2][]{% |
| 1650 |
\begingroup% |
| 1651 |
% \end{macrocode} |
| 1652 |
% The given path and file is parsed with \cs{filename@parse}. |
| 1653 |
% \begin{macrocode} |
| 1654 |
\svg@sanitize@dq\svg@tempa{#2}% |
| 1655 |
\expandafter\filename@parse\expandafter{\svg@tempa}% |
| 1656 |
% If there are quotes in the file path, the closing one will be found as first |
| 1657 |
% character in \cs{filename@base} as \cs{filename@area} is split at the last |
| 1658 |
% slash. This leading quote is removed from \cs{filename@base} with |
| 1659 |
% \cs{svg@remove@leadingchar}. |
| 1660 |
% \begin{macrocode} |
| 1661 |
\svg@quotes@remove{\filename@area}% |
| 1662 |
\if@svg@quotes@found% |
| 1663 |
\edef\filename@area{"\filename@area"}% |
| 1664 |
\svg@remove@leadingchar"\filename@base% |
| 1665 |
\fi% |
| 1666 |
% \end{macrocode} |
| 1667 |
% The found extension is parsed against the optional argument. If a double quote |
| 1668 |
% was found within the extension, it actually belongs to \cs{filename@base}. |
| 1669 |
% \begin{macrocode} |
| 1670 |
\ifx\filename@ext\relax\else% |
| 1671 |
\svg@quotes@remove{\filename@ext}% |
| 1672 |
\svg@extension@parse{#1}% |
| 1673 |
\if@svg@quotes@found% |
| 1674 |
\edef\filename@base{\filename@base"}% |
| 1675 |
\fi% |
| 1676 |
\fi% |
| 1677 |
% \end{macrocode} |
| 1678 |
% Quotes within \cs{filename@base} are normalized. |
| 1679 |
% \begin{macrocode} |
| 1680 |
\svg@quotes@remove{\filename@base}% |
| 1681 |
\if@svg@quotes@found% |
| 1682 |
\edef\filename@base{"\filename@base"}% |
| 1683 |
\fi% |
| 1684 |
% \end{macrocode} |
| 1685 |
% With \cs{svg@tempa} the group is closed and the results are saved in the |
| 1686 |
% macros \cs{filename@\dots}. |
| 1687 |
% \begin{macrocode} |
| 1688 |
\edef\svg@tempa{% |
| 1689 |
\endgroup% |
| 1690 |
\def\noexpand\filename@area{\filename@area}% |
| 1691 |
\def\noexpand\filename@base{\filename@base}% |
| 1692 |
\ifx\filename@ext\relax% |
| 1693 |
\let\noexpand\filename@ext\noexpand\relax% |
| 1694 |
\else% |
| 1695 |
\def\noexpand\filename@ext{\filename@ext}% |
| 1696 |
\fi% |
| 1697 |
}% |
| 1698 |
\svg@tempa% |
| 1699 |
} |
| 1700 |
% \end{macrocode} |
| 1701 |
% \end{macro}^^A \svg@filename@parse |
| 1702 |
% \begin{macro}{\svg@extension@parse} |
| 1703 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 1704 |
% \begin{macro}{\svg@extension@@parse} |
| 1705 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 1706 |
% These macros are used to permit multiple dots in file~names. The content of |
| 1707 |
% \cs{filename@ext} is split at each occurrence of \val{.} and the trailing part |
| 1708 |
% is compared against the content of the argument of \cs{svg@extension@parse}, |
| 1709 |
% which is probably \cs{svg@file@ext}. If they are equal, the previous part is |
| 1710 |
% appended to \cs{filename@base} and \cs{filename@ext} is set to the content of |
| 1711 |
% the first argument. |
| 1712 |
% \begin{macrocode} |
| 1713 |
\newcommand*\svg@extension@parse[1]{% |
| 1714 |
\IfArgIsEmpty{#1}{}{% |
| 1715 |
\@expandtwoargs\Ifstr% |
| 1716 |
{\detokenize\expandafter{\filename@ext}}{\detokenize\expandafter{#1}}{}{% |
| 1717 |
\begingroup% |
| 1718 |
% \end{macrocode} |
| 1719 |
% Macro \cs{svg@tempa} is used to temporarily store anything before the |
| 1720 |
% searched extension at the end of \cs{filename@ext} and \cs{svg@tempb} is set |
| 1721 |
% to the actual searched extension if found. |
| 1722 |
% \begin{macrocode} |
| 1723 |
\edef\svg@tempa{% |
| 1724 |
\def\noexpand\svg@tempa{}% |
| 1725 |
\let\noexpand\svg@tempb\relax% |
| 1726 |
\noexpand\svg@extension@@parse% |
| 1727 |
\filename@ext.\noexpand\@nil#1\noexpand\@nil% |
| 1728 |
}% |
| 1729 |
\svg@tempa% |
| 1730 |
\edef\svg@tempa{% |
| 1731 |
\endgroup% |
| 1732 |
% \end{macrocode} |
| 1733 |
% If the trailing extension was found, \cs{filename@base} and \cs{filename@ext} |
| 1734 |
% are adopted. |
| 1735 |
% \begin{macrocode} |
| 1736 |
\def\noexpand\filename@base{\filename@base\svg@tempa}% |
| 1737 |
\ifx\svg@tempb\relax% |
| 1738 |
\let\noexpand\filename@ext\relax% |
| 1739 |
\else% |
| 1740 |
\def\noexpand\filename@ext{\svg@tempb}% |
| 1741 |
\fi% |
| 1742 |
}% |
| 1743 |
\svg@tempa% |
| 1744 |
}% |
| 1745 |
}% |
| 1746 |
} |
| 1747 |
% \end{macrocode} |
| 1748 |
% Macro \cs{svg@extension@@parse} is recursively called as long as there are |
| 1749 |
% any dots or the searched extension is found. |
| 1750 |
% \begin{macrocode} |
| 1751 |
\newcommand*\svg@extension@@parse{} |
| 1752 |
\def\svg@extension@@parse#1.#2\@nil#3\@nil{% |
| 1753 |
\edef\svg@tempa{\svg@tempa.#1}% |
| 1754 |
\IfArgIsEmpty{#2}{}{% |
| 1755 |
\Ifstr{\detokenize{#2}}{\detokenize{#3.}}{% |
| 1756 |
% \end{macrocode} |
| 1757 |
% If the trailing extension is found, \cs{svg@tempb} is defined. |
| 1758 |
% \begin{macrocode} |
| 1759 |
\edef\svg@tempb{#3}% |
| 1760 |
}{% |
| 1761 |
\svg@extension@@parse#2\@nil#3\@nil% |
| 1762 |
}% |
| 1763 |
}% |
| 1764 |
} |
| 1765 |
% \end{macrocode} |
| 1766 |
% \end{macro}^^A \svg@extension@@parse |
| 1767 |
% \end{macro}^^A \svg@extension@parse |
| 1768 |
% \begin{macro}{\svg@iffilenewer} |
| 1769 |
% \changes{v2.02d}{2019/10/22}{use \cs{filemoddate} with Xe\LaTeX, see |
| 1770 |
% \url{https://github.com/mrpiggi/svg/issues/12}}^^A |
| 1771 |
% The macro \cs{svg@iffilenewer} is used to decide, whether the export with |
| 1772 |
% \app{Inkscape} is necessary due to an updated SVG~file. This can only be |
| 1773 |
% done, if \cs{pdf@filemoddate} or \cs{filemoddate} is defined. |
| 1774 |
% \ToDo{\cs{svg@iffilenewer} instead \cs{IfFileExists} to check results}[v2.03] |
| 1775 |
% \begin{macrocode} |
| 1776 |
\newcommand*\svg@iffilenewer[2]{\@gobbletwo} |
| 1777 |
\ifx\pdf@filemoddate\@undefined |
| 1778 |
\ifx\filemoddate\@undefined\else |
| 1779 |
\ifx\strcmp\@undefined\else |
| 1780 |
\renewcommand*\svg@iffilenewer[2]{% |
| 1781 |
\begingroup% |
| 1782 |
\edef\svg@tempa{\filemoddate{#1}}% |
| 1783 |
\edef\svg@tempb{\filemoddate{#2}}% |
| 1784 |
\ifnum\strcmp{\svg@tempa}{\svg@tempb}>\z@\relax% |
| 1785 |
\aftergroup\@firstoftwo% |
| 1786 |
\else% |
| 1787 |
\aftergroup\@secondoftwo% |
| 1788 |
\fi% |
| 1789 |
\endgroup% |
| 1790 |
}% |
| 1791 |
\fi |
| 1792 |
\fi |
| 1793 |
\else |
| 1794 |
\ifx\pdf@strcmp\@undefined\else |
| 1795 |
\renewcommand*\svg@iffilenewer[2]{% |
| 1796 |
\begingroup% |
| 1797 |
\edef\svg@tempa{\pdf@filemoddate{#1}}% |
| 1798 |
\edef\svg@tempb{\pdf@filemoddate{#2}}% |
| 1799 |
\ifnum\pdf@strcmp{\svg@tempa}{\svg@tempb}>\z@\relax% |
| 1800 |
\aftergroup\@firstoftwo% |
| 1801 |
\else% |
| 1802 |
\aftergroup\@secondoftwo% |
| 1803 |
\fi% |
| 1804 |
\endgroup% |
| 1805 |
}% |
| 1806 |
\fi |
| 1807 |
\fi |
| 1808 |
% \end{macrocode} |
| 1809 |
% \end{macro}^^A \svg@iffilenewer |
| 1810 |
% \begin{macro}{\svg@shell@mkdir} |
| 1811 |
% \begin{macro}{\svg@shell@@mkdir} |
| 1812 |
% \begin{macro}{\svg@shell@mv} |
| 1813 |
% \begin{macro}{\svg@shell@@mv} |
| 1814 |
% \begin{macro}{\svg@shell@rm} |
| 1815 |
% \begin{macro}{\svg@shell@@rm} |
| 1816 |
% Finally, platform dependent macros for creating directories as well as |
| 1817 |
% moving and deleting files are provided. |
| 1818 |
% \begin{macrocode} |
| 1819 |
\newcommand*\svg@shell@mkdir[1]{% |
| 1820 |
\begingroup% |
| 1821 |
% \end{macrocode} |
| 1822 |
% A directory should only be created, if it isn't the current working directory. |
| 1823 |
% \begin{macrocode} |
| 1824 |
\svg@quotes@remove[{#1}]{\svg@tempa}% |
| 1825 |
\@svg@tempswatrue% |
| 1826 |
\Ifstr{\svg@tempa}{}{\@svg@tempswafalse}{% |
| 1827 |
\Ifstr{\svg@tempa}{./}{\@svg@tempswafalse}{% |
| 1828 |
}}% |
| 1829 |
\if@svg@tempswa% |
| 1830 |
\ShellEscape{\svg@shell@@mkdir{\svg@tempa}}% |
| 1831 |
\fi% |
| 1832 |
\endgroup% |
| 1833 |
} |
| 1834 |
\newcommand*\svg@shell@mv[2]{% |
| 1835 |
\ShellEscape{\svg@shell@@mv\space"#1"\space"#2"}% |
| 1836 |
} |
| 1837 |
\newcommand*\svg@shell@rm[1]{% |
| 1838 |
\ShellEscape{\svg@shell@@rm\space"#1"}% |
| 1839 |
} |
| 1840 |
% \end{macrocode} |
| 1841 |
% The platform dependent commands for file access. |
| 1842 |
% \begin{macrocode} |
| 1843 |
\svg@ifwindowsdetected{% |
| 1844 |
\newcommand*\svg@shell@@mkdir[1]{if not exist "#1" mkdir "#1"}% |
| 1845 |
\newcommand*\svg@shell@@mv{move}% |
| 1846 |
\newcommand*\svg@shell@@rm{del}% |
| 1847 |
}{% |
| 1848 |
\newcommand*\svg@shell@@mkdir[1]{mkdir -p "#1"}% |
| 1849 |
\newcommand*\svg@shell@@mv{mv}% |
| 1850 |
\newcommand*\svg@shell@@rm{rm}% |
| 1851 |
} |
| 1852 |
% \end{macrocode} |
| 1853 |
% \end{macro}^^A \svg@shell@@rm |
| 1854 |
% \end{macro}^^A \svg@shell@rm |
| 1855 |
% \end{macro}^^A \svg@shell@@mv |
| 1856 |
% \end{macro}^^A \svg@shell@mv |
| 1857 |
% \end{macro}^^A \svg@shell@@mkdir |
| 1858 |
% \end{macro}^^A \svg@shell@mkdir |
| 1859 |
% \begin{macro}{\svg@normalize@path} |
| 1860 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@deactivate@dq}}^^A |
| 1861 |
% \begin{macro}{\svg@normalize@@path} |
| 1862 |
% If any path is given, a trailing slash is needed. These two macros ensure |
| 1863 |
% that this condition is fulfilled in any case, even if this is not considered |
| 1864 |
% by the user. As before, a macro containing the path string is passed to |
| 1865 |
% \cs{svg@normalize@path}. |
| 1866 |
% \begin{macrocode} |
| 1867 |
\newcommand*\svg@normalize@path[1]{% |
| 1868 |
\begingroup% |
| 1869 |
\svg@quotes@remove[{#1}]{\svg@tempa}% |
| 1870 |
\ifx\svg@tempa\@empty\relax% |
| 1871 |
\def\svg@tempa{./}% |
| 1872 |
\fi% |
| 1873 |
\expandafter\svg@normalize@@path\svg@tempa//\@nil% |
| 1874 |
\edef\svg@tempb{% |
| 1875 |
\endgroup% |
| 1876 |
\if@svg@quotes@found% |
| 1877 |
\def\noexpand#1{"\svg@tempa"}% |
| 1878 |
\else% |
| 1879 |
\def\noexpand#1{\svg@tempa}% |
| 1880 |
\fi% |
| 1881 |
}% |
| 1882 |
\svg@tempb% |
| 1883 |
} |
| 1884 |
\newcommand*\svg@normalize@@path{} |
| 1885 |
\def\svg@normalize@@path#1/#2/\@nil{% |
| 1886 |
\IfArgIsEmpty{#2}{% |
| 1887 |
\IfArgIsEmpty{#1}{\def\svg@tempa{}}{\def\svg@tempa{#1/}}% |
| 1888 |
}{% |
| 1889 |
\svg@normalize@@path#2/\@nil% |
| 1890 |
\edef\svg@tempa{#1/\svg@tempa}% |
| 1891 |
}% |
| 1892 |
} |
| 1893 |
% \end{macrocode} |
| 1894 |
% \end{macro}^^A \svg@normalize@@path |
| 1895 |
% \end{macro}^^A \svg@normalize@path |
| 1896 |
% |
| 1897 |
% \iffalse |
| 1898 |
%</main> |
| 1899 |
%<*extract> |
| 1900 |
% \fi |
| 1901 |
% |
| 1902 |
% |
| 1903 |
% |
| 1904 |
% \subsubsection{List handling} |
| 1905 |
% |
| 1906 |
% \begin{macro}{\svgx@ifinlist} |
| 1907 |
% Check, if the first argument is included in a comma-separated list in the |
| 1908 |
% second argument. Keep in mind that the first argument is not expanded at all, |
| 1909 |
% the second one exactly once. |
| 1910 |
% \begin{macrocode} |
| 1911 |
\newcommand*\svgx@ifinlist[2]{% |
| 1912 |
\begingroup% |
| 1913 |
\def\svg@tempa##1,#1,##2\@nil{% |
| 1914 |
\IfArgIsEmpty{##2}{% |
| 1915 |
\aftergroup\@secondoftwo% |
| 1916 |
}{% |
| 1917 |
\aftergroup\@firstoftwo% |
| 1918 |
}% |
| 1919 |
}% |
| 1920 |
\expandafter\svg@tempa\expandafter,#2,#1,\@nil% |
| 1921 |
\endgroup% |
| 1922 |
} |
| 1923 |
% \end{macrocode} |
| 1924 |
% \end{macro}^^A \svgx@ifinlist |
| 1925 |
% |
| 1926 |
% \iffalse |
| 1927 |
%</extract> |
| 1928 |
%</package&base> |
| 1929 |
%<*package&option> |
| 1930 |
% \fi |
| 1931 |
% |
| 1932 |
% |
| 1933 |
% |
| 1934 |
% \section{Including SVG files with package \pkg{svg}} |
| 1935 |
% \subsection{Options} |
| 1936 |
% |
| 1937 |
% All options, which are recommended to be set with \cs{svgsetup}\marg{options} |
| 1938 |
% but are also available as package options, as well as the optional parameters |
| 1939 |
% for both user commands \cs{includesvg}\oarg{parameters}\marg{svg~file} |
| 1940 |
% and \cs{includeinkscape}\oarg{parameters}\marg{file} are defined with |
| 1941 |
% the interface provided by package \pkg{scrbase}. |
| 1942 |
% \begin{macrocode} |
| 1943 |
\DefineFamily{SVG} |
| 1944 |
\DefineFamilyMember{SVG} |
| 1945 |
% \end{macrocode} |
| 1946 |
% |
| 1947 |
% \iffalse |
| 1948 |
%</package&option> |
| 1949 |
%<*package&option&main> |
| 1950 |
% \fi |
| 1951 |
% |
| 1952 |
% \begin{macro}{\svg@deprecated@key} |
| 1953 |
% With version v2.00 the whole user\hbox{-}interface was renewed. For reasons |
| 1954 |
% of compatibility, outdated options and parameters from version~v1.0 are also |
| 1955 |
% provided. If an old key was given, a warning is issued and the valid key is |
| 1956 |
% used. |
| 1957 |
% \begin{macrocode} |
| 1958 |
\newcommand*\svg@deprecated@key[3][svg]{% |
| 1959 |
\PackageWarning{#1}{% |
| 1960 |
The option key `#2' is deprecated. \MessageBreak% |
| 1961 |
It's recommended to use `#3'\MessageBreak% |
| 1962 |
instead% |
| 1963 |
}% |
| 1964 |
\FamilyOptions{SVG}{#3}% |
| 1965 |
} |
| 1966 |
% \end{macrocode} |
| 1967 |
% \end{macro}^^A \svg@deprecated@key |
| 1968 |
% |
| 1969 |
% Within the exported \LaTeX~files of \app{Inkscape}, some commands are used |
| 1970 |
% out of additional packages. But maybe the user doesn't want to load this |
| 1971 |
% packages anyhow. |
| 1972 |
% |
| 1973 |
% \begin{option}{usexcolor} |
| 1974 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 1975 |
% \begin{option}{noxcolor} |
| 1976 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 1977 |
% \begin{macro}{\if@svg@use@xcolor} |
| 1978 |
% \begin{option}{usetransparent} |
| 1979 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 1980 |
% \begin{option}{notransparent} |
| 1981 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 1982 |
% \begin{macro}{\if@svg@use@transparent} |
| 1983 |
% Options for preventing packages \pkg{xcolor} and \pkg{transparent} to be |
| 1984 |
% loaded. |
| 1985 |
% \begin{macrocode} |
| 1986 |
\newif\if@svg@use@xcolor |
| 1987 |
\FamilyBoolKey{SVG}{usexcolor}{@svg@use@xcolor} |
| 1988 |
\DeclareOption{noxcolor}{\FamilyOptions{SVG}{usexcolor=false}} |
| 1989 |
\newif\if@svg@use@transparent |
| 1990 |
\FamilyBoolKey{SVG}{usetransparent}{@svg@use@transparent} |
| 1991 |
\DeclareOption{notransparent}{\FamilyOptions{SVG}{usetransparent=false}} |
| 1992 |
% \end{macrocode} |
| 1993 |
% They are only available during the loading process of package \pkg{svg}. |
| 1994 |
% \begin{macrocode} |
| 1995 |
\AtEndOfPackage{% |
| 1996 |
\RelaxFamilyKey{SVG}{usexcolor}% |
| 1997 |
\RelaxFamilyKey{SVG}{usetransparent}% |
| 1998 |
\if@svg@use@xcolor% |
| 1999 |
\RequirePackage{xcolor}[2016/05/11]% |
| 2000 |
\else% |
| 2001 |
\AfterPackage*{xcolor}{% |
| 2002 |
\PackageWarning{svg}{Package `xcolor' was loaded anyway}% |
| 2003 |
}% |
| 2004 |
\fi% |
| 2005 |
\if@svg@use@transparent% |
| 2006 |
\RequirePackage{transparent}[2019/11/29]% |
| 2007 |
\else% |
| 2008 |
\AfterPackage*{transparent}{% |
| 2009 |
\PackageWarning{svg}{Package `transparent' was loaded anyway}% |
| 2010 |
}% |
| 2011 |
\fi% |
| 2012 |
% \end{macrocode} |
| 2013 |
% There is an issue with package \pkg{transparent}, which currently implements |
| 2014 |
% an \emph{invalid} check relying on internal commands of package \pkg{pgfsys}, |
| 2015 |
% whereas these have changed in the latest version.^^A |
| 2016 |
% \footnote{\url{https://github.com/ho-tex/transparent/issues/3}} |
| 2017 |
% \begin{macrocode} |
| 2018 |
\AfterPackage*{transparent}{% |
| 2019 |
\ifcsname Gin@driver\endcsname% |
| 2020 |
\RequirePackage{pgfsys}% |
| 2021 |
\fi% |
| 2022 |
}% |
| 2023 |
} |
| 2024 |
% \end{macrocode} |
| 2025 |
% \end{macro}^^A \if@svg@use@transparent |
| 2026 |
% \end{option}^^A notransparent |
| 2027 |
% \end{option}^^A usetransparent |
| 2028 |
% \end{macro}^^A \if@svg@use@xcolor |
| 2029 |
% \end{option}^^A noxcolor |
| 2030 |
% \end{option}^^A usexcolor |
| 2031 |
% |
| 2032 |
% |
| 2033 |
% |
| 2034 |
% \subsubsection{The invocation of \app{Inkscape}} |
| 2035 |
% |
| 2036 |
% The Application \app{Inkscape} is used to create includable graphic files in |
| 2037 |
% a desired format (PDF/EPS/PS/PNG) out of files in SVG~format, whereas the |
| 2038 |
% support of \LaTeX{} can optionally be used. |
| 2039 |
% |
| 2040 |
% \begin{option}{inkscape} |
| 2041 |
% \changes{v2.00}{2017/02/17}{changed/extended}^^A |
| 2042 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@sanitize@dq}}^^A |
| 2043 |
% \changes{v2.01}{2017/11/28}{using \cs{trim@spaces}}^^A |
| 2044 |
% \begin{macro}{\svg@ink@mode} |
| 2045 |
% The intension of option \opt{inkscape} is to control the running behaviour of |
| 2046 |
% \app{Inkscape}. It can be switched off at all (\opt{inkscape}|=|\val{false}) |
| 2047 |
% or invoked only if necessary (\opt{inkscape}|=|\val{true}) and even be forced |
| 2048 |
% with every \LaTeX~run (\opt{inkscape}|=|\val{forced}). Additionally, option |
| 2049 |
% \opt{inkscape} can be used as wrapper for options \opt{inkscapeformat}, |
| 2050 |
% \opt{inkscapelatex}, \opt{inkscapearea} and \opt{inkscapedpi}, which are |
| 2051 |
% declared later. |
| 2052 |
% \begin{macrocode} |
| 2053 |
\newcommand*\svg@ink@mode{} |
| 2054 |
\DefineFamilyKey{SVG}{inkscape}[true]{% |
| 2055 |
\svg@sanitize@dq\svg@tempb{#1}% |
| 2056 |
\FamilySetNumerical{SVG}{inkscape}{svg@tempa}{% |
| 2057 |
{false}{0},{off}{0},{no}{0},% |
| 2058 |
{true}{1},{on}{1},{yes}{1},{auto}{1},{onlynewer}{1},{newer}{1},% |
| 2059 |
{forced}{2},{force}{2},{overwrite}{2},% |
| 2060 |
{pdf}{3},{PDF}{3},{eps}{4},{EPS}{4},{ps}{5},{PS}{5},{png}{6},{PNG}{6},% |
| 2061 |
{drawing}{7},{crop}{7},% |
| 2062 |
{page}{8},{nocrop}{8},% |
| 2063 |
{tex}{9},{latex}{9},{exportlatex}{9},{latexexport}{9},% |
| 2064 |
{notex}{10},{nolatex}{10},{noexportlatex}{10},{nolatexexport}{10},% |
| 2065 |
{latexnoexport}{10},{raw}{10},{plain}{10},{simple}{10}% |
| 2066 |
}{\svg@tempb}% |
| 2067 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 2068 |
% \end{macrocode} |
| 2069 |
% Setting the mode for invoking \app{Inkscape}\dots |
| 2070 |
% \begin{macrocode} |
| 2071 |
\ifnum\svg@tempa<\thr@@\relax% |
| 2072 |
\let\svg@ink@mode\svg@tempa% |
| 2073 |
\else% |
| 2074 |
% \end{macrocode} |
| 2075 |
% \dots and the part as wrapper for different options. |
| 2076 |
% \begin{macrocode} |
| 2077 |
\ifcase\svg@tempa\relax\or\or\or% pdf |
| 2078 |
\FamilyOptions{SVG}{inkscapeformat=pdf}% |
| 2079 |
\or% eps |
| 2080 |
\FamilyOptions{SVG}{inkscapeformat=eps}% |
| 2081 |
\or% ps |
| 2082 |
\FamilyOptions{SVG}{inkscapeformat=ps}% |
| 2083 |
\or% png |
| 2084 |
\FamilyOptions{SVG}{inkscapeformat=png}% |
| 2085 |
\or% drawing |
| 2086 |
\FamilyOptions{SVG}{inkscapearea=drawing}% |
| 2087 |
\or% page |
| 2088 |
\FamilyOptions{SVG}{inkscapearea=page}% |
| 2089 |
\or% tex |
| 2090 |
\FamilyOptions{SVG}{inkscapelatex=true}% |
| 2091 |
\or% notex |
| 2092 |
\FamilyOptions{SVG}{inkscapelatex=false}% |
| 2093 |
\fi% |
| 2094 |
\fi% |
| 2095 |
% \end{macrocode} |
| 2096 |
% It's also possible to set the option \opt{inkscapedpi} by passing a number |
| 2097 |
% followed by \val{dpi} like \opt{inkscape}|=|\val{300dpi}. |
| 2098 |
% \begin{macrocode} |
| 2099 |
\else% dpi |
| 2100 |
\def\svg@tempa##1dpi##2\@nil{% |
| 2101 |
\Ifstr{##2}{dpi}{\FamilyOptions{SVG}{inkscapedpi=##1}}{}% |
| 2102 |
}% |
| 2103 |
\lowercase{\expandafter\svg@tempa\svg@tempb dpi\@nil}% |
| 2104 |
% \end{macrocode} |
| 2105 |
% In version~v1.0 the option \opt{inkscape} was used to set both the executable |
| 2106 |
% and options for \app{Inkscape}. This is taken into account here. |
| 2107 |
% \begin{macrocode} |
| 2108 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed\else% legacy option |
| 2109 |
% \end{macrocode} |
| 2110 |
% Splitting executable from options with delimited macros. After calling |
| 2111 |
% \cs{svg@tempa} with the given value, the part for the executable is stored in |
| 2112 |
% \cs{svg@tempa} and the option part---which is recognized by the first |-| |
| 2113 |
% character--- in \cs{svg@tempb}. |
| 2114 |
% \begin{macrocode} |
| 2115 |
\svg@quotes@remove[{#1}]{\svg@tempb}% |
| 2116 |
\def\svg@tempa##1-##2\@nil{% |
| 2117 |
\IfArgIsEmpty{##2}{\let\svg@tempb\@empty}{% |
| 2118 |
\def\svg@tempa####1-\@nil{\def\svg@tempb{-####1}}% |
| 2119 |
\svg@tempa##2\@nil% |
| 2120 |
}% |
| 2121 |
\edef\svg@tempa{\trim@spaces{##1}}% |
| 2122 |
}% |
| 2123 |
\edef\svg@tempb{% |
| 2124 |
\noexpand\svg@tempa\svg@tempb-\noexpand\@nil% |
| 2125 |
}% |
| 2126 |
\svg@tempb% |
| 2127 |
\if@svg@quotes@found% |
| 2128 |
\edef\svg@tempa{"\svg@tempa"}% |
| 2129 |
\fi% |
| 2130 |
\PackageWarning{svg}{% |
| 2131 |
Setting the executable% |
| 2132 |
\ifx\svg@tempb\@empty\else% |
| 2133 |
\space and associated options% |
| 2134 |
\fi% |
| 2135 |
\MessageBreak% |
| 2136 |
for Inkscape should be done with options\MessageBreak% |
| 2137 |
`inkscapeexe=\svg@tempa'% |
| 2138 |
\ifx\svg@tempb\@empty\else% |
| 2139 |
\MessageBreak and `inkscapeopt=\svg@tempb'% |
| 2140 |
\fi.\MessageBreak% |
| 2141 |
Nevertheless, this was done by now anyway% |
| 2142 |
}% |
| 2143 |
\edef\svg@tempa{% |
| 2144 |
\noexpand\FamilyOptions{SVG}{inkscapeexe=\svg@tempa}% |
| 2145 |
\ifx\svg@tempb\@empty\else% |
| 2146 |
\noexpand\FamilyOptions{SVG}{inkscapeopt=\svg@tempb}% |
| 2147 |
\fi% |
| 2148 |
}% |
| 2149 |
\svg@tempa% |
| 2150 |
\fi% |
| 2151 |
\fi% |
| 2152 |
} |
| 2153 |
% \end{macrocode} |
| 2154 |
% \end{macro}^^A \svg@ink@mode |
| 2155 |
% \end{option}^^A inkscape |
| 2156 |
% \begin{option}{on} |
| 2157 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 2158 |
% \begin{option}{off} |
| 2159 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 2160 |
% Package options which can be used to switch functionality on or off during |
| 2161 |
% the loading of package \pkg{svg}. |
| 2162 |
% \begin{macrocode} |
| 2163 |
\DeclareOption{on}{\FamilyOptions{SVG}{inkscape=true}} |
| 2164 |
\DeclareOption{off}{\FamilyOptions{SVG}{inkscape=false}} |
| 2165 |
% \end{macrocode} |
| 2166 |
% \end{option}^^A off |
| 2167 |
% \end{option}^^A on |
| 2168 |
% \begin{option}{inkscapeversion} |
| 2169 |
% \changes{v2.02f}{2020/05/06}{new}^^A |
| 2170 |
% \begin{macro}{\svg@ink@ver} |
| 2171 |
% \changes{v2.02f}{2020/05/06}{new}^^A |
| 2172 |
% \begin{option}{inkscapeexe} |
| 2173 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2174 |
% \changes{v2.02f}{2020/05/06}{only usable in preamble}^^A |
| 2175 |
% \begin{macro}{\svg@ink@exe} |
| 2176 |
% \begin{option}{inkscapeopt} |
| 2177 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2178 |
% \begin{macro}{\svg@ink@opt} |
| 2179 |
% With these options, the executed command for invoking \app{Inkscape} as well |
| 2180 |
% as additional options can be defined. |
| 2181 |
% \ToDo{rename \cs{svg@ink@ver} > \cs{svg@ink@ver@val} (keep former cs)?}[v2.03] |
| 2182 |
% \begin{macrocode} |
| 2183 |
\newcommand*\svg@ink@ver{\m@ne} |
| 2184 |
\DefineFamilyKey{SVG}{inkscapeversion}[true]{% |
| 2185 |
\FamilySetNumerical{SVG}{inkscape}{svg@tempa}{% |
| 2186 |
{true}{0},{on}{0},{yes}{0},{auto}{0},{detect}{0},{determine}{0},{fetch}{0},% |
| 2187 |
{enquire}{0},{identify}{0},{request}{0},{retrieve}{0},{obtain}{0}% |
| 2188 |
}{#1}% |
| 2189 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 2190 |
\renewcommand*\svg@ink@ver{\m@ne}% |
| 2191 |
\else% |
| 2192 |
\def\svg@tempa##1.##2\@nil{% |
| 2193 |
\Ifnumber{##1}{% |
| 2194 |
\renewcommand*\svg@ink@ver{##1}% |
| 2195 |
\FamilyKeyStateProcessed% |
| 2196 |
}{}% |
| 2197 |
}% |
| 2198 |
\svg@tempa#1.\@nil% |
| 2199 |
\fi% |
| 2200 |
} |
| 2201 |
\newcommand*\svg@ink@exe{inkscape} |
| 2202 |
\DefineFamilyKey{SVG}{inkscapeexe}{% |
| 2203 |
\svg@sanitize@dq\svg@ink@exe{#1}% |
| 2204 |
\FamilyKeyStateProcessed% |
| 2205 |
} |
| 2206 |
\newcommand*\svg@ink@opt{} |
| 2207 |
\DefineFamilyKey{SVG}{inkscapeopt}{% |
| 2208 |
\renewcommand*\svg@ink@opt{#1}% |
| 2209 |
\FamilyKeyStateProcessed% |
| 2210 |
} |
| 2211 |
% \end{macrocode} |
| 2212 |
% The two options \opt{inkscapeversion} and \opt{inkscapeexe} can only be used |
| 2213 |
% within the preamble. |
| 2214 |
% \begin{macrocode} |
| 2215 |
\def\svg@tempa#1{% |
| 2216 |
\AtBeginDocument{% |
| 2217 |
\DefineFamilyKey[]{SVG}{#1}[]{% |
| 2218 |
\PackageError{svg}{Option `#1' too late}{% |
| 2219 |
Option `#1' can only be set within\MessageBreak% |
| 2220 |
the preamble but you have tried to set it up later.% |
| 2221 |
}% |
| 2222 |
\FamilyKeyStateProcessed% |
| 2223 |
}% |
| 2224 |
}% |
| 2225 |
} |
| 2226 |
\svg@tempa{inkscapeexe} |
| 2227 |
\svg@tempa{inkscapeversion} |
| 2228 |
% \end{macrocode} |
| 2229 |
% \end{macro}^^A \svg@ink@opt |
| 2230 |
% \end{option}^^A inkscapeopt |
| 2231 |
% \end{macro}^^A \svg@ink@exe |
| 2232 |
% \end{option}^^A inkscapeexe |
| 2233 |
% \end{macro}^^A \svg@ink@ver |
| 2234 |
% \end{option}^^A inkscapeversion |
| 2235 |
% \begin{option}{inkscapeformat} |
| 2236 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2237 |
% \begin{macro}{\svg@ink@format} |
| 2238 |
% With option \opt{inkscapeformat} the output format of the \app{Inkscape} |
| 2239 |
% export function, which is called via \cs{ShellEscape}, can be configured. |
| 2240 |
% It is set to \val{pdf} or, if dvi output could be detected, to \val{eps} |
| 2241 |
% during initialization. |
| 2242 |
% \begin{macrocode} |
| 2243 |
\newcommand*\svg@ink@format{pdf} |
| 2244 |
\ifxetex\else\ifpdf\else |
| 2245 |
\renewcommand*\svg@ink@format{eps} |
| 2246 |
\fi\fi |
| 2247 |
\DefineFamilyKey{SVG}{inkscapeformat}{% |
| 2248 |
\FamilySetNumerical{SVG}{inkscapeformat}{svg@tempa}{% |
| 2249 |
{pdf}{0},{PDF}{0},{eps}{1},{EPS}{1},{ps}{2},{PS}{2},{png}{3},{PNG}{3}% |
| 2250 |
}{#1}% |
| 2251 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 2252 |
\ifcase\svg@tempa\relax% latex |
| 2253 |
\renewcommand*\svg@ink@format{pdf}% |
| 2254 |
\or% eps |
| 2255 |
\renewcommand*\svg@ink@format{eps}% |
| 2256 |
\or% ps |
| 2257 |
\renewcommand*\svg@ink@format{ps}% |
| 2258 |
\or% png |
| 2259 |
\renewcommand*\svg@ink@format{png}% |
| 2260 |
\fi% |
| 2261 |
\fi% |
| 2262 |
} |
| 2263 |
% \end{macrocode} |
| 2264 |
% \end{macro}^^A \svg@ink@format |
| 2265 |
% \end{option}^^A inkscapeformat |
| 2266 |
% \begin{option}{inkscapelatex} |
| 2267 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2268 |
% \begin{option}{latex} |
| 2269 |
% \changes{v2.00b}{2017/02/28}{new, alternative key for \opt{inkscapelatex}}^^A |
| 2270 |
% \begin{option}{tex} |
| 2271 |
% \changes{v2.00b}{2017/03/28}{new, alternative key for \opt{inkscapelatex}}^^A |
| 2272 |
% \begin{macro}{\svg@ink@latex} |
| 2273 |
% This option controls whether the \app{Inkscape} export will be invoked with |
| 2274 |
% or without the generation of a separate \LaTeX~file. |
| 2275 |
% \begin{macrocode} |
| 2276 |
\newif\if@svg@ink@latex |
| 2277 |
\FamilyBoolKey{SVG}{inkscapelatex}{@svg@ink@latex} |
| 2278 |
\FamilyBoolKey{SVG}{latex}{@svg@ink@latex} |
| 2279 |
\FamilyBoolKey{SVG}{tex}{@svg@ink@latex} |
| 2280 |
% \end{macrocode} |
| 2281 |
% \end{macro}^^A \svg@ink@latex |
| 2282 |
% \end{option}^^A tex |
| 2283 |
% \end{option}^^A latex |
| 2284 |
% \end{option}^^A inkscapelatex |
| 2285 |
% \begin{option}{inkscapearea} |
| 2286 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2287 |
% \begin{macro}{\svg@ink@area} |
| 2288 |
% The exported area for an \app{Inkscape} graphic can be set with this option. |
| 2289 |
% \begin{macrocode} |
| 2290 |
\newcommand*\svg@ink@area{} |
| 2291 |
\DefineFamilyKey{SVG}{inkscapearea}{% |
| 2292 |
\FamilySetNumerical{SVG}{inkscapearea}{svg@tempa}{% |
| 2293 |
{drawing}{0},{crop}{0},% |
| 2294 |
{page}{1},{nocrop}{1}% |
| 2295 |
}{#1}% |
| 2296 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 2297 |
\ifcase\svg@tempa\relax% drawing |
| 2298 |
\renewcommand*\svg@ink@area{-D}% |
| 2299 |
\else% page |
| 2300 |
\renewcommand*\svg@ink@area{-C}% |
| 2301 |
\fi% |
| 2302 |
\fi% |
| 2303 |
} |
| 2304 |
% \end{macrocode} |
| 2305 |
% \end{macro}^^A \svg@ink@area |
| 2306 |
% \end{option}^^A inkscapearea |
| 2307 |
% \begin{option}{inkscapedpi} |
| 2308 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2309 |
% \begin{option}{inkscapedensity} |
| 2310 |
% \begin{macro}{\svg@ink@dpi} |
| 2311 |
% A density can be chosen, which is used during export with \app{Inkscape} for |
| 2312 |
% bitmaps and rasterization of filters. |
| 2313 |
% \begin{macrocode} |
| 2314 |
\newcommand*\svg@ink@dpi{} |
| 2315 |
\let\svg@ink@dpi\relax |
| 2316 |
\DefineFamilyKey{SVG}{inkscapedpi}{% |
| 2317 |
\FamilyKeyStateUnknownValue% |
| 2318 |
\svg@ifvalueisrelax{#1}{% |
| 2319 |
\let\svg@ink@dpi\relax% |
| 2320 |
\FamilyKeyStateProcessed% |
| 2321 |
}{% |
| 2322 |
\def\svg@tempa##1dpi##2\@nil{\def\svg@tempa{##1}}% |
| 2323 |
\lowercase{\svg@tempa#1dpi\@nil}% |
| 2324 |
\Ifnumber{\svg@tempa}{% |
| 2325 |
\edef\svg@ink@dpi{\svg@tempa}% |
| 2326 |
\FamilyKeyStateProcessed% |
| 2327 |
}{}% |
| 2328 |
}% |
| 2329 |
} |
| 2330 |
\DefineFamilyKey{SVG}{inkscapedensity}{\FamilyOptions{SVG}{inkscapedpi=#1}} |
| 2331 |
% \end{macrocode} |
| 2332 |
% \end{macro}^^A \svg@ink@dpi |
| 2333 |
% \end{option}^^A inkscapedensity |
| 2334 |
% \end{option}^^A inkscapedpi |
| 2335 |
% \begin{macro}{\svg@ink@cmd} |
| 2336 |
% \changes{v2.02f}{2020/05/06}{distinguish \app{Inkscape}~CLI versions}^^A |
| 2337 |
% The actual usage of the \app{Inkscape} command~line~interface. |
| 2338 |
% \begin{macrocode} |
| 2339 |
\newcommand*\svg@ink@cmd[2]{% |
| 2340 |
\svg@ink@exe\space"#1.\svg@file@ext"\space\svg@ink@area\space% |
| 2341 |
\ifx\svg@ink@dpi\relax\else--export-dpi=\svg@ink@dpi\space\fi% |
| 2342 |
\if@svg@ink@latex--export-latex\space\fi% |
| 2343 |
\ifx\svg@ink@opt\@empty\else\svg@ink@opt\space\fi% |
| 2344 |
\ifcase\svg@ink@ver\relax% 0.x detected |
| 2345 |
--without-gui\space% |
| 2346 |
--export-\svg@ink@format="#2.\svg@ink@format"% |
| 2347 |
\else% 1.x or nothing detected |
| 2348 |
--export-filename="#2.\svg@ink@format"% |
| 2349 |
\fi% |
| 2350 |
} |
| 2351 |
% \end{macrocode} |
| 2352 |
% \end{macro}^^A \svg@ink@cmd |
| 2353 |
% |
| 2354 |
% |
| 2355 |
% |
| 2356 |
% \subsubsection{Setting input folder and file} |
| 2357 |
% |
| 2358 |
% \begin{option}{svgpath} |
| 2359 |
% \changes{v2.00}{2017/02/12}{deprecated}^^A |
| 2360 |
% In version~v1.0 setting the path to SVG~files was done via option. So |
| 2361 |
% this method is provided as well. |
| 2362 |
% \begin{macrocode} |
| 2363 |
\DefineFamilyKey{SVG}{svgpath}{% |
| 2364 |
\PackageWarning{svg}{% |
| 2365 |
The key `svgpath' is deprecated. It's recommended\MessageBreak% |
| 2366 |
to use `\string\svgpath' instead% |
| 2367 |
}% |
| 2368 |
\ifx\svgpath\@undefined% |
| 2369 |
\AtEndOfPackage{\svgpath{{#1}}}% |
| 2370 |
\else% |
| 2371 |
\svgpath{{#1}}% |
| 2372 |
\fi% |
| 2373 |
\FamilyKeyStateProcessed% |
| 2374 |
} |
| 2375 |
% \end{macrocode} |
| 2376 |
% \end{option}^^A svgpath |
| 2377 |
% \begin{option}{svgextension} |
| 2378 |
% \changes{v2.01}{2017/11/27}{new due to user request}^^A |
| 2379 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@quotes@remove}}^^A |
| 2380 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@remove@leadingchar}}^^A |
| 2381 |
% \begin{option}{extension} |
| 2382 |
% \begin{option}{ext} |
| 2383 |
% \begin{macro}{\svg@file@ext} |
| 2384 |
% This option modifies the expected extension for the input file which is |
| 2385 |
% exported with \app{Inkscape}. It is set to \file{svg} by default. |
| 2386 |
% \begin{macrocode} |
| 2387 |
\newcommand*\svg@file@ext{svg} |
| 2388 |
\DefineFamilyKey{SVG}{svgextension}{% |
| 2389 |
% \end{macrocode} |
| 2390 |
% The extension should be in lower case letters. |
| 2391 |
% \begin{macrocode} |
| 2392 |
\lowercase{\svg@quotes@remove[{#1}]{\svg@file@ext}}% |
| 2393 |
% \end{macrocode} |
| 2394 |
% Remove leading dots from the extension. |
| 2395 |
% \begin{macrocode} |
| 2396 |
\svg@remove@leadingchar.\svg@file@ext% |
| 2397 |
} |
| 2398 |
\DefineFamilyKey{SVG}{extension}{\FamilyOptions{SVG}{svgextension=#1}} |
| 2399 |
\DefineFamilyKey{SVG}{ext}{\FamilyOptions{SVG}{svgextension=#1}} |
| 2400 |
% \end{macrocode} |
| 2401 |
% \end{macro}^^A \svg@file@ext |
| 2402 |
% \end{option}^^A ext |
| 2403 |
% \end{option}^^A extension |
| 2404 |
% \end{option}^^A svgextension |
| 2405 |
% |
| 2406 |
% |
| 2407 |
% |
| 2408 |
% \subsubsection{Setting output folder and file} |
| 2409 |
% |
| 2410 |
% \begin{option}{inkscapepath} |
| 2411 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2412 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@sanitize@dq}}^^A |
| 2413 |
% \begin{macro}{\svg@out@path} |
| 2414 |
% The option \opt{inkscapepath} controls, in which folder the results of the |
| 2415 |
% \app{Inkscape} export will be located. |
| 2416 |
% \begin{macrocode} |
| 2417 |
\newcommand*\svg@out@path{} |
| 2418 |
\DefineFamilyKey{SVG}{inkscapepath}{% |
| 2419 |
\svg@sanitize@dq\svg@tempb{#1}% |
| 2420 |
\FamilySetNumerical{SVG}{inkscapepath}{svg@tempa}{% |
| 2421 |
{svgpath}{0},{svgdir}{0},% |
| 2422 |
{svgsubpath}{1},{svgsubdir}{1},% |
| 2423 |
{basepath}{2},{basedir}{2},{jobpath}{2},{jobdir}{2},% |
| 2424 |
{basesubpath}{3},{basesubdir}{3},{jobsubpath}{3},{jobsubdir}{3}% |
| 2425 |
}{\svg@tempb}% |
| 2426 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 2427 |
\ifcase\svg@tempa\relax% svgpath |
| 2428 |
\renewcommand*\svg@out@path{\svg@file@path}% |
| 2429 |
\or% svgsubpath |
| 2430 |
\renewcommand*\svg@out@path{\svg@file@path svg-inkscape/}% |
| 2431 |
\or% basepath |
| 2432 |
\renewcommand*\svg@out@path{./}% |
| 2433 |
\or% basesubpath |
| 2434 |
\renewcommand*\svg@out@path{./svg-inkscape/}% |
| 2435 |
\fi% |
| 2436 |
\else% |
| 2437 |
\edef\svg@out@path{\svg@tempb}% |
| 2438 |
\svg@normalize@path{\svg@out@path}% |
| 2439 |
\FamilyKeyStateProcessed% |
| 2440 |
\fi% |
| 2441 |
} |
| 2442 |
% \end{macrocode} |
| 2443 |
% \end{macro}^^A \svg@out@path |
| 2444 |
% \end{option}^^A inkscapepath |
| 2445 |
% \begin{option}{inkscapename} |
| 2446 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2447 |
% \begin{macro}{\svg@out@name} |
| 2448 |
% \begin{macro}{\svg@out@base} |
| 2449 |
% With option \opt{inkscapename} the name of the exported file can be changed. |
| 2450 |
% \begin{macrocode} |
| 2451 |
\newcommand*\svg@out@name{\svg@file@name\svg@file@suffix} |
| 2452 |
\newcommand*\svg@out@base{\svg@out@path\svg@out@name.\svg@ink@format} |
| 2453 |
\DefineFamilyKey{SVG}{inkscapename}{% |
| 2454 |
\renewcommand*\svg@out@name{#1\svg@file@suffix}% |
| 2455 |
\FamilyKeyStateProcessed% |
| 2456 |
} |
| 2457 |
% \end{macrocode} |
| 2458 |
% \end{macro}^^A \svg@out@base |
| 2459 |
% \end{macro}^^A \svg@out@name |
| 2460 |
% \end{option}^^A inkscapename |
| 2461 |
% |
| 2462 |
% |
| 2463 |
% |
| 2464 |
% \subsubsection{Options for the inclusion of graphics} |
| 2465 |
% |
| 2466 |
% After the graphic export with \app{Inkscape}, the inclusion of those graphics |
| 2467 |
% can be controlled with the following options. |
| 2468 |
% |
| 2469 |
% \begin{option}{width} |
| 2470 |
% \begin{macro}{\svg@param@width} |
| 2471 |
% \begin{option}{height} |
| 2472 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2473 |
% \begin{macro}{\svg@param@width} |
| 2474 |
% \begin{option}{distort} |
| 2475 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 2476 |
% \begin{option}{keepaspectratio} |
| 2477 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 2478 |
% \begin{macro}{\if@svg@param@distort} |
| 2479 |
% \begin{option}{scale} |
| 2480 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2481 |
% \begin{macro}{\svg@param@scale} |
| 2482 |
% These options determine the size of the included graphics. The usage of |
| 2483 |
% \val{\cs{relax}} as value resets the respective option to the default |
| 2484 |
% behavior. |
| 2485 |
% \begin{macrocode} |
| 2486 |
\newcommand*\svg@param@width{\z@} |
| 2487 |
\DefineFamilyKey{SVG}{width}{% |
| 2488 |
\FamilyKeyStateUnknownValue% |
| 2489 |
\svg@ifvalueisrelax{#1}{% |
| 2490 |
\renewcommand*\svg@param@width{\z@}% |
| 2491 |
\FamilyKeyStateProcessed% |
| 2492 |
}{% |
| 2493 |
\FamilySetLengthMacro{SVG}{width}{\svg@param@width}{#1}% |
| 2494 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 2495 |
\ifdim\svg@param@width<\z@\relax% |
| 2496 |
\FamilyKeyStateUnknownValue% |
| 2497 |
\fi% |
| 2498 |
\fi% |
| 2499 |
}% |
| 2500 |
} |
| 2501 |
\newcommand*\svg@param@height{\z@} |
| 2502 |
\DefineFamilyKey{SVG}{height}{% |
| 2503 |
\FamilyKeyStateUnknownValue% |
| 2504 |
\svg@ifvalueisrelax{#1}{% |
| 2505 |
\renewcommand*\svg@param@height{\z@}% |
| 2506 |
\FamilyKeyStateProcessed% |
| 2507 |
}{% |
| 2508 |
\FamilySetLengthMacro{SVG}{height}{\svg@param@height}{#1}% |
| 2509 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 2510 |
\ifdim\svg@param@height<\z@\relax% |
| 2511 |
\FamilyKeyStateUnknownValue% |
| 2512 |
\fi% |
| 2513 |
\fi% |
| 2514 |
}% |
| 2515 |
} |
| 2516 |
\newif\if@svg@param@distort |
| 2517 |
\FamilyBoolKey{SVG}{distort}{@svg@param@distort} |
| 2518 |
\DefineFamilyKey{SVG}{keepaspectratio}[true]{% |
| 2519 |
\FamilySetBool{SVG}{keepaspectratio}{@svg@tempswa}{#1}% |
| 2520 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 2521 |
\if@svg@tempswa% |
| 2522 |
\FamilyExecuteOptions[.svg.sty]{SVG}{distort=false}% |
| 2523 |
\else% |
| 2524 |
\FamilyExecuteOptions[.svg.sty]{SVG}{distort=true}% |
| 2525 |
\fi% |
| 2526 |
\fi% |
| 2527 |
} |
| 2528 |
\newcommand*\svg@param@scale{1} |
| 2529 |
\DefineFamilyKey{SVG}{scale}{% |
| 2530 |
\FamilyKeyStateUnknownValue% |
| 2531 |
\svg@ifvalueisrelax{#1}{% |
| 2532 |
\renewcommand*\svg@param@scale{1}% |
| 2533 |
\FamilyKeyStateProcessed% |
| 2534 |
}{% |
| 2535 |
\Ifisdimension{#1\p@}{% |
| 2536 |
\ifdim\dimexpr#1\p@\relax>\z@\relax% |
| 2537 |
\renewcommand*\svg@param@scale{#1}% |
| 2538 |
\FamilyKeyStateProcessed% |
| 2539 |
\fi% |
| 2540 |
}{}% |
| 2541 |
}% |
| 2542 |
} |
| 2543 |
% \end{macrocode} |
| 2544 |
% \end{macro}^^A \svg@param@scale |
| 2545 |
% \end{option}^^A scale |
| 2546 |
% \end{macro}^^A \if@svg@param@distort |
| 2547 |
% \end{option}^^A keepaspectratio |
| 2548 |
% \end{option}^^A distort |
| 2549 |
% \end{macro}^^A \svg@param@height |
| 2550 |
% \end{option}^^A height |
| 2551 |
% \end{macro}^^A \svg@param@width |
| 2552 |
% \end{option}^^A width |
| 2553 |
% \begin{option}{pretex} |
| 2554 |
% \begin{macro}{\svg@param@pretex} |
| 2555 |
% \begin{option}{apptex} |
| 2556 |
% \begin{macro}{\svg@param@apptex} |
| 2557 |
% \begin{option}{postex} |
| 2558 |
% \changes{v2.00}{2017/03/02}{deprecated}^^A |
| 2559 |
% For executing code right before or after the graphic inclusion, two hooks are |
| 2560 |
% defined. |
| 2561 |
% \begin{macrocode} |
| 2562 |
\newcommand*\svg@param@pretex{} |
| 2563 |
\let\svg@param@pretex\relax |
| 2564 |
\DefineFamilyKey{SVG}{pretex}{% |
| 2565 |
\svg@ifvalueisrelax{#1}{% |
| 2566 |
\let\svg@param@pretex\relax% |
| 2567 |
}{% |
| 2568 |
\def\svg@param@pretex{#1}% |
| 2569 |
}% |
| 2570 |
\FamilyKeyStateProcessed% |
| 2571 |
} |
| 2572 |
\newcommand*\svg@param@apptex{} |
| 2573 |
\let\svg@param@apptex\relax |
| 2574 |
\DefineFamilyKey{SVG}{apptex}{% |
| 2575 |
\svg@ifvalueisrelax{#1}{% |
| 2576 |
\let\svg@param@apptex\relax% |
| 2577 |
}{% |
| 2578 |
\def\svg@param@apptex{#1}% |
| 2579 |
}% |
| 2580 |
\FamilyKeyStateProcessed% |
| 2581 |
} |
| 2582 |
\DefineFamilyKey{SVG}{postex}{% |
| 2583 |
\svg@deprecated@key{postex=#1}{apptex=#1}% |
| 2584 |
} |
| 2585 |
% \end{macrocode} |
| 2586 |
% \end{option}^^A postex |
| 2587 |
% \end{macro}^^A \svg@param@apptex |
| 2588 |
% \end{option}^^A apptex |
| 2589 |
% \end{macro}^^A \svg@param@pretex |
| 2590 |
% \end{option}^^A pretex |
| 2591 |
% \begin{option}{lastpage} |
| 2592 |
% \changes{v2.00}{2017/02/20}{new}^^A |
| 2593 |
% \begin{counter}{svg@param@lastpage} |
| 2594 |
% For \app{Inkscape}\,0.91 a bug concerning the \LaTeX~export has been reported |
| 2595 |
% (\url{https://bugs.launchpad.net/ubuntu/+source/inkscape/+bug/1417470}). |
| 2596 |
% Sometimes the \LaTeX~file created by \app{Inkscape} tries to include more |
| 2597 |
% pages than actually are present in the PDF~file. To work around this |
| 2598 |
% problem, a patch is provided. For this purpose, the total page number is read |
| 2599 |
% from the PDF~file. |
| 2600 |
% \begin{macrocode} |
| 2601 |
\newcounter{svg@param@lastpage} |
| 2602 |
\DefineFamilyKey{SVG}{lastpage}[true]{% |
| 2603 |
\FamilySetNumerical{SVG}{lastpage}{svg@tempa}{% |
| 2604 |
{false}{0},{off}{0},{no}{0},{ignore}{0},% |
| 2605 |
{true}{1},{on}{1},{yes}{1},{auto}{1}% |
| 2606 |
}{#1}% |
| 2607 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 2608 |
\ifcase\svg@tempa\relax% false |
| 2609 |
\FamilySetCounter{SVG}{lastpage}{svg@param@lastpage}{\m@ne}% |
| 2610 |
\or% true |
| 2611 |
\FamilySetCounter{SVG}{lastpage}{svg@param@lastpage}{\z@}% |
| 2612 |
\fi% |
| 2613 |
\fi% |
| 2614 |
} |
| 2615 |
% \end{macrocode} |
| 2616 |
% \end{counter}^^A svg@param@lastpage |
| 2617 |
% \end{option}^^A lastpage |
| 2618 |
% \begin{option}{draft} |
| 2619 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2620 |
% \begin{macro}{\if@svg@draft} |
| 2621 |
% The option \opt{draft} has the same effect as the eponymous option of package |
| 2622 |
% \pkg{graphicx}. |
| 2623 |
% \begin{macrocode} |
| 2624 |
\newif\if@svg@draft |
| 2625 |
\FamilyBoolKey{SVG}{draft}{@svg@draft} |
| 2626 |
\AfterPackage*{graphicx}{\ifGin@draft\@svg@drafttrue\fi} |
| 2627 |
% \end{macrocode} |
| 2628 |
% \end{macro}^^A \if@svg@draft |
| 2629 |
% \end{option}^^A draft |
| 2630 |
% |
| 2631 |
% \iffalse |
| 2632 |
%</package&option&main> |
| 2633 |
% \fi |
| 2634 |
% |
| 2635 |
% |
| 2636 |
% |
| 2637 |
% \subsection{User commands} |
| 2638 |
% \subsubsection{Optional parameters for user commands} |
| 2639 |
% |
| 2640 |
% The family member is defined for both \pkg{svg} and \pkg{svg-extract}. |
| 2641 |
% \begin{macrocode} |
| 2642 |
%<*package&body> |
| 2643 |
\DefineFamilyMember[.param]{SVG} |
| 2644 |
%</package&body> |
| 2645 |
% \end{macrocode} |
| 2646 |
% |
| 2647 |
% \iffalse |
| 2648 |
%<*package&main> |
| 2649 |
%<*body> |
| 2650 |
% \fi |
| 2651 |
% |
| 2652 |
% \begin{macro}{\svg@local@param@def} |
| 2653 |
% \begin{macro}{\svg@local@param@use} |
| 2654 |
% \begin{macro}{\svg@local@param@set} |
| 2655 |
% \changes{v2.02}{2018/09/07}{reasonable value for key \opt{distort}}^^A |
| 2656 |
% Most of the package options can also be used as optional parameters for |
| 2657 |
% \cs{includesvg} or \cs{includeinkscape}. Some of them are overloaded for the |
| 2658 |
% usage as optional argument and there are some keys, which \emph{only} can be |
| 2659 |
% used as optional parameters. This is realized in such a way that |
| 2660 |
% \cs{svg@local@param@use} is extended with \cs{svg@local@param@def} by the |
| 2661 |
% definition of local keys during the loading of package \pkg{svg}. |
| 2662 |
% \begin{macrocode} |
| 2663 |
\newcommand*\svg@local@param@use{} |
| 2664 |
\newcommand*\svg@local@param@def[1]{% |
| 2665 |
\edef\svg@local@param@use{% |
| 2666 |
\unexpanded\expandafter{\svg@local@param@use}\unexpanded{#1}% |
| 2667 |
}% |
| 2668 |
} |
| 2669 |
\newcommand*\svg@local@param@set[1]{% |
| 2670 |
\svg@local@param@use% |
| 2671 |
\FamilyOptions{SVG}{#1}% |
| 2672 |
% \end{macrocode} |
| 2673 |
% As \cs{svg@local@param@set} is always used in a local group, it is possible |
| 2674 |
% to set \opt{inkscapelatex} to \val{false}, if the output format was set to |
| 2675 |
% \val{png} with option \opt{inkscapeformat}. |
| 2676 |
% \begin{macrocode} |
| 2677 |
\Ifstr{\svg@ink@format}{png}{\FamilyOptions{SVG}{inkscapelatex=false}}{}% |
| 2678 |
% \end{macrocode} |
| 2679 |
% Using \opt{distort=true} is only reasonable, if \opt{height} and \opt{width} |
| 2680 |
% are given. |
| 2681 |
% \begin{macrocode} |
| 2682 |
\@svg@tempswatrue% |
| 2683 |
\ifdim\svg@param@width>\z@\relax\ifdim\svg@param@height>\z@\relax% |
| 2684 |
\@svg@tempswafalse% |
| 2685 |
\fi\fi% |
| 2686 |
\if@svg@tempswa% |
| 2687 |
\FamilyExecuteOptions[.svg.sty]{SVG}{distort=false}% |
| 2688 |
\fi% |
| 2689 |
} |
| 2690 |
% \end{macrocode} |
| 2691 |
% \end{macro}^^A \svg@local@param@set |
| 2692 |
% \end{macro}^^A \svg@local@param@use |
| 2693 |
% \end{macro}^^A \svg@local@param@def |
| 2694 |
% \begin{macro}{\svg@deprecated@param} |
| 2695 |
% This macro checks, if \cs{svgwidth} or \cs{svgscale} are defined. In this |
| 2696 |
% case, the given values are passed to the correlating parameters and a warning |
| 2697 |
% is raised. |
| 2698 |
% \begin{macrocode} |
| 2699 |
\newcommand*\svg@deprecated@param{% |
| 2700 |
\@svg@tempswafalse% |
| 2701 |
\ifx\svgwidth\@undefined\else% |
| 2702 |
\edef\svg@tempa{\noexpand\FamilyOptions{SVG}{width=\svgwidth}}% |
| 2703 |
\svg@tempa% |
| 2704 |
\@svg@tempswatrue% |
| 2705 |
\fi% |
| 2706 |
\ifx\svgscale\@undefined\else% |
| 2707 |
\edef\svg@tempa{\noexpand\FamilyOptions{SVG}{scale=\svgscale}}% |
| 2708 |
\svg@tempa% |
| 2709 |
\@svg@tempswatrue% |
| 2710 |
\fi% |
| 2711 |
\if@svg@tempswa% |
| 2712 |
\PackageWarning{svg}{% |
| 2713 |
You should specify the image size with parameters\MessageBreak% |
| 2714 |
`width' and `height' or `scale' instead of using\MessageBreak% |
| 2715 |
`\string\svgscale' or `\string\svgwidth'% |
| 2716 |
}% |
| 2717 |
\let\svgwidth\@undefined% |
| 2718 |
\let\svgscale\@undefined% |
| 2719 |
\fi% |
| 2720 |
} |
| 2721 |
% \end{macrocode} |
| 2722 |
% \end{macro}^^A \svg@deprecated@param |
| 2723 |
% |
| 2724 |
% |
| 2725 |
% |
| 2726 |
% \subsubsection{Definition of user commands} |
| 2727 |
% |
| 2728 |
% \begin{macro}{\svgsetup} |
| 2729 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2730 |
% \begin{macro}{\setsvg} |
| 2731 |
% \changes{v2.00}{2017/02/17}{deprecated}^^A |
| 2732 |
% The macro \cs{svgsetup}\marg{options} can be used to change options after |
| 2733 |
% loading packages \pkg{svg} or \pkg{svg-extract} both in preamble and the |
| 2734 |
% document body. For compatibility reasons, \cs{setsvg} is also defined. |
| 2735 |
% \begin{macrocode} |
| 2736 |
\newcommand*\svgsetup{\FamilyOptions{SVG}} |
| 2737 |
\newcommand*\setsvg{\FamilyOptions{SVG}} |
| 2738 |
% \end{macrocode} |
| 2739 |
% \end{macro}^^A \setsvg |
| 2740 |
% \end{macro}^^A \svgsetup |
| 2741 |
% \begin{macro}{\svgpath} |
| 2742 |
% \changes{v2.00}{2017/02/12}{new}^^A |
| 2743 |
% \changes{v2.02}{2018/09/07}{parse argument for enclosing braces and provide |
| 2744 |
% those if necessary}^^A |
| 2745 |
% \begin{macro}{\svg@input@path} |
| 2746 |
% With \cs{svgpath} the user can give several root paths to SVG~files in the |
| 2747 |
% same way as \cs{graphicspath} is used. The only difference is that a missing |
| 2748 |
% slash is added at the end of the path, if needed. |
| 2749 |
% \begin{macrocode} |
| 2750 |
\newcommand*\svg@input@path{} |
| 2751 |
\let\svg@input@path\input@path |
| 2752 |
\newcommand*\svgpath[1]{% |
| 2753 |
\def\svg@tempa##1\@nil{% |
| 2754 |
\ifx\svg@tempb\bgroup% |
| 2755 |
\def\svg@input@path{#1}% |
| 2756 |
\else% |
| 2757 |
\def\svg@input@path{{#1}}% |
| 2758 |
\fi% |
| 2759 |
}% |
| 2760 |
\futurelet\svg@tempb\svg@tempa#1\@nil% |
| 2761 |
} |
| 2762 |
% \end{macrocode} |
| 2763 |
% \end{macro}^^A \svg@input@path |
| 2764 |
% \end{macro}^^A \svgpath |
| 2765 |
% \begin{macro}{\includesvg} |
| 2766 |
% \changes{v2.00}{2017/02/17}{changes, especially to optional parameters}^^A |
| 2767 |
% \changes{v2.02}{2018/09/07}{switched to \cs{svg@filename@parse}}^^A |
| 2768 |
% For the inclusion of SVG~files the command \cs{includesvg} is defined. |
| 2769 |
% \begin{macrocode} |
| 2770 |
\newcommand*\includesvg[2][]{% |
| 2771 |
\begingroup% |
| 2772 |
% \end{macrocode} |
| 2773 |
% Checking for deprecated commands \cs{svgwidth} and \cs{svgscale}. |
| 2774 |
% \begin{macrocode} |
| 2775 |
\svg@deprecated@param% |
| 2776 |
% \end{macrocode} |
| 2777 |
% \begin{parameter}{inkscape} |
| 2778 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2779 |
% \begin{parameter}{inkscapeformat} |
| 2780 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2781 |
% \begin{parameter}{inkscapelatex} |
| 2782 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2783 |
% \begin{parameter}{inkscapearea} |
| 2784 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2785 |
% \begin{parameter}{inkscapedpi} |
| 2786 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2787 |
% \begin{parameter}{inkscapeopt} |
| 2788 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2789 |
% \begin{parameter}{svgextension} |
| 2790 |
% \changes{v2.01}{2017/11/27}{new}^^A |
| 2791 |
% \begin{parameter}{width} |
| 2792 |
% \begin{parameter}{height} |
| 2793 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2794 |
% \begin{parameter}{distort} |
| 2795 |
% \changes{v2.02}{2018/07/09}{new}^^A |
| 2796 |
% \begin{parameter}{scale} |
| 2797 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2798 |
% \begin{parameter}{pretex} |
| 2799 |
% \begin{parameter}{apptex} |
| 2800 |
% \begin{parameter}{draft} |
| 2801 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2802 |
% Most of the optional parameters have the same effect as the identically named |
| 2803 |
% options. Only parameter \prm{lastpage} is extended (see below). Moreover, |
| 2804 |
% there are some additional parameters, which can only be used as optional |
| 2805 |
% argument for \cs{includesvg} (\prm{angle} and \prm{origin}) but not as an |
| 2806 |
% option. Now all parameters are set in local context (within a group). |
| 2807 |
% \begin{macrocode} |
| 2808 |
\svg@local@param@set{#1}% |
| 2809 |
% \end{macrocode} |
| 2810 |
% \end{parameter}^^A draft |
| 2811 |
% \end{parameter}^^A apptex |
| 2812 |
% \end{parameter}^^A pretex |
| 2813 |
% \end{parameter}^^A scale |
| 2814 |
% \end{parameter}^^A distort |
| 2815 |
% \end{parameter}^^A height |
| 2816 |
% \end{parameter}^^A width |
| 2817 |
% \end{parameter}^^A svgextension |
| 2818 |
% \end{parameter}^^A inkscapeopt |
| 2819 |
% \end{parameter}^^A inkscapedpi |
| 2820 |
% \end{parameter}^^A inkscapearea |
| 2821 |
% \end{parameter}^^A inkscapelatex |
| 2822 |
% \end{parameter}^^A inkscapeformat |
| 2823 |
% \end{parameter}^^A inkscape |
| 2824 |
% The file suffix used by both packages \pkg{svg} and \pkg{svg-extract}. |
| 2825 |
% \begin{macrocode} |
| 2826 |
\if@svg@ink@latex% |
| 2827 |
\edef\svg@file@suffix{_\svg@file@ext-tex}% |
| 2828 |
\else% |
| 2829 |
\edef\svg@file@suffix{_\svg@file@ext-raw}% |
| 2830 |
\fi% |
| 2831 |
\@onelevel@sanitize\svg@file@suffix% |
| 2832 |
% \end{macrocode} |
| 2833 |
% Searching all given paths for the relevant SVG~file. |
| 2834 |
% \begin{macrocode} |
| 2835 |
\svg@get@path{#2}{}% |
| 2836 |
\if@svg@file@found% |
| 2837 |
% \end{macrocode} |
| 2838 |
% Running the export with \app{Inkscape} (if necessary) and checking the |
| 2839 |
% required files for graphic inclusion. |
| 2840 |
% \begin{macrocode} |
| 2841 |
\svg@ink@run% |
| 2842 |
\IfFileExists{\svg@out@base}{}{% |
| 2843 |
\@svg@file@foundfalse% |
| 2844 |
\svg@file@missing{\svg@out@base}{\svg@file@base.\svg@file@ext}% |
| 2845 |
}% |
| 2846 |
\if@svg@ink@latex% |
| 2847 |
\IfFileExists{\svg@out@base_tex}{}{% |
| 2848 |
\@svg@file@foundfalse% |
| 2849 |
\svg@file@missing{\svg@out@base_tex}{\svg@file@base.\svg@file@ext}% |
| 2850 |
}% |
| 2851 |
\fi% |
| 2852 |
% \end{macrocode} |
| 2853 |
% Include the resulting graphic file and maybe extract independent files. |
| 2854 |
% \begin{macrocode} |
| 2855 |
\if@svg@file@found% |
| 2856 |
\svg@input{\svg@out@base}% |
| 2857 |
\svg@extract{\svg@out@base}% |
| 2858 |
\fi% |
| 2859 |
\else% |
| 2860 |
% \end{macrocode} |
| 2861 |
% Raise an error, if the requested SVG~file wasn't found. |
| 2862 |
% \begin{macrocode} |
| 2863 |
\svg@file@missing[\svg@file@ext]{\svg@file@base}{}% |
| 2864 |
\fi% |
| 2865 |
\endgroup% |
| 2866 |
} |
| 2867 |
% \end{macrocode} |
| 2868 |
% \begin{parameter}{lastpage} |
| 2869 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2870 |
% In addition to the automatic finding of the last page, which is included, it |
| 2871 |
% can also be given directly as parameter. |
| 2872 |
% \begin{macrocode} |
| 2873 |
\svg@local@param@def{% |
| 2874 |
\FamilyCounterKey[.param]{SVG}{lastpage}{svg@param@lastpage}% |
| 2875 |
} |
| 2876 |
% \end{macrocode} |
| 2877 |
% \end{parameter}^^A lastpage |
| 2878 |
% \begin{parameter}{angle} |
| 2879 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2880 |
% \changes{v2.02}{2018/09/07}{validation of argument}^^A |
| 2881 |
% \begin{parameter}{origin} |
| 2882 |
% \changes{v2.00}{2017/02/17}{new}^^A |
| 2883 |
% The parameters \prm{angle} and \prm{origin} are defined as pendants to the |
| 2884 |
% keys provided by \cs{includegraphics}. |
| 2885 |
% \begin{macrocode} |
| 2886 |
\newcommand*\svg@param@angle{0} |
| 2887 |
\svg@local@param@def{% |
| 2888 |
\DefineFamilyKey[.param]{SVG}{angle}{% |
| 2889 |
\FamilyKeyStateUnknownValue% |
| 2890 |
\Ifisdimension{#1\p@}{% |
| 2891 |
\renewcommand*\svg@param@angle{#1}% |
| 2892 |
\FamilyKeyStateProcessed% |
| 2893 |
}{}% |
| 2894 |
}% |
| 2895 |
} |
| 2896 |
\newcommand*\svg@param@origin{c} |
| 2897 |
\svg@local@param@def{% |
| 2898 |
\DefineFamilyKey[.param]{SVG}{origin}[c]{% |
| 2899 |
\renewcommand*\svg@param@origin{#1}% |
| 2900 |
\FamilyKeyStateProcessed% |
| 2901 |
}% |
| 2902 |
} |
| 2903 |
% \end{macrocode} |
| 2904 |
% \end{parameter}^^A origin |
| 2905 |
% \end{parameter}^^A angle |
| 2906 |
% \end{macro}^^A \includesvg |
| 2907 |
% \begin{macro}{\includeinkscape} |
| 2908 |
% \changes{v2.00}{2017/02/23}{new}^^A |
| 2909 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@extension@parse}}^^A |
| 2910 |
% The command \cs{includeinkscape} can be used for including the export results |
| 2911 |
% of \app{Inkscape}, if this part of the job was done in another way. |
| 2912 |
% \begin{macrocode} |
| 2913 |
\newcommand*\includeinkscape[2][]{% |
| 2914 |
\begingroup% |
| 2915 |
% \end{macrocode} |
| 2916 |
% Checking for deprecated commands \cs{svgwidth} and \cs{svgscale}. |
| 2917 |
% \begin{macrocode} |
| 2918 |
\svg@deprecated@param% |
| 2919 |
% \end{macrocode} |
| 2920 |
% The given file extension is examined, where a known extension overwrites the |
| 2921 |
% current setting for \opt{inkscapeformat}. If there's a suffix \file{\_tex}, |
| 2922 |
% the option \opt{inkscapelatex} is set to \val{true} by default. |
| 2923 |
% \begin{macrocode} |
| 2924 |
\svg@filename@parse{#2}% |
| 2925 |
\ifx\filename@ext\relax\else% |
| 2926 |
\svg@quotes@remove{\filename@ext}% |
| 2927 |
\expandafter\lowercase\expandafter{% |
| 2928 |
\expandafter\def\expandafter\filename@ext\expandafter{\filename@ext}% |
| 2929 |
}% |
| 2930 |
\def\svg@tempb##1_tex##2\@nil{% |
| 2931 |
\IfArgIsEmpty{##1}{}{\def\filename@ext{##1}}% |
| 2932 |
\Ifstr{##2}{_tex}{\@svg@tempswatrue}{\@svg@tempswafalse}% |
| 2933 |
}% |
| 2934 |
\@svg@tempswafalse% |
| 2935 |
\@tfor\svg@tempa:={pdf}{eps}{ps}{png}\do{% |
| 2936 |
\begingroup% |
| 2937 |
\expandafter\svg@tempb\filename@ext_tex\@nil% |
| 2938 |
\svg@extension@parse{\svg@tempa}% |
| 2939 |
\ifx\filename@ext\relax% |
| 2940 |
\def\svg@tempb{\endgroup}% |
| 2941 |
\else% |
| 2942 |
\edef\svg@tempb{% |
| 2943 |
\endgroup% |
| 2944 |
\noexpand\FamilyOptions{SVG}{inkscapeformat=\svg@tempa}% |
| 2945 |
\if@svg@tempswa% |
| 2946 |
\noexpand\FamilyOptions{SVG}{inkscapelatex=true}% |
| 2947 |
\fi% |
| 2948 |
\def\noexpand\filename@base{\filename@base}% |
| 2949 |
\def\noexpand\filename@ext{\filename@ext}% |
| 2950 |
\noexpand\@svg@tempswatrue% |
| 2951 |
}% |
| 2952 |
\fi% |
| 2953 |
\svg@tempb% |
| 2954 |
% \end{macrocode} |
| 2955 |
% Break for loop, if valid extension was found. |
| 2956 |
% \begin{macrocode} |
| 2957 |
\if@svg@tempswa% |
| 2958 |
\@break@tfor% |
| 2959 |
\fi% |
| 2960 |
}% |
| 2961 |
% \end{macrocode} |
| 2962 |
% If no valid extension was found, it is set to the specified format and the |
| 2963 |
% actual found one is appended to cs{\filename@base}. |
| 2964 |
% \begin{macrocode} |
| 2965 |
\if@svg@tempswa\else% |
| 2966 |
\svg@extension@parse{\svg@ink@format}% |
| 2967 |
\fi% |
| 2968 |
\fi% |
| 2969 |
% \end{macrocode} |
| 2970 |
% \begin{parameter}{inkscapeformat} |
| 2971 |
% \begin{parameter}{inkscapelatex} |
| 2972 |
% \begin{parameter}{width} |
| 2973 |
% \begin{parameter}{height} |
| 2974 |
% \begin{parameter}{distort} |
| 2975 |
% \begin{parameter}{scale} |
| 2976 |
% \begin{parameter}{pretex} |
| 2977 |
% \begin{parameter}{apptex} |
| 2978 |
% \begin{parameter}{draft} |
| 2979 |
% \begin{parameter}{lastpage} |
| 2980 |
% \begin{parameter}{angle} |
| 2981 |
% \begin{parameter}{origin} |
| 2982 |
% Parameters, which are supported by \cs{includesvg}, can also be used with |
| 2983 |
% \cs{includeinkscape} even if some of them---more precisely those that control |
| 2984 |
% the export with \app{Inkscape}---don't have an effect at all. Nevertheless, |
| 2985 |
% they are set right now in local context (within a group). |
| 2986 |
% \begin{macrocode} |
| 2987 |
\svg@local@param@set{#1}% |
| 2988 |
% \end{macrocode} |
| 2989 |
% \end{parameter}^^A origin |
| 2990 |
% \end{parameter}^^A angle |
| 2991 |
% \end{parameter}^^A lastpage |
| 2992 |
% \end{parameter}^^A draft |
| 2993 |
% \end{parameter}^^A apptex |
| 2994 |
% \end{parameter}^^A pretex |
| 2995 |
% \end{parameter}^^A scale |
| 2996 |
% \end{parameter}^^A distort |
| 2997 |
% \end{parameter}^^A height |
| 2998 |
% \end{parameter}^^A width |
| 2999 |
% \end{parameter}^^A inkscapelatex |
| 3000 |
% \end{parameter}^^A inkscapeformat |
| 3001 |
% Searching all given paths for the relevant PDF/EPS~file. |
| 3002 |
% \begin{macrocode} |
| 3003 |
\svg@get@path[\svg@ink@format]{\filename@area\filename@base}{\svg@out@path}% |
| 3004 |
\if@svg@file@found% |
| 3005 |
% \end{macrocode} |
| 3006 |
% Checking the required files for graphic inclusion. |
| 3007 |
% \begin{macrocode} |
| 3008 |
\edef\svg@out@name{\svg@file@name}% |
| 3009 |
\edef\svg@out@base{\svg@file@path\svg@file@name.\svg@ink@format}% |
| 3010 |
\if@svg@ink@latex% |
| 3011 |
\IfFileExists{\svg@out@base_tex}{}{% |
| 3012 |
\@svg@file@foundfalse% |
| 3013 |
\svg@file@missing{\svg@out@base_tex}{\svg@out@base}% |
| 3014 |
}% |
| 3015 |
\fi% |
| 3016 |
% \end{macrocode} |
| 3017 |
% Include the resulting graphic file and maybe extract independent files. |
| 3018 |
% \begin{macrocode} |
| 3019 |
\if@svg@file@found% |
| 3020 |
\svg@input{\svg@out@base}% |
| 3021 |
\svg@extract{\svg@out@base}% |
| 3022 |
\fi% |
| 3023 |
\else% |
| 3024 |
% \end{macrocode} |
| 3025 |
% Raise an error, if the requested PDF/EPS~file wasn't found. |
| 3026 |
% \begin{macrocode} |
| 3027 |
\svg@file@missing[\svg@ink@format]{\svg@file@base}{\svg@out@path}% |
| 3028 |
\fi% |
| 3029 |
\endgroup% |
| 3030 |
} |
| 3031 |
% \end{macrocode} |
| 3032 |
% \end{macro}^^A \includeinkscape |
| 3033 |
% |
| 3034 |
% |
| 3035 |
% |
| 3036 |
% \subsection{Auxiliary macros} |
| 3037 |
% |
| 3038 |
% \begin{macro}{\svg@ink@run} |
| 3039 |
% \begin{macro}{\if@svg@ink@run} |
| 3040 |
% The command, which performs the call of \app{Inkscape} via \cs{ShellEscape}. |
| 3041 |
% \begin{macrocode} |
| 3042 |
\newif\if@svg@ink@run |
| 3043 |
\newcommand*\svg@ink@run{% |
| 3044 |
\ifnum\svg@ink@mode>\z@\relax% |
| 3045 |
\begingroup% |
| 3046 |
% \end{macrocode} |
| 3047 |
% If the mode for \opt{inkscape} was set to \val{forced}, \app{Inkscape} will |
| 3048 |
% be called in any case. Otherwise, some checks are performed to detect, if a |
| 3049 |
% run of \app{Inkscape} is actually necessary. |
| 3050 |
% \begin{macrocode} |
| 3051 |
\@svg@ink@runtrue% |
| 3052 |
\ifnum\svg@ink@mode=\tw@\relax\else% |
| 3053 |
% \end{macrocode} |
| 3054 |
% This is the case when the SVG~file is newer than the corresponding exported |
| 3055 |
% file, or if the latter isn't present at all. |
| 3056 |
% \begin{macrocode} |
| 3057 |
\svg@iffilenewer{\svg@file@base.\svg@file@ext}{\svg@out@base}{}{% |
| 3058 |
\@svg@ink@runfalse% |
| 3059 |
}% |
| 3060 |
% \end{macrocode} |
| 3061 |
% The same is true, when the associated \LaTeX~file is missing. But when this |
| 3062 |
% file already exists, maybe the user did some changes to this file. In this |
| 3063 |
% case, overwriting this file is maybe not intended. |
| 3064 |
% \begin{macrocode} |
| 3065 |
\if@svg@ink@latex% |
| 3066 |
\IfFileExists{\svg@out@base_tex}{% |
| 3067 |
\ifnum\pdf@shellescape=\@ne\relax\if@svg@ink@run% |
| 3068 |
\svg@iffilenewer{\svg@out@base_tex}{\svg@out@base}{% |
| 3069 |
\@svg@ink@runfalse% |
| 3070 |
\svg@quotes@remove[\svg@out@base]{\svg@tempa}% |
| 3071 |
\PackageWarning{svg}{% |
| 3072 |
Since the encountered filedate of file\MessageBreak% |
| 3073 |
`\svg@tempa_tex' is newer than \MessageBreak% |
| 3074 |
`\svg@tempa' it's supposed that\MessageBreak% |
| 3075 |
you customized this file. To avoid an accidental\MessageBreak% |
| 3076 |
overwriting of this file, the Inkscape export\MessageBreak% |
| 3077 |
won't be done. If you want to overwrite the\MessageBreak% |
| 3078 |
existing file please choose the parameter\MessageBreak% |
| 3079 |
`inkscape=force'% |
| 3080 |
}% |
| 3081 |
}{}% |
| 3082 |
\fi\fi% |
| 3083 |
}{\@svg@ink@runtrue}% |
| 3084 |
\fi% |
| 3085 |
\fi% |
| 3086 |
% \end{macrocode} |
| 3087 |
% If all checks were positive, the export with \app{Inkscape} can be done in |
| 3088 |
% case flag \file{-{}-shell-escape} is used. |
| 3089 |
% \begin{macrocode} |
| 3090 |
\if@svg@ink@run% |
| 3091 |
\ifnum\pdf@shellescape=\@ne\relax% |
| 3092 |
% \end{macrocode} |
| 3093 |
% For exporting PNG~files, the used density is set to \val{300dpi}, if no |
| 3094 |
% value was given. |
| 3095 |
% \begin{macrocode} |
| 3096 |
\ifx\svg@ink@dpi\relax% |
| 3097 |
\Ifstr{\svg@ink@format}{png}{% |
| 3098 |
\FamilyOptions{SVG}{inkscapedpi=300}% |
| 3099 |
}{}% |
| 3100 |
\fi% |
| 3101 |
\PackageInfo{svg}{% |
| 3102 |
Calling Inkscape% |
| 3103 |
\ifx\svg@ink@opt\@empty\else% |
| 3104 |
\space with added options `\svg@ink@opt'% |
| 3105 |
\fi% |
| 3106 |
}% |
| 3107 |
% \end{macrocode} |
| 3108 |
% Executing \app{Inkscape} on shell. Afterwards, the export results are moved |
| 3109 |
% into the given output path. |
| 3110 |
% \begin{macrocode} |
| 3111 |
\svg@quotes@remove[\svg@file@base]{\svg@tempa}% |
| 3112 |
\svg@quotes@remove[\svg@out@name]{\svg@tempb}% |
| 3113 |
% \end{macrocode} |
| 3114 |
% The last try to detect the version automatically, if this wasn't successful |
| 3115 |
% until now. |
| 3116 |
% \begin{macrocode} |
| 3117 |
\ifnum\svg@ink@ver=\m@ne\relax% |
| 3118 |
\svg@ink@ver@explore{\svg@tempa}{\svg@tempb}{\svg@out@name}% |
| 3119 |
\fi% |
| 3120 |
% \end{macrocode} |
| 3121 |
% Now it's time to actually create the desired graphic. |
| 3122 |
% \begin{macrocode} |
| 3123 |
\ShellEscape{\svg@ink@cmd{\svg@tempa}{\svg@tempb}}% |
| 3124 |
\IfFileExists{\svg@out@name.\svg@ink@format}{% |
| 3125 |
\edef\svg@tempb{\svg@tempb.\svg@ink@format}% |
| 3126 |
\svg@quotes@remove{\svg@out@base}% |
| 3127 |
\svg@shell@mkdir{\svg@out@path}% |
| 3128 |
\svg@shell@mv{\svg@tempb}{\svg@out@base}% |
| 3129 |
\if@svg@ink@latex% |
| 3130 |
\svg@shell@mv{\svg@tempb_tex}{\svg@out@base_tex}% |
| 3131 |
\fi% |
| 3132 |
}{% |
| 3133 |
\gdef\svg@ink@ver{\m@ne}% |
| 3134 |
\PackageWarning{svg}{% |
| 3135 |
The export with Inkscape failed for file\MessageBreak% |
| 3136 |
`\svg@tempa.\svg@file@ext'\MessageBreak% |
| 3137 |
Troubleshooting: Please check in the log file how\MessageBreak% |
| 3138 |
the invocation of Inkscape took place and try to\MessageBreak% |
| 3139 |
execute it yourself in the terminal% |
| 3140 |
}% |
| 3141 |
}% |
| 3142 |
% \end{macrocode} |
| 3143 |
% If \file{-{}-shell-escape} wasn't enabled, a warning is issued. |
| 3144 |
% \begin{macrocode} |
| 3145 |
\else% |
| 3146 |
\svg@quotes@remove[\svg@file@base]{\svg@tempa}% |
| 3147 |
\PackageWarning{svg}{% |
| 3148 |
You didn't enable `shell escape' (or `write18')\MessageBreak% |
| 3149 |
so it wasn't possible to launch the Inkscape export\MessageBreak% |
| 3150 |
for `\svg@tempa.\svg@file@ext'% |
| 3151 |
}% |
| 3152 |
\fi% |
| 3153 |
\fi% |
| 3154 |
\endgroup% |
| 3155 |
\fi% |
| 3156 |
} |
| 3157 |
% \end{macrocode} |
| 3158 |
% \end{macro}^^A \if@svg@ink@run |
| 3159 |
% \end{macro}^^A \svg@ink@run |
| 3160 |
% \begin{macro}{\svg@input} |
| 3161 |
% \begin{macro}{\svg@@input} |
| 3162 |
% \changes{v2.02g}{2020/06/12}{parsing of file extension discarded; meanwhile |
| 3163 |
% taken over by the kernel}^^A |
| 3164 |
% \begin{macro}{\svg@box} |
| 3165 |
% With \cs{svg@@input} the export results of \app{Inkscape} are included. The |
| 3166 |
% macro \cs{svg@input} is defined in order to realize the option \opt{exclude} |
| 3167 |
% for package \pkg{svg-extract}. The macro \cs{svg@set@input@path} is called to |
| 3168 |
% support commands like \cs{input}\marg{tex filename} within SVG~files. |
| 3169 |
% \begin{macrocode} |
| 3170 |
\newsavebox\svg@box |
| 3171 |
\newcommand*\svg@input{\svg@@input} |
| 3172 |
\newcommand*\svg@@input[2][]{% |
| 3173 |
\IfArgIsEmpty{#1}{}{\svg@local@param@set{#1}}% |
| 3174 |
\svg@set@input@path% |
| 3175 |
% \end{macrocode} |
| 3176 |
% If the export with \app{Inkscape} was done with \LaTeX~support enabled, the |
| 3177 |
% corresponding file will be used together with \cs{input}. The necessary |
| 3178 |
% patches to environment \env{picture} as well as command \cs{includegraphics} |
| 3179 |
% are made beforehand with \cs{svg@patches}. |
| 3180 |
% \begin{macrocode} |
| 3181 |
\@svg@tempswatrue% |
| 3182 |
\if@svg@draft% |
| 3183 |
\@svg@tempswafalse% |
| 3184 |
\fi% |
| 3185 |
\if@svg@ink@latex\else% |
| 3186 |
\@svg@tempswafalse% |
| 3187 |
\fi% |
| 3188 |
\edef\svg@tempa{#2}% |
| 3189 |
\if@svg@tempswa% |
| 3190 |
\svg@patches{\svg@tempa}% |
| 3191 |
\ifnum\value{svg@param@lastpage}=\z@\relax% |
| 3192 |
\expandafter\svg@get@lastpage\expandafter{\svg@tempa}% |
| 3193 |
\fi% |
| 3194 |
\edef\svg@tempa{% |
| 3195 |
\ifx\svg@param@pretex\relax\else% |
| 3196 |
\noexpand\svg@param@pretex% |
| 3197 |
\fi% |
| 3198 |
\noexpand\input{\svg@tempa_tex}% |
| 3199 |
\ifx\svg@param@apptex\relax\else% |
| 3200 |
\noexpand\svg@param@apptex% |
| 3201 |
\fi% |
| 3202 |
}% |
| 3203 |
% \end{macrocode} |
| 3204 |
% If \opt{distort=true} is desired, the input is resized with \cs{resizebox*}. |
| 3205 |
% \begin{macrocode} |
| 3206 |
\if@svg@param@distort% |
| 3207 |
\def\svg@tempb{\resizebox*{\svg@param@width}{\svg@param@height}}% |
| 3208 |
\else% |
| 3209 |
\let\svg@tempb\@firstofone% |
| 3210 |
\fi% |
| 3211 |
\sbox\svg@box{\svg@tempb{\svg@tempa}}% |
| 3212 |
% \end{macrocode} |
| 3213 |
% If a rotation angle was given, the input is done within \cs{rotatebox}. |
| 3214 |
% \begin{macrocode} |
| 3215 |
\ifdim\dimexpr\svg@param@angle\p@\relax=\z@\relax% |
| 3216 |
\let\svg@tempb\@firstofone% |
| 3217 |
\else% |
| 3218 |
\edef\svg@tempb{% |
| 3219 |
\noexpand\rotatebox[origin=\svg@param@origin]{\svg@param@angle}% |
| 3220 |
}% |
| 3221 |
\fi% |
| 3222 |
\svg@tempb{\usebox\svg@box}% |
| 3223 |
\else% |
| 3224 |
% \end{macrocode} |
| 3225 |
% If the export with \app{Inkscape} was done without \LaTeX~support, the |
| 3226 |
% resulting graphic file will be included with \cs{includegraphics}. |
| 3227 |
% \begin{macrocode} |
| 3228 |
\svg@wrn@scale% |
| 3229 |
\edef\svg@tempb{% |
| 3230 |
draft\if@svg@draft\else=false\fi,% |
| 3231 |
scale=\svg@param@scale,% |
| 3232 |
keepaspectratio\if@svg@param@distort=false\fi% |
| 3233 |
}% |
| 3234 |
\ifdim\svg@param@height>\z@\relax% |
| 3235 |
\edef\svg@tempb{\svg@tempb,height=\svg@param@height}% |
| 3236 |
\fi% |
| 3237 |
\ifdim\svg@param@width>\z@\relax% |
| 3238 |
\edef\svg@tempb{\svg@tempb,width=\svg@param@width}% |
| 3239 |
\fi% |
| 3240 |
\ifdim\dimexpr\svg@param@angle\p@\relax=\z@\relax\else% |
| 3241 |
\edef\svg@tempb{% |
| 3242 |
\svg@tempb,origin=\svg@param@origin,angle=\svg@param@angle% |
| 3243 |
}% |
| 3244 |
\fi% |
| 3245 |
\expandafter\includegraphics\expandafter[\svg@tempb]{\svg@tempa}% |
| 3246 |
\fi% |
| 3247 |
} |
| 3248 |
% \end{macrocode} |
| 3249 |
% \end{macro}^^A \svg@box |
| 3250 |
% \end{macro}^^A \svg@@input |
| 3251 |
% \end{macro}^^A \svg@input |
| 3252 |
% \begin{macro}{\svg@wrn@scale} |
| 3253 |
% The option \opt{scale} respectively the parameter \prm{scale} is only |
| 3254 |
% considered if the size was not specified. |
| 3255 |
% \begin{macrocode} |
| 3256 |
\newcommand*\svg@wrn@scale{% |
| 3257 |
\ifdim\dimexpr\svg@param@scale\p@\relax=\p@\relax\else% |
| 3258 |
\@svg@tempswafalse% |
| 3259 |
\ifdim\svg@param@width>\z@\relax% |
| 3260 |
\@svg@tempswatrue% |
| 3261 |
\fi% |
| 3262 |
\ifdim\svg@param@height>\z@\relax% |
| 3263 |
\@svg@tempswatrue% |
| 3264 |
\fi% |
| 3265 |
\if@svg@tempswa% |
| 3266 |
\PackageWarning{svg}{% |
| 3267 |
The parameter `scale' is only considered if neither\MessageBreak% |
| 3268 |
`width' nor `height' are specified% |
| 3269 |
}% |
| 3270 |
\fi% |
| 3271 |
\fi% |
| 3272 |
} |
| 3273 |
% \end{macrocode} |
| 3274 |
% \end{macro}^^A \svg@wrn@scale |
| 3275 |
% \begin{macro}{\svg@get@lastpage} |
| 3276 |
% This macro is used to circumvent the multiple pages bug for PDF~files of |
| 3277 |
% \app{Inkscape}\,0.91, when the the \LaTeX~export was enabled. For this |
| 3278 |
% purpose, the total page number is read from the PDF~file. |
| 3279 |
% \begin{macrocode} |
| 3280 |
\newcommand*\svg@get@lastpage[1]{% |
| 3281 |
\Ifstr{\svg@ink@format}{pdf}{% |
| 3282 |
\begingroup% |
| 3283 |
\@tempcnta=\m@ne\relax% |
| 3284 |
\ifx\XeTeXpdfpagecount\@undefined% |
| 3285 |
\ifpdf% |
| 3286 |
\ifx\pdfximage\@undefined% |
| 3287 |
\ifx\saveimageresource\@undefined\else% |
| 3288 |
\saveimageresource{#1}% |
| 3289 |
\@tempcnta=\lastsavedimageresourcepages\relax% |
| 3290 |
\fi% |
| 3291 |
\else% |
| 3292 |
\pdfximage{#1}% |
| 3293 |
\@tempcnta=\pdflastximagepages\relax% |
| 3294 |
\fi% |
| 3295 |
\fi% |
| 3296 |
\else% |
| 3297 |
\@tempcnta=\XeTeXpdfpagecount#1\relax% |
| 3298 |
\fi% |
| 3299 |
\ifnum\@tempcnta=\m@ne\relax% |
| 3300 |
\PackageWarning{svg}{% |
| 3301 |
It wasn't possible to detect the last page\MessageBreak% |
| 3302 |
of `#1'% |
| 3303 |
}% |
| 3304 |
\else% |
| 3305 |
\PackageInfo{svg}{Last page of `#1' is \the\@tempcnta}% |
| 3306 |
\fi% |
| 3307 |
\edef\svg@tempa{% |
| 3308 |
\endgroup% |
| 3309 |
\noexpand\FamilyOptions{SVG}{lastpage=\the\@tempcnta}% |
| 3310 |
}% |
| 3311 |
\svg@tempa% |
| 3312 |
}{}% |
| 3313 |
} |
| 3314 |
% \end{macrocode} |
| 3315 |
% \end{macro}^^A \svg@get@lastpage |
| 3316 |
% \begin{macro}{\svg@file@missing} |
| 3317 |
% \changes{v2.02}{2018/09/07}{notify svg file when missing exported files}^^A |
| 3318 |
% The error message, which is raised, if a file is missing either after the |
| 3319 |
% export with \app{Inkscape} or in general. |
| 3320 |
% \begin{macrocode} |
| 3321 |
\newcommand*\svg@file@missing[3][]{% |
| 3322 |
\begingroup% |
| 3323 |
\svg@quotes@remove[{#2}]{\svg@tempa}% |
| 3324 |
\svg@filename@parse[{#1}]{\svg@tempa}% |
| 3325 |
\IfArgIsEmpty{#1}{% |
| 3326 |
\svg@quotes@remove[{#3}]{\svg@tempb}% |
| 3327 |
\def\svg@tempa{% |
| 3328 |
Did you run the export with Inkscape? There's no file\MessageBreak% |
| 3329 |
`\filename@area\filename@base.\filename@ext'\MessageBreak% |
| 3330 |
although `\svg@tempb' was found.% |
| 3331 |
}% |
| 3332 |
}{% |
| 3333 |
\edef\filename@ext{#1}% |
| 3334 |
\Ifstr{\filename@area}{./}{\let\filename@area\@empty}{}% |
| 3335 |
% \end{macrocode} |
| 3336 |
% Collecting all considered path for the error message. |
| 3337 |
% \begin{macrocode} |
| 3338 |
\edef\svg@tempb{#3}% |
| 3339 |
\Ifstr{\svg@tempb}{./}{\let\svg@tempb\@empty}{}% |
| 3340 |
\ifx\svg@tempb\@empty% |
| 3341 |
\svg@set@input@path% |
| 3342 |
\else% |
| 3343 |
\svg@set@input@path[\svg@tempb]% |
| 3344 |
\fi% |
| 3345 |
\ifx\input@path\@undefined% |
| 3346 |
\def\svg@tempb{No additional path was given.}% |
| 3347 |
\else% |
| 3348 |
\def\svg@tempb{Following folders have additionally been searched:}% |
| 3349 |
\expandafter\@tfor\expandafter\svg@tempa\expandafter:\expandafter=% |
| 3350 |
\input@path\do{% |
| 3351 |
\edef\svg@tempb{\svg@tempb\noexpand\MessageBreak\svg@tempa}% |
| 3352 |
}% |
| 3353 |
\fi% |
| 3354 |
% \end{macrocode} |
| 3355 |
% The error message itself. |
| 3356 |
% \begin{macrocode} |
| 3357 |
\def\svg@tempa{% |
| 3358 |
There's no file `\filename@base.\filename@ext'\MessageBreak% |
| 3359 |
\ifx\filename@area\@empty% |
| 3360 |
neither in the current directory nor any other searched\MessageBreak% |
| 3361 |
path given by \string\svgpath\space or \string\graphicspath.% |
| 3362 |
\MessageBreak\svg@tempb% |
| 3363 |
\else% |
| 3364 |
in folder `\filename@area'.% |
| 3365 |
\fi% |
| 3366 |
}% |
| 3367 |
}% |
| 3368 |
\PackageError{svg}{% |
| 3369 |
File `\filename@base.\filename@ext' is missing% |
| 3370 |
}{\svg@tempa}% |
| 3371 |
\endgroup% |
| 3372 |
} |
| 3373 |
% \end{macrocode} |
| 3374 |
% \end{macro}^^A \svg@file@missing |
| 3375 |
% \begin{macro}{\svg@ink@ver@settings} |
| 3376 |
% \changes{v2.02f}{2020/05/06}{new}^^A |
| 3377 |
% \begin{macro}{\svg@ink@ver@detect} |
| 3378 |
% \changes{v2.02f}{2020/05/06}{new}^^A |
| 3379 |
% \begin{macro}{\svg@@ink@ver@detect} |
| 3380 |
% \changes{v2.02f}{2020/05/06}{new}^^A |
| 3381 |
% \begin{macro}{\if@svg@ink@ver@detect} |
| 3382 |
% \changes{v2.02f}{2020/05/06}{new}^^A |
| 3383 |
% As the command~line~interface of \app{Inkscape} has changed between versions |
| 3384 |
% \val{0.x} and \val{1.x}, option \opt{inkscapeversion}|=|\val{detect} allows |
| 3385 |
% to detect the used version of \app{Inkscape} in order to define the calling |
| 3386 |
% macro \cs{svg@ink@cmd}. The obtained version is stored in \cs{svg@ink@ver}, |
| 3387 |
% whereas the following meanings are applied: |
| 3388 |
% \begin{description} |
| 3389 |
% \item[\val{-1}] version check has not be done or \app{Inkscape} could not |
| 3390 |
% be found/executed |
| 3391 |
% \item[\val{0}] \app{Inkscape} version \val{0.x} was found |
| 3392 |
% \item[\val{1}] \app{Inkscape} version \val{1.x} or later was found |
| 3393 |
% \end{description} |
| 3394 |
% |
| 3395 |
% All necessary information are stored within \cs{svg@ink@ver@settings} as |
| 3396 |
% three arguments, whereas the first one is the manually set version, the |
| 3397 |
% second is the used \opt{inkscapeexe} for automatic detection and the third |
| 3398 |
% one is the detected version itself. |
| 3399 |
% \begin{macrocode} |
| 3400 |
\newcommand*\svg@ink@ver@settings{{\svg@ink@ver}{\svg@ink@exe}{\m@ne}} |
| 3401 |
\newif\if@svg@ink@ver@detect |
| 3402 |
% \end{macrocode} |
| 3403 |
% In order to run the check for \app{Inkscape} version at the beginning of the |
| 3404 |
% document only if needed, changes of both \opt{inkscapeversion}---at this |
| 3405 |
% point stored in \cs{svg@ink@ver}--- as well as \opt{inkscapeexe} are detected |
| 3406 |
% and are triggering the version check. After evaluating the triggers, the |
| 3407 |
% current values set are stored as two tokens in \cs{svg@ink@ver@settings}. If |
| 3408 |
% a check has been triggered, the detected version will be evaluated further |
| 3409 |
% on and is stored in the third token of \cs{svg@ink@ver@settings}. |
| 3410 |
% \begin{macrocode} |
| 3411 |
\newcommand*\svg@ink@ver@detect[3]{% |
| 3412 |
\@svg@ink@ver@detectfalse% |
| 3413 |
\ifnum\pdf@shellescape=\@ne\relax% |
| 3414 |
\ifnum\svg@ink@ver=\m@ne\relax% |
| 3415 |
% \end{macrocode} |
| 3416 |
% If \opt{inkscapeexe} was not changed\dots |
| 3417 |
% \begin{macrocode} |
| 3418 |
\svg@sanitize@dq\svg@tempa{#2}% |
| 3419 |
\ifx\svg@tempa\svg@ink@exe% |
| 3420 |
% \end{macrocode} |
| 3421 |
% \dots then enforce the check after a change of mode to \val{detect}\dots |
| 3422 |
% \begin{macrocode} |
| 3423 |
\ifnum#1>\m@ne\relax% |
| 3424 |
\@svg@ink@ver@detecttrue% |
| 3425 |
% \end{macrocode} |
| 3426 |
% \dots or if detection was never invoked, do so. |
| 3427 |
% \begin{macrocode} |
| 3428 |
\else% |
| 3429 |
\ifnum#3=\m@ne\relax% |
| 3430 |
\@svg@ink@ver@detecttrue% |
| 3431 |
\fi% |
| 3432 |
\fi% |
| 3433 |
% \end{macrocode} |
| 3434 |
% Enforce the check after a change of \opt{inkscapeexe}. |
| 3435 |
% \begin{macrocode} |
| 3436 |
\else% |
| 3437 |
\@svg@ink@ver@detecttrue% |
| 3438 |
\fi% |
| 3439 |
\fi% |
| 3440 |
\fi% |
| 3441 |
% \end{macrocode} |
| 3442 |
% After evaluating the last settings and maybe setting the trigger for version |
| 3443 |
% detection, the current settings are stored in the main aux file. The detected |
| 3444 |
% version will be expanded during the write to the aux file. |
| 3445 |
% \begin{macrocode} |
| 3446 |
\edef\svg@ink@ver@settings{% |
| 3447 |
{\svg@ink@ver}{\svg@ink@exe}{\noexpand\svg@ink@ver}% |
| 3448 |
}% |
| 3449 |
% \end{macrocode} |
| 3450 |
% Run detection if necessary and store the result in \cs{svg@ink@ver}\dots |
| 3451 |
% \begin{macrocode} |
| 3452 |
\if@svg@ink@ver@detect% |
| 3453 |
\svg@@ink@ver@detect% |
| 3454 |
\else% |
| 3455 |
% \end{macrocode} |
| 3456 |
% \dots or otherwise set previous detected version in automatic mode. |
| 3457 |
% \begin{macrocode} |
| 3458 |
\ifnum\svg@ink@ver=\m@ne\relax% |
| 3459 |
\def\svg@ink@ver{#3}% |
| 3460 |
\fi% |
| 3461 |
\fi% |
| 3462 |
} |
| 3463 |
% \end{macrocode} |
| 3464 |
% If the switch \cs{if@svg@ink@ver@detect} was set by \cs{svg@ink@ver@detect} |
| 3465 |
% during the evaluation of \cs{svg@ink@settings}, which holds the settings of |
| 3466 |
% the last run, this macro is invoked. The call of \app{Inkscape} stored in |
| 3467 |
% \cs{svg@ink@exe} is done with \cs{@@input\textbar"'\dots' -V" } in order to |
| 3468 |
% read from \val{stdout}. |
| 3469 |
% \begin{macrocode} |
| 3470 |
\newcommand*\svg@@ink@ver@detect{% |
| 3471 |
\begingroup% |
| 3472 |
\@makeother\|% |
| 3473 |
\@makeother\&% |
| 3474 |
\everyeof{\noexpand}% |
| 3475 |
\svg@quotes@remove{\svg@ink@exe}% |
| 3476 |
% \end{macrocode} |
| 3477 |
% Keep in mind, that \app{Inkscape} uses |stderr| [sic] to report the used |
| 3478 |
% version of Pango, but as MiK\TeX{} has been fixed by now, \pkg{svg} does not |
| 3479 |
% have to consider anymore. |
| 3480 |
% \begin{macrocode} |
| 3481 |
\edef\svg@tempa{% |
| 3482 |
\edef\noexpand\svg@tempa{\noexpand\@@input|"'\svg@ink@exe' -V " }% |
| 3483 |
}% |
| 3484 |
\svg@tempa% |
| 3485 |
\trim@spaces@in\svg@tempa% |
| 3486 |
% \end{macrocode} |
| 3487 |
% The found version is stored in \cs{svg@tempa} and parsed afterwards. |
| 3488 |
% \begin{macrocode} |
| 3489 |
\long\def\svg@tempb ##1Inkscape ##2.##3\@nil{% |
| 3490 |
\gdef\svg@ink@ver{##2}% |
| 3491 |
% \end{macrocode} |
| 3492 |
% If no version was detected, a warning is written. |
| 3493 |
% \begin{macrocode} |
| 3494 |
\ifnum\svg@ink@ver=\m@ne\relax% |
| 3495 |
\PackageWarning{svg}{% |
| 3496 |
No version of Inkscape was detected by invoking\MessageBreak% |
| 3497 |
`\svg@ink@exe\space-V'\MessageBreak% |
| 3498 |
so the Inkscape export will fail quite sure as the\MessageBreak% |
| 3499 |
command is probably unknown to your OS. You could set\MessageBreak% |
| 3500 |
`inkscapeversion=<version>' manually but this is very\MessageBreak% |
| 3501 |
unlikely to work% |
| 3502 |
}% |
| 3503 |
\fi% |
| 3504 |
}% |
| 3505 |
\expandafter\svg@tempb\svg@tempa Inkscape \m@ne.\@nil% |
| 3506 |
\endgroup% |
| 3507 |
} |
| 3508 |
% \end{macrocode} |
| 3509 |
% Comparing the stored settings from last the last run with current settings. |
| 3510 |
% \begin{macrocode} |
| 3511 |
\AtBeginDocument{\expandafter\svg@ink@ver@detect\svg@ink@ver@settings} |
| 3512 |
% \end{macrocode} |
| 3513 |
% Writing \cs{svg@ink@exe} and \cs{svg@ink@ver} to the main aux-file. |
| 3514 |
% \begin{macrocode} |
| 3515 |
\BeforeClosingMainAux{% |
| 3516 |
\if@filesw% |
| 3517 |
\immediate\write\@mainaux{% |
| 3518 |
\string\gdef\string\svg@ink@ver@settings{\svg@ink@ver@settings}% |
| 3519 |
}% |
| 3520 |
\fi% |
| 3521 |
} |
| 3522 |
% \end{macrocode} |
| 3523 |
% \end{macro}^^A \if@svg@ink@ver@detect |
| 3524 |
% \end{macro}^^A \svg@@ink@ver@detect |
| 3525 |
% \end{macro}^^A \svg@ink@ver@detect |
| 3526 |
% \end{macro}^^A \svg@ink@ver@settings |
| 3527 |
% \begin{macro}{\svg@ink@ver@explore} |
| 3528 |
% \changes{v2.02j}{2020/10/23}{new}^^A |
| 3529 |
% If detecting the used version automatically with \file{inkscape -V} was not |
| 3530 |
% successful, it is tried to explore this by calling \app{Inkscape} through its |
| 3531 |
% command~line~interface with all known variations. If the desired file was |
| 3532 |
% created the used version is stored in \cs{svg@ink@ver}. |
| 3533 |
% \begin{macrocode} |
| 3534 |
\newcommand*\svg@ink@ver@explore[3]{% |
| 3535 |
\begingroup% |
| 3536 |
\@svg@tempswafalse% |
| 3537 |
\@tfor\svg@ink@ver:={1}{0}\do{% |
| 3538 |
\ShellEscape{\svg@ink@cmd{#1}{#2}}% |
| 3539 |
\IfFileExists{#3.\svg@ink@format}{\@svg@tempswatrue}{}% |
| 3540 |
% \end{macrocode} |
| 3541 |
% An output file was found, break loop. |
| 3542 |
% \begin{macrocode} |
| 3543 |
\if@svg@tempswa% |
| 3544 |
\@break@tfor% |
| 3545 |
\fi% |
| 3546 |
}% |
| 3547 |
% \end{macrocode} |
| 3548 |
% If even this attempt fails, an error message is shown. |
| 3549 |
% \begin{macrocode} |
| 3550 |
\if@svg@tempswa% |
| 3551 |
\xdef\svg@ink@ver{\svg@ink@ver}% |
| 3552 |
\else% |
| 3553 |
\PackageError{svg}{Inkscape version not detected}{% |
| 3554 |
It was tried to invoke `\svg@ink@exe'\MessageBreak% |
| 3555 |
for file "#1.\svg@file@ext"\MessageBreak% |
| 3556 |
but no result was produced. Check the log file\MessageBreak% |
| 3557 |
and set `inkscapeversion=<version>' manually.% |
| 3558 |
}% |
| 3559 |
\fi% |
| 3560 |
\endgroup% |
| 3561 |
} |
| 3562 |
% \end{macrocode} |
| 3563 |
% \end{macro}^^A \svg@ink@ver@explore |
| 3564 |
% |
| 3565 |
% |
| 3566 |
% \subsection{Handling path and file names} |
| 3567 |
% |
| 3568 |
% \begin{macro}{\svg@set@input@path} |
| 3569 |
% \changes{v2.01}{2017/11/28}{new}^^A |
| 3570 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@deactivate@dq}}^^A |
| 3571 |
% \begin{macro}{\svg@append@input@path} |
| 3572 |
% \changes{v2.01}{2017/11/28}{new}^^A |
| 3573 |
% \changes{v2.02}{2018/09/07}{avoid duplicates in \cs{input@path}}^^A |
| 3574 |
% In order to import SVG~files from different folders, \cs{svg@set@input@path} |
| 3575 |
% evaluates several macros, which are supposed to be used for holding different |
| 3576 |
% search folders. Any given path will be handled by \cs{svg@normalize@path}. |
| 3577 |
% The optional argument can be used to append an additional search path. |
| 3578 |
% \begin{macrocode} |
| 3579 |
\newcommand*\svg@set@input@path[1][]{% |
| 3580 |
\begingroup% |
| 3581 |
\svg@deactivate@dq% |
| 3582 |
% \end{macrocode} |
| 3583 |
% If a path was already found and stored within \cs{svg@file@path}, it is |
| 3584 |
% searched first and wrapped in curly braces. This is necessary for using |
| 3585 |
% commands like \cs{input}\marg{tex~filename} within SVG~files. |
| 3586 |
% \begin{macrocode} |
| 3587 |
\ifx\svg@file@path\@empty\else% |
| 3588 |
\svg@normalize@path{\svg@file@path}% |
| 3589 |
\edef\svg@file@path{{\svg@file@path}}% |
| 3590 |
\fi% |
| 3591 |
% \end{macrocode} |
| 3592 |
% Afterwards, several search paths are appended. If \cs{svgpath} was used, it |
| 3593 |
% is searched next. If nothing was found, \cs{graphicspath} is considered if |
| 3594 |
% defined followed by a path given in the third argument. If nothing was found |
| 3595 |
% yet, the standard \cs{input@path} is searched last. |
| 3596 |
% \begin{macrocode} |
| 3597 |
\svg@append@input@path{\svg@file@path}{\svg@input@path}% |
| 3598 |
\svg@append@input@path{\svg@file@path}{\Ginput@path}% |
| 3599 |
\IfArgIsEmpty{#1}{}{\svg@append@input@path{\svg@file@path}{{#1}}}% |
| 3600 |
\svg@append@input@path{\svg@file@path}{\input@path}% |
| 3601 |
% \end{macrocode} |
| 3602 |
% Finally, \cs{input@path} is set. |
| 3603 |
% \begin{macrocode} |
| 3604 |
\edef\svg@tempa{% |
| 3605 |
\endgroup% |
| 3606 |
\ifx\svg@file@path\@empty\else% |
| 3607 |
\def\noexpand\input@path{\svg@file@path}% |
| 3608 |
\fi% |
| 3609 |
}% |
| 3610 |
\svg@tempa% |
| 3611 |
} |
| 3612 |
% \end{macrocode} |
| 3613 |
% Only, if a certain search path is defined, it is added. The paths given in |
| 3614 |
% the first argument are compared to each path in the second argument and only |
| 3615 |
% new ones are added. |
| 3616 |
% \begin{macrocode} |
| 3617 |
\newcommand*\svg@append@input@path[2]{% |
| 3618 |
\ifx#2\@undefined\else% |
| 3619 |
\edef\svg@tempb{#2}% |
| 3620 |
\expandafter\@tfor\expandafter\svg@tempa\expandafter:\expandafter=% |
| 3621 |
\svg@tempb\do{% |
| 3622 |
% \end{macrocode} |
| 3623 |
% Passing each new path to \cs{svg@normalize@path}. If a path already exists, |
| 3624 |
% switch \cs{if@svg@tempswa} is set to \val{false}. |
| 3625 |
% \begin{macrocode} |
| 3626 |
\ifx\svg@tempa\@empty\else% |
| 3627 |
\@svg@tempswatrue% |
| 3628 |
\svg@normalize@path{\svg@tempa}% |
| 3629 |
\expandafter\@tfor\expandafter\svg@tempb\expandafter:\expandafter=% |
| 3630 |
#1\do{% |
| 3631 |
\ifx\svg@tempa\svg@tempb% |
| 3632 |
\@svg@tempswafalse% |
| 3633 |
\@break@tfor% |
| 3634 |
\fi% |
| 3635 |
}% |
| 3636 |
\if@svg@tempswa% |
| 3637 |
\edef#1{#1{\svg@tempa}}% |
| 3638 |
\fi% |
| 3639 |
\fi% |
| 3640 |
}% |
| 3641 |
\fi% |
| 3642 |
} |
| 3643 |
% \end{macrocode} |
| 3644 |
% \end{macro}^^A \svg@append@input@path |
| 3645 |
% \end{macro}^^A \svg@set@input@path |
| 3646 |
% \begin{macro}{\svg@get@path} |
| 3647 |
% \changes{v2.01}{2017/11/28}{using \cs{svg@set@input@path}}^^A |
| 3648 |
% \changes{v2.01}{2017/11/28}{using \cs{trim@spaces}}^^A |
| 3649 |
% \begin{macro}{\if@svg@file@found} |
| 3650 |
% \begin{macro}{\svg@file@path} |
| 3651 |
% \begin{macro}{\svg@file@name} |
| 3652 |
% \begin{macro}{\svg@file@base} |
| 3653 |
% \begin{macro}{\svg@file@suffix} |
| 3654 |
% The command \cs{svg@get@path} tries to find a given SVG~file. If the |
| 3655 |
% searched file wasn't found in the current path, all paths given with |
| 3656 |
% \cs{svgpath} are evaluated. If there was no appropriate file again, all paths |
| 3657 |
% given by \cs{graphicspath} are examined. In the last step, a given path |
| 3658 |
% within the second mandatory argument is browsed. The results for file path |
| 3659 |
% and name are stored in \cs{svg@file@path} and \cs{svg@file@name} as well as |
| 3660 |
% the compound of both is saved in \cs{svg@file@base}. |
| 3661 |
% \begin{macrocode} |
| 3662 |
\newif\if@svg@file@found |
| 3663 |
\newcommand*\svg@file@path{} |
| 3664 |
\newcommand*\svg@file@name{} |
| 3665 |
\newcommand*\svg@file@base{} |
| 3666 |
\newcommand*\svg@file@suffix{} |
| 3667 |
\newcommand*\svg@get@path[3][\svg@file@ext]{% |
| 3668 |
\begingroup% |
| 3669 |
\svg@filename@parse[{#1}]{#2}% |
| 3670 |
\IfArgIsEmpty{#1}{% |
| 3671 |
\edef\svg@tempa{\filename@area\filename@base.\filename@ext}% |
| 3672 |
}{% |
| 3673 |
\edef\svg@tempa{\filename@area\filename@base.#1}% |
| 3674 |
}% |
| 3675 |
% \end{macrocode} |
| 3676 |
% After calling \cs{svg@set@input@path}, all search paths are stored in |
| 3677 |
% \cs{input@path}, a single path given in the third argument will also be |
| 3678 |
% considered. |
| 3679 |
% \begin{macrocode} |
| 3680 |
\svg@set@input@path[{#3}]% |
| 3681 |
% \end{macrocode} |
| 3682 |
% The specified file is searched with \cs{IfFileExists}. If the file search was |
| 3683 |
% successful, the macro \cs{svg@filename@parse} is called with the result. |
| 3684 |
% \begin{macrocode} |
| 3685 |
\@svg@tempswafalse% |
| 3686 |
\expandafter\IfFileExists\expandafter{\svg@tempa}{% |
| 3687 |
\expandafter\svg@quotes@check\expandafter{\svg@tempa}% |
| 3688 |
\if@svg@quotes@found\else% |
| 3689 |
\svg@quotes@remove{\@filef@und}% |
| 3690 |
\fi% |
| 3691 |
\@svg@tempswatrue% |
| 3692 |
\edef\@filef@und{\expandafter\trim@spaces\expandafter{\@filef@und}}% |
| 3693 |
\svg@filename@parse[{#1}]{\@filef@und}% |
| 3694 |
}{}% |
| 3695 |
\edef\svg@tempa{% |
| 3696 |
\endgroup% |
| 3697 |
\if@svg@tempswa% |
| 3698 |
\noexpand\@svg@file@foundtrue% |
| 3699 |
\def\noexpand\svg@file@path{\filename@area}% |
| 3700 |
\def\noexpand\svg@file@name{\filename@base}% |
| 3701 |
\def\noexpand\svg@file@base{\filename@area\filename@base}% |
| 3702 |
\else% |
| 3703 |
\noexpand\@svg@file@foundfalse% |
| 3704 |
\def\noexpand\svg@file@path{}% |
| 3705 |
\def\noexpand\svg@file@name{#2}% |
| 3706 |
\def\noexpand\svg@file@base{#2}% |
| 3707 |
\fi% |
| 3708 |
}% |
| 3709 |
\svg@tempa% |
| 3710 |
} |
| 3711 |
% \end{macrocode} |
| 3712 |
% \end{macro}^^A \svg@file@suffix |
| 3713 |
% \end{macro}^^A \svg@file@base |
| 3714 |
% \end{macro}^^A \svg@file@name |
| 3715 |
% \end{macro}^^A \svg@file@path |
| 3716 |
% \end{macro}^^A \if@svg@file@found |
| 3717 |
% \end{macro}^^A \svg@get@path |
| 3718 |
% |
| 3719 |
% |
| 3720 |
% |
| 3721 |
% \subsection{Patches} |
| 3722 |
% |
| 3723 |
% \begin{macro}{\svg@patches} |
| 3724 |
% \changes{v2.02b}{2018/11/12}{fix bug for package \pkg{tikzscale}: store |
| 3725 |
% original definitions of \cs{picture} and \cs{includegraphics} right after |
| 3726 |
% loading package \pkg{svg}}^^A |
| 3727 |
% \begin{macro}{\svg@picture@saved} |
| 3728 |
% \begin{macro}{\svg@includegraphics@saved} |
| 3729 |
% For including the export results from \app{Inkscape} with \LaTeX~support |
| 3730 |
% enabled, there are some patches necessary for environment \env{picture} and |
| 3731 |
% \cs{includegraphics}. These patches are done with \cs{svg@patches}. |
| 3732 |
% \begin{macrocode} |
| 3733 |
\newcommand*\svg@picture@saved{} |
| 3734 |
\let\svg@picture@saved\picture |
| 3735 |
\newcommand*\svg@includegraphics@saved{} |
| 3736 |
\let\svg@includegraphics@saved\includegraphics |
| 3737 |
\newcommand*\svg@patches[1]{% |
| 3738 |
\let\picture\svg@picture@patched% |
| 3739 |
\let\includegraphics\svg@includegraphics@patched% |
| 3740 |
\edef\svg@includegraphics@file{#1}% |
| 3741 |
} |
| 3742 |
% \end{macrocode} |
| 3743 |
% \end{macro}^^A \svg@includegraphics@saved |
| 3744 |
% \end{macro}^^A \svg@picture@saved |
| 3745 |
% \end{macro}^^A \svg@patches |
| 3746 |
% \begin{macro}{\svg@picture@patched} |
| 3747 |
% \begin{macro}{\svg@pictur@patched} |
| 3748 |
% In order to provide the possibility specify the desired width of a graphic, |
| 3749 |
% the appropriate \cs{unitlength} is calculated at the beginning of the |
| 3750 |
% \env{picture}~environment. |
| 3751 |
% \begin{macrocode} |
| 3752 |
\newcommand*\svg@picture@patched{} |
| 3753 |
\newcommand*\svg@pictur@patched{} |
| 3754 |
\long\def\svg@picture@patched#1{\svg@pictur@patched@#1} |
| 3755 |
\def\svg@pictur@patched@(#1,#2){% |
| 3756 |
\svg@wrn@scale% |
| 3757 |
% \end{macrocode} |
| 3758 |
% If a desired height is present, the resulting \cs{unitlength} is calculated |
| 3759 |
% with the ratio of the coordinates of the \env{picture}~environment given as |
| 3760 |
% arguments for x- and y-direction by using \cs{Gscale@div}. With this factor, |
| 3761 |
% \cs{unitlength}---which is connected to the x-coordinate---can be scaled in a |
| 3762 |
% suitable manner. |
| 3763 |
% \begin{macrocode} |
| 3764 |
\ifdim\svg@param@height>\z@\relax% |
| 3765 |
\Gscale@div\svg@tempa{#1\p@}{#2\p@}% |
| 3766 |
\setlength\unitlength{\svg@param@height}% |
| 3767 |
\setlength\unitlength{\svg@tempa\unitlength}% |
| 3768 |
\ifdim\svg@param@width>\z@\relax% |
| 3769 |
\ifdim\unitlength>\svg@param@width\relax% |
| 3770 |
\setlength\unitlength{\svg@param@width}% |
| 3771 |
\fi% |
| 3772 |
\fi% |
| 3773 |
\else% |
| 3774 |
% \end{macrocode} |
| 3775 |
% If no height is given, \cs{unitlength} can be set easily. |
| 3776 |
% \begin{macrocode} |
| 3777 |
\ifdim\svg@param@width>\z@\relax% |
| 3778 |
\setlength\unitlength{\svg@param@width}% |
| 3779 |
\else% |
| 3780 |
\setlength\unitlength{\svg@param@scale\unitlength}% |
| 3781 |
\fi% |
| 3782 |
\fi% |
| 3783 |
% \end{macrocode} |
| 3784 |
% After setting \cs{unitlength}, the \env{picture}~environment can be called |
| 3785 |
% with its original definition. |
| 3786 |
% \begin{macrocode} |
| 3787 |
\svg@picture@saved(#1,#2)% |
| 3788 |
} |
| 3789 |
% \end{macrocode} |
| 3790 |
% \end{macro}^^A \svg@pictur@patched |
| 3791 |
% \end{macro}^^A \svg@picture@patched |
| 3792 |
% \begin{macro}{\svg@includegraphics@patched} |
| 3793 |
% \begin{macro}{\svg@includegraphics@file} |
| 3794 |
% The patch to \cs{includegraphics} is meant to dissolve the \app{Inkscape} bug |
| 3795 |
% concerning the inclusion of more PDF~pages than actually are existing. |
| 3796 |
% |
| 3797 |
% The given optional parameters to \cs{includegraphics} are processed and the |
| 3798 |
% counter \cnt{svg@param@currpage} is set to the value of a given \prm{page}. |
| 3799 |
% The value of parameter \prm{width} is ignored. |
| 3800 |
% \begin{macrocode} |
| 3801 |
\DefineFamily{SVGpatch} |
| 3802 |
\DefineFamilyMember{SVGpatch} |
| 3803 |
\newcounter{svg@param@currpage} |
| 3804 |
\setcounter{svg@param@currpage}{\m@ne} |
| 3805 |
\FamilyCounterKey{SVGpatch}{page}{svg@param@currpage} |
| 3806 |
\DefineFamilyKey{SVGpatch}{width}{\FamilyKeyStateProcessed} |
| 3807 |
\newcommand*\svg@includegraphics@file{} |
| 3808 |
\newcommand*\svg@includegraphics@patched[2][]{% |
| 3809 |
\FamilyOptions{SVGpatch}{#1}% |
| 3810 |
% \end{macrocode} |
| 3811 |
% If option \opt{lastpage} was set to \val{false}, each page is included---even |
| 3812 |
% if it doesn't exist, which may cause errors. |
| 3813 |
% \begin{macrocode} |
| 3814 |
\ifnum\value{svg@param@lastpage}<\z@\relax% |
| 3815 |
\FamilySetCounter{SVGpatch}{page}{svg@param@currpage}{% |
| 3816 |
\the\value{svg@param@lastpage}% |
| 3817 |
}% |
| 3818 |
\fi% |
| 3819 |
% \end{macrocode} |
| 3820 |
% Only if counter \cnt{svg@param@lastpage} is smaller than |
| 3821 |
% \cnt{svg@param@currpage}, pages are included, where \cnt{svg@param@lastpage} |
| 3822 |
% was either given as a number with parameter \prm{lastpage} or was |
| 3823 |
% automatically calculated with \cs{svg@get@lastpage}. |
| 3824 |
% \begin{macrocode} |
| 3825 |
\ifnum\value{svg@param@currpage}>\value{svg@param@lastpage}\relax\else% |
| 3826 |
% \end{macrocode} |
| 3827 |
% A page is included with the original definition of \cs{includegraphics}. All |
| 3828 |
% optional parameters are passed. |
| 3829 |
% \begin{macrocode} |
| 3830 |
\svg@includegraphics@saved[{#1}]{\svg@includegraphics@file}% |
| 3831 |
\fi% |
| 3832 |
} |
| 3833 |
% \end{macrocode} |
| 3834 |
% \end{macro}^^A \svg@includegraphics@file |
| 3835 |
% \end{macro}^^A \svg@includegraphics@patched |
| 3836 |
% |
| 3837 |
% \iffalse |
| 3838 |
%</body> |
| 3839 |
%</package&main> |
| 3840 |
%<*package&option> |
| 3841 |
% \fi |
| 3842 |
% |
| 3843 |
% |
| 3844 |
% |
| 3845 |
% \section{Extracting independent graphic files with \pkg{svg-extract}} |
| 3846 |
% \subsection{Options} |
| 3847 |
% |
| 3848 |
% For package \pkg{svg-extract} the user\hbox{-}interface of package \pkg{svg} |
| 3849 |
% is extended. The following options can either be set with \cs{svgsetup} or be |
| 3850 |
% used as optional parameters for \cs{includesvg} and \cs{includeinkscape}. |
| 3851 |
% |
| 3852 |
% \begin{macro}{\svg@dummy@key} |
| 3853 |
% If package \pkg{svg-extract} wasn't loaded, the following options are defined |
| 3854 |
% for package \pkg{svg} in order to raise a warning message. Primarily this is |
| 3855 |
% done for compatibility reasons. |
| 3856 |
% \begin{macrocode} |
| 3857 |
%<*main> |
| 3858 |
\DefineFamilyMember[.dummy]{SVG} |
| 3859 |
\newcommand*\svg@dummy@key[2][]{% |
| 3860 |
\@ifpackageloaded{svg-extract}{}{% |
| 3861 |
\IfArgIsEmpty{#1}{% |
| 3862 |
\DefineFamilyKey[.dummy]{SVG}{#2}{% |
| 3863 |
\PackageWarning{svg}{% |
| 3864 |
The option key `#2' can only\MessageBreak% |
| 3865 |
be used with package `svg-extract', but\MessageBreak% |
| 3866 |
you didn't load it% |
| 3867 |
}% |
| 3868 |
\FamilyKeyStateProcessed% |
| 3869 |
}% |
| 3870 |
}{% |
| 3871 |
\DefineFamilyKey[.dummy]{SVG}{#2}[{#1}]{% |
| 3872 |
\PackageWarning{svg}{% |
| 3873 |
The option key `#2' can only\MessageBreak% |
| 3874 |
be used with package `svg-extract', but\MessageBreak% |
| 3875 |
you didn't load it% |
| 3876 |
}% |
| 3877 |
\FamilyKeyStateProcessed% |
| 3878 |
}% |
| 3879 |
}% |
| 3880 |
% \end{macrocode} |
| 3881 |
% Before package \pkg{svg-extract} the given key |#2| of family member |.dummy| |
| 3882 |
% is relaxed. |
| 3883 |
% \begin{macrocode} |
| 3884 |
\AfterPackage{svg-extract}{\RelaxFamilyKey[.dummy]{SVG}{#2}}% |
| 3885 |
}% |
| 3886 |
} |
| 3887 |
%</main> |
| 3888 |
% \end{macrocode} |
| 3889 |
% \end{macro}^^A \svg@dummy@key |
| 3890 |
% |
| 3891 |
% |
| 3892 |
% |
| 3893 |
% \subsubsection{Controlling the extract process} |
| 3894 |
% |
| 3895 |
% \begin{option}{extract} |
| 3896 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 3897 |
% \begin{macro}{\if@svgx@run} |
| 3898 |
% With option \opt{extract} it can be controlled, if the extraction of |
| 3899 |
% independent graphic files should be done. |
| 3900 |
% \begin{macrocode} |
| 3901 |
%<*main> |
| 3902 |
\svg@dummy@key[true]{extract} |
| 3903 |
%</main> |
| 3904 |
%<*extract> |
| 3905 |
\newif\if@svgx@run |
| 3906 |
\DefineFamilyKey{SVG}{extract}[true]{% |
| 3907 |
\lowercase{\def\svg@tempa{#1}}% |
| 3908 |
\FamilySetNumerical{SVG}{extract}{svg@tempa}{% |
| 3909 |
{false}{0},{off}{0},{no}{0},% |
| 3910 |
{true}{1},{on}{1},{yes}{1},{onlynewer}{1},{newer}{1},% |
| 3911 |
{overwrite}{1},{force}{1},{forced}{1},% |
| 3912 |
{pdf}{2},{eps}{3},{ps}{4}% |
| 3913 |
}{\svg@tempa}% |
| 3914 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 3915 |
\ifcase\svg@tempa\relax% false |
| 3916 |
\@svgx@runfalse% |
| 3917 |
\or% true |
| 3918 |
\@svgx@runtrue% |
| 3919 |
\or% pdf |
| 3920 |
\FamilyOptions{SVG}{extractformat=pdf}% |
| 3921 |
\or% eps |
| 3922 |
\FamilyOptions{SVG}{extractformat=eps}% |
| 3923 |
\or% ps |
| 3924 |
\FamilyOptions{SVG}{extractformat=ps}% |
| 3925 |
\fi% |
| 3926 |
\fi% |
| 3927 |
} |
| 3928 |
%</extract> |
| 3929 |
% \end{macrocode} |
| 3930 |
% \end{macro}^^A \if@svgx@run |
| 3931 |
% \end{option}^^A extract |
| 3932 |
% \begin{option}{on} |
| 3933 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 3934 |
% \begin{option}{off} |
| 3935 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 3936 |
% Package options which can be used to switch functionality on or off during |
| 3937 |
% the loading of package \pkg{svg-extract}. |
| 3938 |
% \begin{macrocode} |
| 3939 |
%<*extract> |
| 3940 |
\DeclareOption{on}{\FamilyOptions{SVG}{extract=true}} |
| 3941 |
\DeclareOption{off}{\FamilyOptions{SVG}{extract=false}} |
| 3942 |
%</extract> |
| 3943 |
% \end{macrocode} |
| 3944 |
% \end{option}^^A off |
| 3945 |
% \end{option}^^A on |
| 3946 |
% \begin{option}{extractformat} |
| 3947 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 3948 |
% \begin{macro}{\svgx@format} |
| 3949 |
% \begin{option}{pdf} |
| 3950 |
% \changes{v2.00}{2017/03/02}{deprecated}^^A |
| 3951 |
% \begin{option}{eps} |
| 3952 |
% \changes{v2.00}{2017/03/02}{deprecated}^^A |
| 3953 |
% Option \opt{extractformat} controls the output format (\val{pdf/eps/ps}). It |
| 3954 |
% is set to \val{pdf} or, if dvi output could be detected, to \val{eps} during |
| 3955 |
% initialization. |
| 3956 |
% \begin{macrocode} |
| 3957 |
%<*main> |
| 3958 |
\svg@dummy@key{extractformat} |
| 3959 |
\svg@dummy@key[true]{pdf} |
| 3960 |
\svg@dummy@key[true]{eps} |
| 3961 |
%</main> |
| 3962 |
%<*extract> |
| 3963 |
\newcommand*\svgx@format{pdf} |
| 3964 |
\ifxetex\else\ifpdf\else |
| 3965 |
\renewcommand*\svgx@format{eps} |
| 3966 |
\fi\fi |
| 3967 |
\DefineFamilyKey{SVG}{extractformat}{% |
| 3968 |
\lowercase{\edef\svgx@format{#1}}% |
| 3969 |
\FamilyKeyStateProcessed% |
| 3970 |
} |
| 3971 |
\DefineFamilyKey{SVG}{pdf}[true]{% |
| 3972 |
\FamilySetBool{SVG}{pdf}{@svg@tempswa}{#1}% |
| 3973 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 3974 |
\if@svg@tempswa% |
| 3975 |
\svgx@ifinlist{pdf}{\svgx@format}{}{% |
| 3976 |
\edef\svgx@format{\svgx@format,pdf}% |
| 3977 |
}% |
| 3978 |
\svg@deprecated@key{pdf}{extractformat={\svgx@format}}% |
| 3979 |
\else% |
| 3980 |
\FamilyKeyStateUnknownValue% |
| 3981 |
\fi% |
| 3982 |
\fi% |
| 3983 |
} |
| 3984 |
\DefineFamilyKey{SVG}{eps}[true]{% |
| 3985 |
\FamilySetBool{SVG}{eps}{@svg@tempswa}{#1}% |
| 3986 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 3987 |
\if@svg@tempswa% |
| 3988 |
\svgx@ifinlist{eps}{\svgx@format}{}{% |
| 3989 |
\edef\svgx@format{\svgx@format,eps}% |
| 3990 |
}% |
| 3991 |
\svg@deprecated@key{eps}{extractformat={\svgx@format}}% |
| 3992 |
\else% |
| 3993 |
\FamilyKeyStateUnknownValue% |
| 3994 |
\fi% |
| 3995 |
\fi% |
| 3996 |
} |
| 3997 |
%</extract> |
| 3998 |
% \end{macrocode} |
| 3999 |
% \end{option}^^A eps |
| 4000 |
% \end{option}^^A pdf |
| 4001 |
% \end{macro}^^A \svgx@format |
| 4002 |
% \end{option}^^A extractformat |
| 4003 |
% \begin{option}{extractpreamble} |
| 4004 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4005 |
% \begin{option}{preamble} |
| 4006 |
% \changes{v2.00}{2017/02/24}{deprecated}^^A |
| 4007 |
% \begin{macro}{\svgx@preamble} |
| 4008 |
% \begin{option}{extractpreambleend} |
| 4009 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4010 |
% \begin{option}{end} |
| 4011 |
% \changes{v2.00}{2017/02/24}{deprecated}^^A |
| 4012 |
% \begin{macro}{\svgx@endpreamble} |
| 4013 |
% For the extraction process, a preamble is necessary for a separate auxiliary |
| 4014 |
% \LaTeX~file. By default, the preamble of the main document is used, which end |
| 4015 |
% is detected at \cs{begin}|{document}|. |
| 4016 |
% \begin{macrocode} |
| 4017 |
%<*main> |
| 4018 |
\svg@dummy@key{extractpreamble} |
| 4019 |
\svg@dummy@key{preamble} |
| 4020 |
\svg@dummy@key{extractpreambleend} |
| 4021 |
\svg@dummy@key{end} |
| 4022 |
%</main> |
| 4023 |
%<*extract> |
| 4024 |
\newcommand*\svgx@preamble{\jobname.\svgx@latex@ext}% |
| 4025 |
\DefineFamilyKey{SVG}{extractpreamble}{% |
| 4026 |
\renewcommand*\svgx@preamble{#1}% |
| 4027 |
\FamilyKeyStateProcessed% |
| 4028 |
} |
| 4029 |
\DefineFamilyKey{SVG}{preamble}{% |
| 4030 |
\svg@deprecated@key[svg-extract]{preamble=#1}{extractpreamble=#1}% |
| 4031 |
} |
| 4032 |
\newcommand*\svgx@endpreamble{} |
| 4033 |
\expandafter\def\expandafter\svgx@endpreamble\expandafter{% |
| 4034 |
\csname begin\endcsname{document}% |
| 4035 |
} |
| 4036 |
\DefineFamilyKey{SVG}{extractpreambleend}{% |
| 4037 |
\renewcommand*\svgx@endpreamble{#1}% |
| 4038 |
\FamilyKeyStateProcessed% |
| 4039 |
} |
| 4040 |
\DefineFamilyKey{SVG}{end}{% |
| 4041 |
\svg@deprecated@key[svg-extract]{end=#1}{extractpreambleend=#1}% |
| 4042 |
} |
| 4043 |
%</extract> |
| 4044 |
% \end{macrocode} |
| 4045 |
% \end{macro}^^A \svgx@endpreamble |
| 4046 |
% \end{option}^^A end |
| 4047 |
% \end{option}^^A extractpreambleend |
| 4048 |
% \end{macro}^^A \svgx@preamble |
| 4049 |
% \end{option}^^A preamble |
| 4050 |
% \end{option}^^A extractpreamble |
| 4051 |
% \begin{option}{extractruns} |
| 4052 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4053 |
% \begin{counter}{svgx@runs} |
| 4054 |
% With this option, the number of \LaTeX~runs for the separate auxiliary file |
| 4055 |
% can be set. |
| 4056 |
% \begin{macrocode} |
| 4057 |
%<*main> |
| 4058 |
\svg@dummy@key{extractruns} |
| 4059 |
%</main> |
| 4060 |
%<*extract> |
| 4061 |
\newcounter{svgx@runs} |
| 4062 |
\DefineFamilyKey{SVG}{extractruns}{% |
| 4063 |
\FamilySetCounter{SVG}{extractruns}{svgx@runs}{#1}% |
| 4064 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 4065 |
\ifnum\value{svgx@runs}<\@ne\relax% |
| 4066 |
\PackageWarning{svg-extract}{% |
| 4067 |
The count for runs has to be at least one% |
| 4068 |
}% |
| 4069 |
\FamilySetCounter{SVG}{extractruns}{svgx@runs}{\@ne}% |
| 4070 |
\fi% |
| 4071 |
\fi% |
| 4072 |
} |
| 4073 |
%</extract> |
| 4074 |
% \end{macrocode} |
| 4075 |
% \end{counter}^^A svgx@runs |
| 4076 |
% \end{option}^^A extractruns |
| 4077 |
% \begin{option}{latexexe} |
| 4078 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4079 |
% \begin{option}{pdflatex} |
| 4080 |
% \changes{v2.00}{2017/02/24}{deprecated}^^A |
| 4081 |
% \begin{macro}{\svgx@latex@exe} |
| 4082 |
% \begin{option}{latexext} |
| 4083 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4084 |
% \begin{macro}{\svgx@latex@ext} |
| 4085 |
% \begin{option}{latexopt} |
| 4086 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4087 |
% \begin{macro}{\svgx@latex@opt} |
| 4088 |
% The command and facultative options for the \LaTeX~call of the separate |
| 4089 |
% auxiliary file. The default is set according to the currently used engine. |
| 4090 |
% \begin{macrocode} |
| 4091 |
%<*main> |
| 4092 |
\svg@dummy@key{latexexe} |
| 4093 |
\svg@dummy@key{pdflatex} |
| 4094 |
\svg@dummy@key{latexext} |
| 4095 |
\svg@dummy@key{latexopt} |
| 4096 |
%</main> |
| 4097 |
%<*extract> |
| 4098 |
\ifxetex |
| 4099 |
\newcommand*\svgx@latex@exe{xelatex} |
| 4100 |
\else\ifluatex |
| 4101 |
\ifpdf |
| 4102 |
\newcommand*\svgx@latex@exe{lualatex} |
| 4103 |
\else |
| 4104 |
\newcommand*\svgx@latex@exe{lualatex --output-format=dvi} |
| 4105 |
\fi |
| 4106 |
\else\ifpdf |
| 4107 |
\newcommand*\svgx@latex@exe{pdflatex} |
| 4108 |
\else |
| 4109 |
\newcommand*\svgx@latex@exe{latex} |
| 4110 |
\fi\fi\fi |
| 4111 |
\DefineFamilyKey{SVG}{latexexe}{% |
| 4112 |
\renewcommand*\svgx@latex@exe{#1}% |
| 4113 |
\FamilyKeyStateProcessed% |
| 4114 |
} |
| 4115 |
\DefineFamilyKey{SVG}{pdflatex}{% |
| 4116 |
\svg@deprecated@key[svg-extract]{pdflatex=#1}{latexexe=#1}% |
| 4117 |
} |
| 4118 |
\newcommand*\svgx@latex@ext{tex} |
| 4119 |
\DefineFamilyKey{SVG}{latexext}{% |
| 4120 |
\renewcommand*\svgx@latex@ext{#1}% |
| 4121 |
\FamilyKeyStateProcessed% |
| 4122 |
} |
| 4123 |
\newcommand*\svgx@latex@opt{} |
| 4124 |
\DefineFamilyKey{SVG}{latexopt}{% |
| 4125 |
\renewcommand*\svgx@latex@opt{#1}% |
| 4126 |
\FamilyKeyStateProcessed% |
| 4127 |
} |
| 4128 |
%</extract> |
| 4129 |
% \end{macrocode} |
| 4130 |
% \end{macro}^^A \svgx@latex@opt |
| 4131 |
% \end{option}^^A latexopt |
| 4132 |
% \end{macro}^^A \svgx@latex@ext |
| 4133 |
% \end{option}^^A latexext |
| 4134 |
% \end{macro}^^A \svgx@latex@exe |
| 4135 |
% \end{option}^^A latexexe |
| 4136 |
% \end{option}^^A pdflatexexe |
| 4137 |
% \begin{option}{dvipsopt} |
| 4138 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4139 |
% \begin{macro}{\svgx@dvips@exe} |
| 4140 |
% \begin{macro}{\svgx@dvips@opt} |
| 4141 |
% \begin{option}{pstoepsopt} |
| 4142 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4143 |
% \begin{macro}{\svgx@pstoeps@exe} |
| 4144 |
% \begin{macro}{\svgx@pstoeps@opt} |
| 4145 |
% \begin{option}{pstopdfopt} |
| 4146 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4147 |
% \begin{macro}{\svgx@pstopdf@exe} |
| 4148 |
% \begin{macro}{\svgx@pstopdf@opt} |
| 4149 |
% \begin{option}{pdftoepsopt} |
| 4150 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4151 |
% \begin{macro}{\svgx@pdftoeps@exe} |
| 4152 |
% \begin{macro}{\svgx@pdftoeps@opt} |
| 4153 |
% \begin{option}{pdftopsopt} |
| 4154 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4155 |
% \begin{macro}{\svgx@pdftops@exe} |
| 4156 |
% \begin{macro}{\svgx@pdftops@opt} |
| 4157 |
% \begin{option}{pdftops} |
| 4158 |
% \changes{v2.00}{2017/02/24}{deprecated}^^A |
| 4159 |
% Options and macros for calling convert commands, which are supplied by most |
| 4160 |
% \LaTeX~distributions. These are used to generate all files, which are |
| 4161 |
% supported by option \opt{extractformat}, as they don't need an additional |
| 4162 |
% application. |
| 4163 |
% \begin{macrocode} |
| 4164 |
%<*main> |
| 4165 |
\svg@dummy@key{dvipsopt} |
| 4166 |
\svg@dummy@key{pstoepsopt} |
| 4167 |
\svg@dummy@key{pstopdfopt} |
| 4168 |
\svg@dummy@key{pdftoepsopt} |
| 4169 |
\svg@dummy@key{pdftopsopt} |
| 4170 |
\svg@dummy@key{pdftops} |
| 4171 |
%</main> |
| 4172 |
%<*extract> |
| 4173 |
\newcommand*\svgx@dvips@exe{dvips} |
| 4174 |
\newcommand*\svgx@dvips@opt{} |
| 4175 |
\DefineFamilyKey{SVG}{dvipsopt}{% |
| 4176 |
\renewcommand*\svgx@dvips@opt{#1}% |
| 4177 |
\FamilyKeyStateProcessed% |
| 4178 |
} |
| 4179 |
\newcommand*\svgx@pstoeps@exe{ps2eps} |
| 4180 |
\newcommand*\svgx@pstoeps@opt{-B -C} |
| 4181 |
\DefineFamilyKey{SVG}{pstoepsopt}{% |
| 4182 |
\renewcommand*\svgx@pstoeps@opt{#1}% |
| 4183 |
\FamilyKeyStateProcessed% |
| 4184 |
} |
| 4185 |
\newcommand*\svgx@pstopdf@exe{ps2pdf} |
| 4186 |
\newcommand*\svgx@pstopdf@opt{} |
| 4187 |
\DefineFamilyKey{SVG}{pstopdfopt}{% |
| 4188 |
\renewcommand*\svgx@pstopdf@opt{#1}% |
| 4189 |
\FamilyKeyStateProcessed% |
| 4190 |
} |
| 4191 |
\newcommand*\svgx@pdftoeps@exe{pdftops -eps} |
| 4192 |
\newcommand*\svgx@pdftoeps@opt{} |
| 4193 |
\DefineFamilyKey{SVG}{pdftoepsopt}{% |
| 4194 |
\renewcommand*\svgx@pdftoeps@opt{#1}% |
| 4195 |
\FamilyKeyStateProcessed% |
| 4196 |
} |
| 4197 |
\newcommand*\svgx@pdftops@exe{pdftops} |
| 4198 |
\newcommand*\svgx@pdftops@opt{} |
| 4199 |
\DefineFamilyKey{SVG}{pdftopsopt}{% |
| 4200 |
\renewcommand*\svgx@pdftops@opt{#1}% |
| 4201 |
\FamilyKeyStateProcessed% |
| 4202 |
} |
| 4203 |
\DefineFamilyKey{SVG}{pdftops}{% |
| 4204 |
\PackageWarning{svg-extract}{% |
| 4205 |
The option key `pdftops' is deprecated. \MessageBreak% |
| 4206 |
You should use either `pdftoepsopt' or\MessageBreak% |
| 4207 |
`pdftopsopt' instead. See the manual for\MessageBreak% |
| 4208 |
more. Nothing was done% |
| 4209 |
}% |
| 4210 |
\FamilyKeyStateProcessed% |
| 4211 |
} |
| 4212 |
%</extract> |
| 4213 |
% \end{macrocode} |
| 4214 |
% \end{option}^^A pdftops |
| 4215 |
% \end{macro}^^A \svgx@pdftops@opt |
| 4216 |
% \end{macro}^^A \svgx@pdftops@exe |
| 4217 |
% \end{option}^^A pdftopsopt |
| 4218 |
% \end{macro}^^A \svgx@pdftoeps@opt |
| 4219 |
% \end{macro}^^A \svgx@pdftoeps@exe |
| 4220 |
% \end{option}^^A pdftoepsopt |
| 4221 |
% \end{macro}^^A \svgx@pstopdf@opt |
| 4222 |
% \end{macro}^^A \svgx@pstopdf@exe |
| 4223 |
% \end{option}^^A pstopdfopt |
| 4224 |
% \end{macro}^^A \svgx@pstoeps@opt |
| 4225 |
% \end{macro}^^A \svgx@pstoeps@exe |
| 4226 |
% \end{option}^^A pstoepsopt |
| 4227 |
% \end{macro}^^A \svgx@dvips@opt |
| 4228 |
% \end{macro}^^A \svgx@dvips@exe |
| 4229 |
% \end{option}^^A dvipsopt |
| 4230 |
% |
| 4231 |
% |
| 4232 |
% |
| 4233 |
% \subsubsection{Invoking external application for graphic conversion} |
| 4234 |
% |
| 4235 |
% Besides the use of a conversion tool supplied by the \LaTeX~distribution, |
| 4236 |
% the applications \app{ImageMagick} and \app{Ghostscript} can be used for |
| 4237 |
% converting graphics. |
| 4238 |
% |
| 4239 |
% \begin{option}{convert} |
| 4240 |
% \changes{v2.00}{2017/02/24}{changed/extended}^^A |
| 4241 |
% \begin{macro}{\if@svgx@cnv@run} |
| 4242 |
% \begin{macro}{\svgx@cnv@cmd} |
| 4243 |
% The option \opt{convert} can be used to define, which of both applications |
| 4244 |
% should be use. \app{ImageMagick} is set by default. |
| 4245 |
% \begin{macrocode} |
| 4246 |
%<*main> |
| 4247 |
\svg@dummy@key[true]{convert} |
| 4248 |
%</main> |
| 4249 |
%<*extract> |
| 4250 |
\newif\if@svgx@cnv@run |
| 4251 |
\newcommand*\svgx@cnv@cmd{} |
| 4252 |
\DefineFamilyKey{SVG}{convert}[true]{% |
| 4253 |
\FamilySetNumerical{SVG}{convert}{svg@tempa}{% |
| 4254 |
{false}{0},{off}{0},{no}{0},% |
| 4255 |
{true}{1},{on}{1},{yes}{1},{onlynewer}{1},{newer}{1},% |
| 4256 |
{overwrite}{1},{force}{1},{forced}{1},% |
| 4257 |
{magick}{2},{imagemagick}{2},{convert}{2},% |
| 4258 |
{gs}{3},{ghostscript}{3},% |
| 4259 |
{gs64}{4},{ghostscript64}{4},% |
| 4260 |
{gs32}{5},{ghostscript32}{5}% |
| 4261 |
}{#1}% |
| 4262 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 4263 |
\ifcase\svg@tempa\relax% false |
| 4264 |
\@svgx@cnv@runfalse% |
| 4265 |
\or% true |
| 4266 |
\@svgx@cnv@runtrue% |
| 4267 |
\or% magick |
| 4268 |
\@svgx@cnv@runtrue% |
| 4269 |
\renewcommand*\svgx@cnv@cmd{\svgx@magick@cmd}% |
| 4270 |
\or% gs |
| 4271 |
\@svgx@cnv@runtrue% |
| 4272 |
\renewcommand*\svgx@cnv@cmd{\svgx@gs@cmd}% |
| 4273 |
\or% gs64 |
| 4274 |
\@svgx@cnv@runtrue% |
| 4275 |
\renewcommand*\svgx@cnv@cmd{\svgx@gs@cmd}% |
| 4276 |
\svg@ifwindowsdetected{% |
| 4277 |
\renewcommand*\svgx@gs@exe{gswin64c}% |
| 4278 |
}{}% |
| 4279 |
\or% gs32 |
| 4280 |
\@svgx@cnv@runtrue% |
| 4281 |
\renewcommand*\svgx@cnv@cmd{\svgx@gs@cmd}% |
| 4282 |
\svg@ifwindowsdetected{% |
| 4283 |
\renewcommand*\svgx@gs@exe{gswin32c}% |
| 4284 |
}{}% |
| 4285 |
\fi% |
| 4286 |
% \end{macrocode} |
| 4287 |
% In version~v1.0 the option \opt{convert} was used to set both the executable |
| 4288 |
% and options for the conversion application, meant for the usage of |
| 4289 |
% \app{ImageMagick}. This is taken into account here. |
| 4290 |
% \begin{macrocode} |
| 4291 |
\else% legacy option |
| 4292 |
% \end{macrocode} |
| 4293 |
% Same doing like with legacy part of option \opt{inkscape}. |
| 4294 |
% \begin{macrocode} |
| 4295 |
\def\svg@tempa##1-##2\@nil{% |
| 4296 |
\IfArgIsEmpty{##2}{\def\svg@tempb{}}{% |
| 4297 |
\def\svg@tempa##1####1\@nil{\def\svg@tempb{####1}}% |
| 4298 |
\svg@tempa#1\@nil% |
| 4299 |
}% |
| 4300 |
\def\svg@tempa{##1}% |
| 4301 |
}% |
| 4302 |
\svg@tempa#1-\@nil% |
| 4303 |
\PackageWarning{svg-extract}{% |
| 4304 |
Setting the executable% |
| 4305 |
\ifx\svg@tempb\@empty\else% |
| 4306 |
\space and associated options% |
| 4307 |
\fi% |
| 4308 |
\MessageBreak% |
| 4309 |
for ImageMagick should be done with options\MessageBreak% |
| 4310 |
`magickexe=\svg@tempa'% |
| 4311 |
\ifx\svg@tempb\@empty\else% |
| 4312 |
\MessageBreak and `magicksetting' and/or `magickoperator'% |
| 4313 |
\fi.\MessageBreak% |
| 4314 |
Nevertheless, this was done by now% |
| 4315 |
\ifx\svg@tempb\@empty\else% |
| 4316 |
, whereby \MessageBreak `magicksetting=\svg@tempb' was used% |
| 4317 |
\fi% |
| 4318 |
}% |
| 4319 |
\FamilyOptions{SVG}{convert=magick}% |
| 4320 |
\edef\svg@tempa{% |
| 4321 |
\noexpand\FamilyOptions{SVG}{magickexe=\svg@tempa}% |
| 4322 |
\ifx\svg@tempb\@empty\else% |
| 4323 |
\noexpand\FamilyOptions{SVG}{magicksetting=\svg@tempb}% |
| 4324 |
\fi% |
| 4325 |
}% |
| 4326 |
\svg@tempa% |
| 4327 |
\fi% |
| 4328 |
} |
| 4329 |
%</extract> |
| 4330 |
% \end{macrocode} |
| 4331 |
% \end{macro}^^A \svgx@cnv@cmd |
| 4332 |
% \end{macro}^^A \if@svgx@cnv@run |
| 4333 |
% \end{option}^^A convert |
| 4334 |
% \begin{option}{convertformat} |
| 4335 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4336 |
% \begin{macro}{\svgx@cnv@format} |
| 4337 |
% \begin{option}{png} |
| 4338 |
% \changes{v2.00}{2017/03/02}{deprecated}^^A |
| 4339 |
% Option \opt{convertformat} controls the output format for converted files. It |
| 4340 |
% is set to \val{png} by default. |
| 4341 |
% \begin{macrocode} |
| 4342 |
%<*main> |
| 4343 |
\svg@dummy@key{convertformat} |
| 4344 |
\svg@dummy@key[true]{png} |
| 4345 |
%</main> |
| 4346 |
%<*extract> |
| 4347 |
\newcommand*\svgx@cnv@format{png} |
| 4348 |
\DefineFamilyKey{SVG}{convertformat}{% |
| 4349 |
\lowercase{\edef\svgx@cnv@format{#1}}% |
| 4350 |
\ifx\svgx@cnv@format\@empty\else% |
| 4351 |
\@svgx@cnv@runtrue% |
| 4352 |
\fi% |
| 4353 |
\FamilyKeyStateProcessed% |
| 4354 |
} |
| 4355 |
\DefineFamilyKey{SVG}{png}[true]{% |
| 4356 |
\FamilySetBool{SVG}{png}{@svg@tempswa}{#1}% |
| 4357 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 4358 |
\if@svg@tempswa% |
| 4359 |
\svgx@ifinlist{png}{\svgx@cnv@format}{}{% |
| 4360 |
\edef\svgx@cnv@format{\svgx@cnv@format,png}% |
| 4361 |
}% |
| 4362 |
\svg@deprecated@key{png}{convertformat={\svgx@cnv@format}}% |
| 4363 |
\else% |
| 4364 |
\FamilyKeyStateUnknownValue% |
| 4365 |
\fi% |
| 4366 |
\fi% |
| 4367 |
} |
| 4368 |
%</extract> |
| 4369 |
% \end{macrocode} |
| 4370 |
% \end{option}^^A png |
| 4371 |
% \end{macro}^^A \svgx@cnv@format |
| 4372 |
% \end{option}^^A convertformat |
| 4373 |
% \begin{option}{convertdpi} |
| 4374 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4375 |
% \begin{option}{convertdensity} |
| 4376 |
% \begin{macro}{\svgx@cnv@dpi} |
| 4377 |
% \begin{macro}{\svgx@cnv@get@dpi} |
| 4378 |
% The option \opt{convertdpi} is meant to define the used density during the |
| 4379 |
% conversion process. It can be set either for all designated output formats or |
| 4380 |
% targeted for a specific format. It's also possible to use something like |
| 4381 |
% \val{500x300}. Given values are resolved by \cs{svgx@cnv@get@dpi}. It's used |
| 4382 |
% like \opt{convertdpi}|=|\val{300} or \opt{convertdpi}|=|\val{\{png=600\}} If |
| 4383 |
% the option is used for a specific or for all output formats is recognized by |
| 4384 |
% \cs{svgx@ifkeyandval}. |
| 4385 |
% \begin{macrocode} |
| 4386 |
%<*main> |
| 4387 |
\svg@dummy@key{convertdpi} |
| 4388 |
\svg@dummy@key{convertdensity} |
| 4389 |
%</main> |
| 4390 |
%<*extract> |
| 4391 |
\newcommand*\svgx@cnv@dpi{} |
| 4392 |
\let\svgx@cnv@dpi\relax |
| 4393 |
\DefineFamilyKey{SVG}{convertdpi}{% |
| 4394 |
\FamilyKeyStateUnknownValue% |
| 4395 |
\svgx@ifkeyandval{#1}{% |
| 4396 |
\svgx@cnv@get@dpi{##2}% |
| 4397 |
\ifx\svg@tempa\relax\else% |
| 4398 |
\expandafter\edef\csname svgx@cnv@dpi@##1\endcsname{\svg@tempa}% |
| 4399 |
\FamilyKeyStateProcessed% |
| 4400 |
\fi% |
| 4401 |
}{% |
| 4402 |
\svgx@cnv@get@dpi{##1}% |
| 4403 |
\ifx\svg@tempa\relax\else% |
| 4404 |
\edef\svgx@cnv@dpi{\svg@tempa}% |
| 4405 |
\FamilyKeyStateProcessed% |
| 4406 |
\fi% |
| 4407 |
}% |
| 4408 |
} |
| 4409 |
\DefineFamilyKey{SVG}{convertdensity}{\FamilyOptions{SVG}{convertdpi=#1}} |
| 4410 |
% \end{macrocode} |
| 4411 |
% This macro is used to resolve a given value to set the density for the |
| 4412 |
% conversion. The delimited macros \cs{svg@tempa} and \cs{svg@tempb} are |
| 4413 |
% defined to first crop any given suffix \val{dpi} and second to split two |
| 4414 |
% numbers at |x|, if present. Pay attention how both macros are invoked. In the |
| 4415 |
% end, a passed value in any of the forms \val{300}, \val{300dpi}, \val{300x400} |
| 4416 |
% or \val{300x400dpi} and even \val{300dpix400dpi} is possible. The result is |
| 4417 |
% stored in \cs{svg@tempa}. |
| 4418 |
% \begin{macrocode} |
| 4419 |
\newcommand*\svgx@cnv@get@dpi[1]{% |
| 4420 |
\begingroup% |
| 4421 |
\def\svg@tempa##1dpi##2x##3dpi##4\@nil{% |
| 4422 |
\edef\svg@tempa{##1}% |
| 4423 |
% \end{macrocode} |
| 4424 |
% Switch \cs{if@svg@tempswa} as \cs{iftrue} means, a valid value was found. |
| 4425 |
% \begin{macrocode} |
| 4426 |
\@svg@tempswafalse% |
| 4427 |
% \end{macrocode} |
| 4428 |
% If only the first argument is a number and third is empty, a single number |
| 4429 |
% was given and there's nothing more to do. If the argument is something like |
| 4430 |
% \val{300dpix400dpi}, the third argument is the second number. |
| 4431 |
% \begin{macrocode} |
| 4432 |
\Ifnumber{##1}{% |
| 4433 |
\IfArgIsEmpty{##3}{\@svg@tempswatrue}{% |
| 4434 |
\Ifnumber{##3}{\edef\svg@tempa{##1x##3}}{}% |
| 4435 |
}% |
| 4436 |
}{}% |
| 4437 |
\if@svg@tempswa\else% |
| 4438 |
\expandafter\svg@tempb\svg@tempa xx\@nil% |
| 4439 |
\fi% |
| 4440 |
}% |
| 4441 |
% \end{macrocode} |
| 4442 |
% Macro \cs{svg@tempb} splits at |x| and checks, if something valid like |
| 4443 |
% \val{300x400} was given. If true, the value is stored in \cs{svg@tempa}. |
| 4444 |
% \begin{macrocode} |
| 4445 |
\def\svg@tempb##1x##2x##3\@nil{% |
| 4446 |
\Ifstr{##3}{x}{% |
| 4447 |
\@svg@tempswatrue% |
| 4448 |
\IfArgIsEmpty{##1}{\@svg@tempswafalse}{% |
| 4449 |
\Ifnumber{##1}{}{\@svg@tempswafalse}% |
| 4450 |
}% |
| 4451 |
\IfArgIsEmpty{##2}{\@svg@tempswafalse}{% |
| 4452 |
\Ifnumber{##2}{}{\@svg@tempswafalse}% |
| 4453 |
}% |
| 4454 |
\if@svg@tempswa% |
| 4455 |
\edef\svg@tempa{##1x##2}% |
| 4456 |
\fi% |
| 4457 |
}{}% |
| 4458 |
}% |
| 4459 |
\IfArgIsEmpty{#1}{% |
| 4460 |
\let\svg@tempa\@empty% |
| 4461 |
}{% |
| 4462 |
\lowercase{\svg@tempa#1dpi#1xdpi\@nil}% |
| 4463 |
\if@svg@tempswa\else% |
| 4464 |
\let\svg@tempa\relax% |
| 4465 |
\fi% |
| 4466 |
}% |
| 4467 |
\edef\svg@tempb{% |
| 4468 |
\endgroup% |
| 4469 |
\ifx\svg@tempa\relax% |
| 4470 |
\let\noexpand\svg@tempa\noexpand\relax% |
| 4471 |
\else% |
| 4472 |
\def\noexpand\svg@tempa{\svg@tempa}% |
| 4473 |
\fi% |
| 4474 |
}% |
| 4475 |
\svg@tempb% |
| 4476 |
} |
| 4477 |
%</extract> |
| 4478 |
% \end{macrocode} |
| 4479 |
% \end{macro}^^A \svgx@cnv@get@dpi |
| 4480 |
% \end{macro}^^A \svgx@cnv@dpi |
| 4481 |
% \end{option}^^A convertdensity |
| 4482 |
% \end{option}^^A convertdpi |
| 4483 |
% |
| 4484 |
% \iffalse |
| 4485 |
%<*extract> |
| 4486 |
% \fi |
| 4487 |
% |
| 4488 |
% \begin{macro}{\svgx@setformatkey} |
| 4489 |
% \begin{macro}{\svgx@useformatkey} |
| 4490 |
% With \cs{svgx@setformatkey} the---maybe output format depend---keys for the |
| 4491 |
% conversion tools are set. First argument contains the value given to a key, |
| 4492 |
% second the command sequence name of the macro, to whom the value shall be |
| 4493 |
% allocated. |
| 4494 |
% \begin{macrocode} |
| 4495 |
\newcommand*\svgx@setformatkey[2]{% |
| 4496 |
% \end{macrocode} |
| 4497 |
% A key of the form \val{\meta{key}=\{\meta{format}=\meta{value}\}} is given. |
| 4498 |
% The desired output format can be accessed with |##1|, the value with |##2| |
| 4499 |
% within the arguments of \cs{svgx@ifkeyandval}. |
| 4500 |
% \begin{macrocode} |
| 4501 |
\svgx@ifkeyandval{#1}{% |
| 4502 |
\svg@ifvalueisrelax{##2}{% |
| 4503 |
\expandafter\let\csname #2@##1\endcsname\relax% |
| 4504 |
}{% |
| 4505 |
\@namedef{#2@##1}{##2}% |
| 4506 |
}% |
| 4507 |
% \end{macrocode} |
| 4508 |
% A key of the form \val{\meta{key}=\{\meta{format}=\meta{value}\}} is given. |
| 4509 |
% The value can be used with |##1|. |
| 4510 |
% \begin{macrocode} |
| 4511 |
}{% |
| 4512 |
\svg@ifvalueisrelax{##1}{% |
| 4513 |
\expandafter\let\csname #2\endcsname\relax% |
| 4514 |
}{% |
| 4515 |
\@namedef{#2}{##1}% |
| 4516 |
}% |
| 4517 |
}% |
| 4518 |
} |
| 4519 |
% \end{macrocode} |
| 4520 |
% The command \cs{svgx@useformatkey} checks, if a format specific key was |
| 4521 |
% defined with \cs{svgx@setformatkey}, whereas the format is given in the |
| 4522 |
% second argument. If this is not the case, the setting for all output formats |
| 4523 |
% is used. After that, a specific key appended with a |+| can be used to do |
| 4524 |
% some additional stuff. |
| 4525 |
% \begin{macrocode} |
| 4526 |
\newcommand*\svgx@useformatkey[3]{% |
| 4527 |
\scr@ifundefinedorrelax{#1@#2}{% |
| 4528 |
\scr@ifundefinedorrelax{#1}{}{% |
| 4529 |
\expandafter\ifx\csname #1\endcsname\@empty\else% |
| 4530 |
#3\@nameuse{#1}\space% |
| 4531 |
\fi% |
| 4532 |
}% |
| 4533 |
\scr@ifundefinedorrelax{#1@#2+}{}{% |
| 4534 |
\expandafter\ifx\csname #1@#2+\endcsname\@empty\else% |
| 4535 |
#3\@nameuse{#1@#2+}\space% |
| 4536 |
\fi% |
| 4537 |
}% |
| 4538 |
}{% |
| 4539 |
% \end{macrocode} |
| 4540 |
% If a format specific key was definded, it is used. |
| 4541 |
% \begin{macrocode} |
| 4542 |
\expandafter\ifx\csname #1@#2\endcsname\@empty\else% |
| 4543 |
#3\@nameuse{#1@#2}\space% |
| 4544 |
\fi% |
| 4545 |
}% |
| 4546 |
} |
| 4547 |
% \end{macrocode} |
| 4548 |
% \end{macro}^^A \svgx@useformatkey |
| 4549 |
% \end{macro}^^A \svgx@setformatkey |
| 4550 |
% |
| 4551 |
% \iffalse |
| 4552 |
%</extract> |
| 4553 |
% \fi |
| 4554 |
% |
| 4555 |
% \begin{option}{magickexe} |
| 4556 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4557 |
% \begin{macro}{\svgx@magick@exe} |
| 4558 |
% \begin{option}{magicksetting} |
| 4559 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4560 |
% \begin{macro}{\svgx@magick@set} |
| 4561 |
% \begin{option}{magickoperator} |
| 4562 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4563 |
% \begin{macro}{\svgx@magick@opr} |
| 4564 |
% \begin{macro}{\svgx@magick@cmd} |
| 4565 |
% Setting the command including maybe the path to \app{ImageMagick}. The keys |
| 4566 |
% \opt{magicksetting} and \opt{magickoperator} should be used to add optional |
| 4567 |
% arguments before (\emph{Settings}) or after (\emph{Operators}) the input |
| 4568 |
% file. They can either be set for all or a specific output format as like |
| 4569 |
% option \opt{convertdpi}. For this \cs{svgx@setformatkey} is used. |
| 4570 |
% \begin{macrocode} |
| 4571 |
%<*main> |
| 4572 |
\svg@dummy@key{magickexe} |
| 4573 |
\svg@dummy@key{magicksetting} |
| 4574 |
\svg@dummy@key{magickoperator} |
| 4575 |
%</main> |
| 4576 |
%<*extract> |
| 4577 |
\svg@ifwindowsdetected{% |
| 4578 |
\newcommand*\svgx@magick@exe{magick}% |
| 4579 |
}{% |
| 4580 |
\newcommand*\svgx@magick@exe{convert}% |
| 4581 |
} |
| 4582 |
\DefineFamilyKey{SVG}{magickexe}{% |
| 4583 |
\renewcommand*\svgx@magick@exe{#1}% |
| 4584 |
\FamilyKeyStateProcessed% |
| 4585 |
} |
| 4586 |
\newcommand*\svgx@magick@set{} |
| 4587 |
\DefineFamilyKey{SVG}{magicksetting}{% |
| 4588 |
\svgx@setformatkey{#1}{svgx@magick@set}% |
| 4589 |
\FamilyKeyStateProcessed% |
| 4590 |
} |
| 4591 |
\newcommand*\svgx@magick@opr{} |
| 4592 |
\DefineFamilyKey{SVG}{magickoperator}{% |
| 4593 |
\svgx@setformatkey{#1}{svgx@magick@opr}% |
| 4594 |
\FamilyKeyStateProcessed% |
| 4595 |
} |
| 4596 |
\newcommand*\svgx@magick@cmd[3]{% |
| 4597 |
\svgx@magick@exe\space% |
| 4598 |
\svgx@useformatkey{svgx@cnv@dpi}{#3}{-density }% |
| 4599 |
\svgx@useformatkey{svgx@magick@set}{#3}{}% |
| 4600 |
"#1.#2"\space% |
| 4601 |
\svgx@useformatkey{svgx@magick@opr}{#3}{}% |
| 4602 |
"#1.#3"% |
| 4603 |
} |
| 4604 |
%</extract> |
| 4605 |
% \end{macrocode} |
| 4606 |
% \end{macro}^^A \svgx@magick@cmd |
| 4607 |
% \end{macro}^^A \svgx@magick@opr |
| 4608 |
% \end{option}^^A magickoperator |
| 4609 |
% \end{macro}^^A \svgx@magick@set |
| 4610 |
% \end{option}^^A magicksetting |
| 4611 |
% \end{macro}^^A \svgx@magick@exe |
| 4612 |
% \end{option}^^A magickexe |
| 4613 |
% \begin{option}{gsexe} |
| 4614 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4615 |
% \begin{macro}{\svgx@gs@exe} |
| 4616 |
% \begin{option}{gsopt} |
| 4617 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4618 |
% \begin{macro}{\svgx@gs@opt} |
| 4619 |
% \begin{option}{gsdevice} |
| 4620 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4621 |
% \begin{macro}{\svgx@gs@device} |
| 4622 |
% \begin{macro}{\svgx@gs@cmd} |
| 4623 |
% Options to set the command including maybe the path to \app{Ghostscript}. As |
| 4624 |
% \app{Ghostscript} needs a specific device defined for different output |
| 4625 |
% formats, the option \opt{gsdevice} can be used. It can either be set for all |
| 4626 |
% or a specific output format just like \opt{gsopt} in the same manner like |
| 4627 |
% option \opt{convertdpi}. |
| 4628 |
% \begin{macrocode} |
| 4629 |
%<*main> |
| 4630 |
\svg@dummy@key{gsexe} |
| 4631 |
\svg@dummy@key{gsopt} |
| 4632 |
\svg@dummy@key{gsdevice} |
| 4633 |
%</main> |
| 4634 |
%<*extract> |
| 4635 |
\svg@ifwindowsdetected{% |
| 4636 |
\newcommand*\svgx@gs@exe{gswin64c}% |
| 4637 |
}{% |
| 4638 |
\newcommand*\svgx@gs@exe{gs}% |
| 4639 |
} |
| 4640 |
\DefineFamilyKey{SVG}{gsexe}{% |
| 4641 |
\renewcommand*\svgx@gs@exe{#1}% |
| 4642 |
\FamilyKeyStateProcessed% |
| 4643 |
} |
| 4644 |
\newcommand*\svgx@gs@opt{} |
| 4645 |
\DefineFamilyKey{SVG}{gsopt}{% |
| 4646 |
\svgx@setformatkey{#1}{svgx@gs@opt}% |
| 4647 |
\FamilyKeyStateProcessed% |
| 4648 |
} |
| 4649 |
\newcommand*\svgx@gs@device{} |
| 4650 |
\DefineFamilyKey{SVG}{gsdevice}{% |
| 4651 |
\svgx@setformatkey{#1}{svgx@gs@device}% |
| 4652 |
\FamilyKeyStateProcessed% |
| 4653 |
} |
| 4654 |
\newcommand*\svgx@gs@cmd[3]{% |
| 4655 |
\svgx@gs@exe\space-dSAFER -dBATCH -dNOPAUSE\space% |
| 4656 |
\svgx@useformatkey{svgx@gs@device}{#3}{-sDEVICE=}% |
| 4657 |
\svgx@useformatkey{svgx@cnv@dpi}{#3}{-r}% |
| 4658 |
\svgx@useformatkey{svgx@gs@opt}{#3}{}% |
| 4659 |
-sOutputFile="#1.#3"\space"#1.#2"% |
| 4660 |
} |
| 4661 |
%</extract> |
| 4662 |
% \end{macrocode} |
| 4663 |
% \end{macro}^^A \svgx@gs@cmd |
| 4664 |
% \end{macro}^^A \svgx@gs@device |
| 4665 |
% \end{option}^^A gsdevice |
| 4666 |
% \end{macro}^^A \svgx@gs@opt |
| 4667 |
% \end{option}^^A gsopt |
| 4668 |
% \end{macro}^^A \svgx@gs@exe |
| 4669 |
% \end{option}^^A gsexe |
| 4670 |
% |
| 4671 |
% |
| 4672 |
% |
| 4673 |
% \subsubsection{Setting output folder} |
| 4674 |
% |
| 4675 |
% \begin{option}{extractpath} |
| 4676 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4677 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@sanitize@dq}}^^A |
| 4678 |
% \begin{option}{path} |
| 4679 |
% \changes{v2.00}{2017/02/24}{deprecated}^^A |
| 4680 |
% \begin{macro}{\svgx@out@path} |
| 4681 |
% The option \opt{extractpath} controls, in which folder the results both of |
| 4682 |
% the extraction as well as the conversion of \app{ImageMagick} or |
| 4683 |
% \app{Ghostscript} will be located. |
| 4684 |
% \begin{macrocode} |
| 4685 |
%<*main> |
| 4686 |
\svg@dummy@key{extractpath} |
| 4687 |
\svg@dummy@key{path} |
| 4688 |
%</main> |
| 4689 |
%<*extract> |
| 4690 |
\newcommand*\svgx@out@path{} |
| 4691 |
\DefineFamilyKey{SVG}{extractpath}{% |
| 4692 |
\svg@sanitize@dq\svg@tempb{#1}% |
| 4693 |
\FamilySetNumerical{SVG}{extractpath}{svg@tempa}{% |
| 4694 |
{svgpath}{0},{svgdir}{0},% |
| 4695 |
{svgsubpath}{1},{svgsubdir}{1},% |
| 4696 |
{basepath}{2},{basedir}{2},{jobpath}{2},{jobdir}{2},% |
| 4697 |
{basesubpath}{3},{basesubdir}{3},{jobsubpath}{3},{jobsubdir}{3}% |
| 4698 |
}{\svg@tempb}% |
| 4699 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 4700 |
\ifcase\svg@tempa\relax% svgpath |
| 4701 |
\renewcommand*\svgx@out@path{\svg@file@path}% |
| 4702 |
\or% svgsubpath |
| 4703 |
\renewcommand*\svgx@out@path{\svg@file@path svg-extract/}% |
| 4704 |
\or% basepath |
| 4705 |
\renewcommand*\svgx@out@path{./}% |
| 4706 |
\or% basesubpath |
| 4707 |
\renewcommand*\svgx@out@path{./svg-extract/}% |
| 4708 |
\fi% |
| 4709 |
\else% |
| 4710 |
\edef\svgx@out@path{\svg@tempb}% |
| 4711 |
\svg@normalize@path{\svgx@out@path}% |
| 4712 |
\FamilyKeyStateProcessed% |
| 4713 |
\fi% |
| 4714 |
} |
| 4715 |
\DefineFamilyKey{SVG}{path}{% |
| 4716 |
\svg@deprecated@key[svg-extract]{path=#1}{extractpath=#1}% |
| 4717 |
} |
| 4718 |
%</extract> |
| 4719 |
% \end{macrocode} |
| 4720 |
% \end{macro}^^A \svgx@out@path |
| 4721 |
% \end{option}^^A path |
| 4722 |
% \end{option}^^A extractpath |
| 4723 |
% \begin{option}{extractname} |
| 4724 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 4725 |
% \changes{v2.02}{2018/09/07}{usage of \cs{svg@quotes@remove}}^^A |
| 4726 |
% \begin{option}{name} |
| 4727 |
% \changes{v2.00}{2017/02/24}{deprecated}^^A |
| 4728 |
% \changes{v2.00}{2017/02/24}{support of \pkg{subfig} removed}^^A |
| 4729 |
% \begin{macro}{\svgx@out@name} |
| 4730 |
% \begin{macro}{\if@svgx@out@sec} |
| 4731 |
% \begin{counter}{svgx@out@count} |
| 4732 |
% \begin{macro}{\svgx@out@sec} |
| 4733 |
% With option \opt{extractname} the name of the extracted and maybe converted |
| 4734 |
% file itself can be changed. |
| 4735 |
% \begin{macrocode} |
| 4736 |
%<*main> |
| 4737 |
\svg@dummy@key{extractname} |
| 4738 |
\svg@dummy@key{name} |
| 4739 |
%</main> |
| 4740 |
%<*extract> |
| 4741 |
\newcommand*\svgx@out@name{} |
| 4742 |
\newif\if@svgx@out@sec |
| 4743 |
\newcounter{svgx@out@count} |
| 4744 |
\newcommand*\svgx@out@sec{unknown} |
| 4745 |
\DefineFamilyKey{SVG}{extractname}{% |
| 4746 |
\svg@quotes@remove[{#1}]{\svg@tempb}% |
| 4747 |
\FamilySetNumerical{SVG}{extractname}{svg@tempa}{% |
| 4748 |
{filename}{0},{name}{0},% |
| 4749 |
{filenamenumbered}{1},{namenumbered}{1},% |
| 4750 |
{numberedfilename}{1},{numberedname}{1},% |
| 4751 |
{numbered}{2},{section}{2},{numberedsection}{2},{sectionnumbered}{2}% |
| 4752 |
}{\svg@tempb}% |
| 4753 |
\@svgx@out@secfalse% |
| 4754 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 4755 |
\ifcase\svg@tempa\relax% filename |
| 4756 |
\renewcommand*\svgx@out@name{\svg@out@name-extract}% |
| 4757 |
\or% filenamenumbered |
| 4758 |
\renewcommand*\svgx@out@name{\the\value{svgx@out@count}-\svg@out@name}% |
| 4759 |
\or% numbered |
| 4760 |
\renewcommand*\svgx@out@name{\the\value{svgx@out@count}-\svgx@out@sec}% |
| 4761 |
\@svgx@out@sectrue% |
| 4762 |
\fi% |
| 4763 |
\else% |
| 4764 |
\if@svg@quotes@found% |
| 4765 |
\edef\svgx@out@name{"\svg@tempb"}% |
| 4766 |
\else% |
| 4767 |
\edef\svgx@out@name{\svg@tempb}% |
| 4768 |
\fi% |
| 4769 |
\FamilyKeyStateProcessed% |
| 4770 |
\fi% |
| 4771 |
} |
| 4772 |
\DefineFamilyKey{SVG}{name}{% |
| 4773 |
\svg@deprecated@key[svg-extract]{name=#1}{extractname=#1}% |
| 4774 |
} |
| 4775 |
%</extract> |
| 4776 |
% \end{macrocode} |
| 4777 |
% \end{macro}^^A \svgx@out@sec |
| 4778 |
% \end{counter}^^A svgx@out@count |
| 4779 |
% \end{macro}^^A \if@svgx@out@sec |
| 4780 |
% \end{macro}^^A \svgx@out@name |
| 4781 |
% \end{option}^^A name |
| 4782 |
% \end{option}^^A extractname |
| 4783 |
% |
| 4784 |
% |
| 4785 |
% |
| 4786 |
% \subsubsection{Options for the extraction of graphics} |
| 4787 |
% |
| 4788 |
% \begin{option}{extractwidth} |
| 4789 |
% \changes{v2.00}{2017/02/20}{new}^^A |
| 4790 |
% \begin{macro}{\svgx@param@width} |
| 4791 |
% \begin{option}{extractheight} |
| 4792 |
% \changes{v2.00}{2017/02/20}{new}^^A |
| 4793 |
% \begin{macro}{\svgx@param@width} |
| 4794 |
% \begin{option}{extractdistort} |
| 4795 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 4796 |
% \begin{option}{extractkeepaspectratio} |
| 4797 |
% \begin{macro}{\svgx@param@distort} |
| 4798 |
% \begin{option}{extractscale} |
| 4799 |
% \changes{v2.00}{2017/02/20}{new}^^A |
| 4800 |
% \begin{macro}{\svgx@param@scale} |
| 4801 |
% For graphic extraction, the given settings regarding the size for inclusion |
| 4802 |
% can be overwritten with these options. Using \val{\cs{relax}} as value leads |
| 4803 |
% to resetting an option as unset, regardless of what was previously given. The |
| 4804 |
% value \val{inherit} means, that the actual option for including is used for |
| 4805 |
% extraction as well. This is the default setting. |
| 4806 |
% \begin{macrocode} |
| 4807 |
%<*main> |
| 4808 |
\svg@dummy@key{extractwidth} |
| 4809 |
\svg@dummy@key{extractheight} |
| 4810 |
\svg@dummy@key{extractdistort} |
| 4811 |
\svg@dummy@key{extractkeepaspectratio} |
| 4812 |
\svg@dummy@key{extractscale} |
| 4813 |
%</main> |
| 4814 |
%<*extract> |
| 4815 |
\newcommand*\svgx@param@width{\svg@param@width} |
| 4816 |
\DefineFamilyKey{SVG}{extractwidth}{% |
| 4817 |
\FamilyKeyStateUnknownValue% |
| 4818 |
\svg@ifvalueisrelax{#1}{% |
| 4819 |
\renewcommand*\svgx@param@width{\z@}% |
| 4820 |
\FamilyKeyStateProcessed% |
| 4821 |
}{% |
| 4822 |
\Ifstr{#1}{inherit}{% |
| 4823 |
\renewcommand*\svgx@param@width{\svg@param@width}% |
| 4824 |
\FamilyKeyStateProcessed% |
| 4825 |
}{% |
| 4826 |
\FamilySetLengthMacro{SVG}{extractwidth}{\svgx@param@width}{#1}% |
| 4827 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 4828 |
\ifdim\svgx@param@width<\z@\relax% |
| 4829 |
\FamilyKeyStateUnknownValue% |
| 4830 |
\fi% |
| 4831 |
\fi% |
| 4832 |
}% |
| 4833 |
}% |
| 4834 |
} |
| 4835 |
\newcommand*\svgx@param@height{\svg@param@height} |
| 4836 |
\DefineFamilyKey{SVG}{extractheight}{% |
| 4837 |
\FamilyKeyStateUnknownValue% |
| 4838 |
\svg@ifvalueisrelax{#1}{% |
| 4839 |
\renewcommand*\svgx@param@height{\z@}% |
| 4840 |
\FamilyKeyStateProcessed% |
| 4841 |
}{% |
| 4842 |
\Ifstr{#1}{inherit}{% |
| 4843 |
\renewcommand*\svgx@param@height{\svg@param@height}% |
| 4844 |
\FamilyKeyStateProcessed% |
| 4845 |
}{% |
| 4846 |
\FamilySetLengthMacro{SVG}{extractheight}{\svgx@param@height}{#1}% |
| 4847 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 4848 |
\ifdim\svgx@param@height<\z@\relax% |
| 4849 |
\FamilyKeyStateUnknownValue% |
| 4850 |
\fi% |
| 4851 |
\fi% |
| 4852 |
}% |
| 4853 |
}% |
| 4854 |
} |
| 4855 |
\newif\if@svgx@param@distort |
| 4856 |
\DefineFamilyKey{SVG}{extractdistort}[true]{% |
| 4857 |
\FamilyKeyStateUnknownValue% |
| 4858 |
\svg@ifvalueisrelax{#1}{% |
| 4859 |
\@svgx@param@distortfalse% |
| 4860 |
\FamilyKeyStateProcessed% |
| 4861 |
}{% |
| 4862 |
\Ifstr{#1}{inherit}{% |
| 4863 |
\renewcommand*\if@svgx@param@distort{\if@svg@param@distort}% |
| 4864 |
\FamilyKeyStateProcessed% |
| 4865 |
}{% |
| 4866 |
\FamilySetBool{SVG}{extractdistort}{@svgx@param@distort}{#1}% |
| 4867 |
}% |
| 4868 |
}% |
| 4869 |
} |
| 4870 |
\DefineFamilyKey{SVG}{extractkeepaspectratio}[true]{% |
| 4871 |
\FamilySetBool{SVG}{extractkeepaspectratio}{@svg@tempswa}{#1}% |
| 4872 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 4873 |
\if@svg@tempswa% |
| 4874 |
\FamilyOptions{SVG}{extractdistort=false}% |
| 4875 |
\else% |
| 4876 |
\FamilyOptions{SVG}{extractdistort=true}% |
| 4877 |
\fi% |
| 4878 |
\else% |
| 4879 |
\FamilyOptions{SVG}{extractdistort=#1}% |
| 4880 |
\fi% |
| 4881 |
} |
| 4882 |
\newcommand*\svgx@param@scale{\svg@param@scale} |
| 4883 |
\DefineFamilyKey{SVG}{extractscale}{% |
| 4884 |
\FamilyKeyStateUnknownValue% |
| 4885 |
\svg@ifvalueisrelax{#1}{% |
| 4886 |
\renewcommand*\svgx@param@scale{1}% |
| 4887 |
\FamilyKeyStateProcessed% |
| 4888 |
}{% |
| 4889 |
\Ifstr{#1}{inherit}{% |
| 4890 |
\renewcommand*\svgx@param@scale{\svg@param@scale}% |
| 4891 |
\FamilyKeyStateProcessed% |
| 4892 |
}{% |
| 4893 |
\Ifisdimension{#1\p@}{% |
| 4894 |
\ifdim\dimexpr#1\p@\relax>\z@\relax% |
| 4895 |
\renewcommand*\svgx@param@scale{#1}% |
| 4896 |
\FamilyKeyStateProcessed% |
| 4897 |
\fi% |
| 4898 |
}{}% |
| 4899 |
}% |
| 4900 |
}% |
| 4901 |
} |
| 4902 |
%</extract> |
| 4903 |
% \end{macrocode} |
| 4904 |
% \end{macro}^^A \svgx@param@scale |
| 4905 |
% \end{option}^^A extractscale |
| 4906 |
% \end{macro}^^A \svgx@param@distort |
| 4907 |
% \end{option}^^A extractkeepaspectratio |
| 4908 |
% \end{option}^^A extractdistort |
| 4909 |
% \end{macro}^^A \svgx@param@height |
| 4910 |
% \end{option}^^A extractheight |
| 4911 |
% \end{macro}^^A \svgx@param@width |
| 4912 |
% \end{option}^^A extractwidth |
| 4913 |
% \begin{option}{extractpretex} |
| 4914 |
% \changes{v2.00}{2017/02/20}{new}^^A |
| 4915 |
% \begin{macro}{\svgx@param@pretex} |
| 4916 |
% \begin{option}{extractapptex} |
| 4917 |
% \changes{v2.00}{2017/02/20}{new}^^A |
| 4918 |
% \begin{macro}{\svgx@param@apptex} |
| 4919 |
% \begin{option}{extractpostex} |
| 4920 |
% The similar hooks for executing code right before or after the graphic |
| 4921 |
% extraction. |
| 4922 |
% \begin{macrocode} |
| 4923 |
%<*main> |
| 4924 |
\svg@dummy@key{extractpretex} |
| 4925 |
\svg@dummy@key{extractapptex} |
| 4926 |
\svg@dummy@key{extractpostex} |
| 4927 |
%</main> |
| 4928 |
%<*extract> |
| 4929 |
\newcommand*\svgx@param@pretex{\svg@param@pretex} |
| 4930 |
\DefineFamilyKey{SVG}{extractpretex}{% |
| 4931 |
\svg@ifvalueisrelax{#1}{% |
| 4932 |
\let\svgx@param@pretex\relax% |
| 4933 |
}{% |
| 4934 |
\Ifstr{#1}{inherit}{% |
| 4935 |
\renewcommand*\svgx@param@pretex{\svg@param@pretex}% |
| 4936 |
}{% |
| 4937 |
\renewcommand*\svgx@param@pretex{#1}% |
| 4938 |
}% |
| 4939 |
}% |
| 4940 |
\FamilyKeyStateProcessed% |
| 4941 |
} |
| 4942 |
\newcommand*\svgx@param@apptex{\svg@param@apptex} |
| 4943 |
\DefineFamilyKey{SVG}{extractapptex}{% |
| 4944 |
\svg@ifvalueisrelax{#1}{% |
| 4945 |
\let\svgx@param@apptex\relax% |
| 4946 |
}{% |
| 4947 |
\Ifstr{#1}{inherit}{% |
| 4948 |
\renewcommand*\svgx@param@apptex{\svg@param@apptex}% |
| 4949 |
}{% |
| 4950 |
\renewcommand*\svgx@param@apptex{#1}% |
| 4951 |
}% |
| 4952 |
}% |
| 4953 |
\FamilyKeyStateProcessed% |
| 4954 |
} |
| 4955 |
\DefineFamilyKey{SVG}{extractpostex}{% |
| 4956 |
\svg@deprecated@key[svg-extract]{extractpostex=#1}{extractapptex=#1}% |
| 4957 |
} |
| 4958 |
%</extract> |
| 4959 |
% \end{macrocode} |
| 4960 |
% \end{option}^^A extractpostex |
| 4961 |
% \end{macro}^^A \svgx@param@apptex |
| 4962 |
% \end{option}^^A extractapptex |
| 4963 |
% \end{macro}^^A \svgx@param@pretex |
| 4964 |
% \end{option}^^A extractpretex |
| 4965 |
% |
| 4966 |
% |
| 4967 |
% |
| 4968 |
% \subsubsection{Miscellaneous options} |
| 4969 |
% |
| 4970 |
% \begin{option}{clean} |
| 4971 |
% \changes{v2.00}{2017/02/24}{changes, file list possible}^^A |
| 4972 |
% \begin{option}{clear} |
| 4973 |
% \begin{macro}{\svgx@clean} |
| 4974 |
% With option \opt{clean} files generated during the extraction process can be |
| 4975 |
% deleted. Setting \val{true} will remove all files, \val{false} won't clear |
| 4976 |
% any file. Additionally, a specific file list of suffixes can be given. |
| 4977 |
% \begin{macrocode} |
| 4978 |
%<*main> |
| 4979 |
\svg@dummy@key[true]{clean} |
| 4980 |
\svg@dummy@key[true]{clear} |
| 4981 |
%</main> |
| 4982 |
%<*extract> |
| 4983 |
\newcommand*\svgx@clean{} |
| 4984 |
\DefineFamilyKey{SVG}{clean}[true]{% |
| 4985 |
\FamilySetBool{SVG}{clean}{@svg@tempswa}{#1}% |
| 4986 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 4987 |
\if@svg@tempswa% |
| 4988 |
\renewcommand*\svgx@clean{log,aux,dvi,out,ps,eps,pdf,\svgx@latex@ext}% |
| 4989 |
\else% |
| 4990 |
\renewcommand*\svgx@clean{}% |
| 4991 |
\fi% |
| 4992 |
\else% |
| 4993 |
\renewcommand*\svgx@clean{#1}% |
| 4994 |
\FamilyKeyStateProcessed% |
| 4995 |
\fi% |
| 4996 |
} |
| 4997 |
\DefineFamilyKey{SVG}{clear}[true]{\FamilyOptions{SVG}{clean=#1}} |
| 4998 |
%</extract> |
| 4999 |
% \end{macrocode} |
| 5000 |
% \end{macro}^^A \svgx@clean |
| 5001 |
% \end{option}^^A clear |
| 5002 |
% \end{option}^^A clean |
| 5003 |
% \begin{option}{exclude} |
| 5004 |
% If it is desired not to include but only extract graphics with package |
| 5005 |
% \pkg{svg-extract}, option \opt{exclude} can be used. |
| 5006 |
% \begin{macrocode} |
| 5007 |
%<*main> |
| 5008 |
\svg@dummy@key[true]{exclude} |
| 5009 |
%</main> |
| 5010 |
%<*extract> |
| 5011 |
\DefineFamilyKey{SVG}{exclude}[true]{% |
| 5012 |
\FamilySetBool{SVG}{exclude}{@svg@tempswa}{#1}% |
| 5013 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed% |
| 5014 |
\if@svg@tempswa% |
| 5015 |
\renewcommand*\svg@input[2][]{% |
| 5016 |
\if@svgx@run\else% |
| 5017 |
\PackageWarning{svg-extract}{% |
| 5018 |
The image `##2' was\MessageBreak% |
| 5019 |
neither extracted nor included% |
| 5020 |
}% |
| 5021 |
\fi% |
| 5022 |
}% |
| 5023 |
\else% |
| 5024 |
\renewcommand*\svg@input{\svg@@input}% |
| 5025 |
\fi% |
| 5026 |
\fi% |
| 5027 |
} |
| 5028 |
%</extract> |
| 5029 |
% \end{macrocode} |
| 5030 |
% \end{option}^^A exclude |
| 5031 |
% |
| 5032 |
% \iffalse |
| 5033 |
%</package&option> |
| 5034 |
%<*package&body> |
| 5035 |
% \fi |
| 5036 |
% |
| 5037 |
% |
| 5038 |
% |
| 5039 |
% \subsection{User commands} |
| 5040 |
% |
| 5041 |
% \begin{macro}{\includesvg} |
| 5042 |
% \begin{parameter}{extract} |
| 5043 |
% \begin{parameter}{extractpreamble} |
| 5044 |
% \begin{parameter}{extractformat} |
| 5045 |
% \begin{parameter}{extractwidth} |
| 5046 |
% \begin{parameter}{extractheight} |
| 5047 |
% \begin{parameter}{extractdistort} |
| 5048 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 5049 |
% \begin{parameter}{extractscale} |
| 5050 |
% \begin{parameter}{extractangle} |
| 5051 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 5052 |
% \begin{parameter}{extractpretex} |
| 5053 |
% \begin{parameter}{extractapptex} |
| 5054 |
% \begin{parameter}{extractruns} |
| 5055 |
% \begin{parameter}{latexexe} |
| 5056 |
% \begin{parameter}{latexopt} |
| 5057 |
% \begin{parameter}{latexext} |
| 5058 |
% \begin{parameter}{dvipsopt} |
| 5059 |
% \begin{parameter}{pstoepsopt} |
| 5060 |
% \begin{parameter}{pstopdfopt} |
| 5061 |
% \begin{parameter}{pdftoepsopt} |
| 5062 |
% \begin{parameter}{pdftopsopt} |
| 5063 |
% \begin{parameter}{convert} |
| 5064 |
% \begin{parameter}{convertformat} |
| 5065 |
% \begin{parameter}{convertdpi} |
| 5066 |
% \begin{parameter}{magicksetting} |
| 5067 |
% \begin{parameter}{magickoperator} |
| 5068 |
% \begin{parameter}{gsopt} |
| 5069 |
% \begin{parameter}{gsdevice} |
| 5070 |
% \begin{parameter}{clean} |
| 5071 |
% \begin{parameter}{exclude} |
| 5072 |
% \begin{macro}{\includeinkscape} |
| 5073 |
% \begin{parameter}{extract} |
| 5074 |
% \begin{parameter}{extractpreamble} |
| 5075 |
% \begin{parameter}{extractformat} |
| 5076 |
% \begin{parameter}{extractwidth} |
| 5077 |
% \begin{parameter}{extractheight} |
| 5078 |
% \begin{parameter}{extractdistort} |
| 5079 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 5080 |
% \begin{parameter}{extractscale} |
| 5081 |
% \begin{parameter}{extractangle} |
| 5082 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 5083 |
% \begin{parameter}{extractpretex} |
| 5084 |
% \begin{parameter}{extractapptex} |
| 5085 |
% \begin{parameter}{extractruns} |
| 5086 |
% \begin{parameter}{latexexe} |
| 5087 |
% \begin{parameter}{latexopt} |
| 5088 |
% \begin{parameter}{latexext} |
| 5089 |
% \begin{parameter}{dvipsopt} |
| 5090 |
% \begin{parameter}{pstoepsopt} |
| 5091 |
% \begin{parameter}{pstopdfopt} |
| 5092 |
% \begin{parameter}{pdftoepsopt} |
| 5093 |
% \begin{parameter}{pdftopsopt} |
| 5094 |
% \begin{parameter}{convert} |
| 5095 |
% \begin{parameter}{convertformat} |
| 5096 |
% \begin{parameter}{convertdpi} |
| 5097 |
% \begin{parameter}{magicksetting} |
| 5098 |
% \begin{parameter}{magickoperator} |
| 5099 |
% \begin{parameter}{gsopt} |
| 5100 |
% \begin{parameter}{gsdevice} |
| 5101 |
% \begin{parameter}{clean} |
| 5102 |
% \begin{parameter}{exclude} |
| 5103 |
% The parameters \prm{angle} and \prm{origin} are defined as pendants to the |
| 5104 |
% keys provided by \cs{includegraphics}. |
| 5105 |
% \begin{macrocode} |
| 5106 |
%<*extract> |
| 5107 |
\newcommand*\svgx@param@angle{0} |
| 5108 |
\svg@local@param@def{% |
| 5109 |
\DefineFamilyKey[.param]{SVG}{extractangle}{% |
| 5110 |
\FamilyKeyStateUnknownValue% |
| 5111 |
\svg@ifvalueisrelax{#1}{% |
| 5112 |
\renewcommand*\svgx@param@angle{0}% |
| 5113 |
\FamilyKeyStateProcessed% |
| 5114 |
}{% |
| 5115 |
\Ifstr{#1}{inherit}{% |
| 5116 |
\renewcommand*\svgx@param@angle{\svg@param@angle}% |
| 5117 |
\FamilyKeyStateProcessed% |
| 5118 |
}{% |
| 5119 |
\Ifisdimension{#1\p@}{% |
| 5120 |
\renewcommand*\svgx@param@angle{#1}% |
| 5121 |
\FamilyKeyStateProcessed% |
| 5122 |
}{}% |
| 5123 |
}% |
| 5124 |
}% |
| 5125 |
}% |
| 5126 |
} |
| 5127 |
%</extract> |
| 5128 |
% \end{macrocode} |
| 5129 |
% \end{parameter}^^A exclude |
| 5130 |
% \end{parameter}^^A clean |
| 5131 |
% \end{parameter}^^A gsdevice |
| 5132 |
% \end{parameter}^^A gsopt |
| 5133 |
% \end{parameter}^^A magickoperator |
| 5134 |
% \end{parameter}^^A magicksetting |
| 5135 |
% \end{parameter}^^A convertdpi |
| 5136 |
% \end{parameter}^^A convertformat |
| 5137 |
% \end{parameter}^^A convert |
| 5138 |
% \end{parameter}^^A pdftopsopt |
| 5139 |
% \end{parameter}^^A pdftoepsopt |
| 5140 |
% \end{parameter}^^A pstopdfopt |
| 5141 |
% \end{parameter}^^A pstoepsopt |
| 5142 |
% \end{parameter}^^A dvipsopt |
| 5143 |
% \end{parameter}^^A latexext |
| 5144 |
% \end{parameter}^^A latexopt |
| 5145 |
% \end{parameter}^^A latexexe |
| 5146 |
% \end{parameter}^^A extractruns |
| 5147 |
% \end{parameter}^^A extractapptex |
| 5148 |
% \end{parameter}^^A extractpretex |
| 5149 |
% \end{parameter}^^A extractangle |
| 5150 |
% \end{parameter}^^A extractscale |
| 5151 |
% \end{parameter}^^A extractdistort |
| 5152 |
% \end{parameter}^^A extractheight |
| 5153 |
% \end{parameter}^^A extractwidth |
| 5154 |
% \end{parameter}^^A extractformat |
| 5155 |
% \end{parameter}^^A extractpreamble |
| 5156 |
% \end{parameter}^^A extract |
| 5157 |
% \end{macro}^^A \includeinkscape |
| 5158 |
% \end{parameter}^^A exclude |
| 5159 |
% \end{parameter}^^A clean |
| 5160 |
% \end{parameter}^^A gsdevice |
| 5161 |
% \end{parameter}^^A gsopt |
| 5162 |
% \end{parameter}^^A magickoperator |
| 5163 |
% \end{parameter}^^A magicksetting |
| 5164 |
% \end{parameter}^^A convertdpi |
| 5165 |
% \end{parameter}^^A convertformat |
| 5166 |
% \end{parameter}^^A convert |
| 5167 |
% \end{parameter}^^A pdftopsopt |
| 5168 |
% \end{parameter}^^A pdftoepsopt |
| 5169 |
% \end{parameter}^^A pstopdfopt |
| 5170 |
% \end{parameter}^^A pstoepsopt |
| 5171 |
% \end{parameter}^^A dvipsopt |
| 5172 |
% \end{parameter}^^A latexext |
| 5173 |
% \end{parameter}^^A latexopt |
| 5174 |
% \end{parameter}^^A latexexe |
| 5175 |
% \end{parameter}^^A extractruns |
| 5176 |
% \end{parameter}^^A extractapptex |
| 5177 |
% \end{parameter}^^A extractpretex |
| 5178 |
% \end{parameter}^^A extractangle |
| 5179 |
% \end{parameter}^^A extractscale |
| 5180 |
% \end{parameter}^^A extractdistort |
| 5181 |
% \end{parameter}^^A extractheight |
| 5182 |
% \end{parameter}^^A extractwidth |
| 5183 |
% \end{parameter}^^A extractformat |
| 5184 |
% \end{parameter}^^A extractpreamble |
| 5185 |
% \end{parameter}^^A extract |
| 5186 |
% \end{macro}^^A \includesvg |
| 5187 |
% \begin{macro}{\svghidepreamblestart} |
| 5188 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 5189 |
% \begin{macro}{\svghidepreambleend} |
| 5190 |
% \changes{v2.00}{2017/02/24}{new}^^A |
| 5191 |
% Some dummys for package \pkg{svg}. |
| 5192 |
% \begin{macrocode} |
| 5193 |
%<*main> |
| 5194 |
\newcommand*\svghidepreamblestart{% |
| 5195 |
\PackageWarning{svg}{% |
| 5196 |
The macro `\string\svghidepreamblestart' is only meant\MessageBreak% |
| 5197 |
to be used together with package `svg-extract'. \MessageBreak% |
| 5198 |
Nevertheless, nothing will happen% |
| 5199 |
}% |
| 5200 |
} |
| 5201 |
\newcommand*\svghidepreambleend{% |
| 5202 |
\PackageWarning{svg}{% |
| 5203 |
The macro `\string\svghidepreambleend' is only meant\MessageBreak% |
| 5204 |
to be used together with package `svg-extract'. \MessageBreak% |
| 5205 |
Nevertheless, nothing will happen% |
| 5206 |
}% |
| 5207 |
} |
| 5208 |
%</main> |
| 5209 |
% \end{macrocode} |
| 5210 |
% These two macros can be used to hide some parts of the preamble during |
| 5211 |
% reading the preamble of the main document. |
| 5212 |
% \begin{macrocode} |
| 5213 |
%<*extract> |
| 5214 |
\let\svghidepreamblestart\relax |
| 5215 |
\let\svghidepreambleend\relax |
| 5216 |
%</extract> |
| 5217 |
% \end{macrocode} |
| 5218 |
% \end{macro}^^A \svghidepreambleend |
| 5219 |
% \end{macro}^^A \svghidepreamblestart |
| 5220 |
% |
| 5221 |
% |
| 5222 |
% |
| 5223 |
% \subsection{Auxiliary macros} |
| 5224 |
% |
| 5225 |
% \begin{macro}{\svg@extract} |
| 5226 |
% The macro \cs{svg@extract} does the actual job of both extracting and |
| 5227 |
% converting independent graphic files. Since it is necessary to run it with |
| 5228 |
% \file{-{}-shell-escape} enabled, the command raises a warning if it is not |
| 5229 |
% activated. Afterwards, the package is finished. |
| 5230 |
% \begin{macrocode} |
| 5231 |
%<*main> |
| 5232 |
\newcommand*\svg@extract[1]{} |
| 5233 |
%</main> |
| 5234 |
%<*extract> |
| 5235 |
\ifnum\pdf@shellescape=\@ne\relax\else% |
| 5236 |
\renewcommand*\svg@extract[1]{% |
| 5237 |
\if@svgx@run% |
| 5238 |
\begingroup% |
| 5239 |
\edef\svg@tempa{#1}% |
| 5240 |
\svg@quotes@remove{\svg@tempa}% |
| 5241 |
\PackageWarning{svg-extract}{% |
| 5242 |
You didn't enable `shell escape' (or `write18')\MessageBreak% |
| 5243 |
so it wasn't possible to run the extraction for\MessageBreak% |
| 5244 |
file `\svg@tempa'\MessageBreak% |
| 5245 |
}% |
| 5246 |
\endgroup% |
| 5247 |
\fi% |
| 5248 |
}% |
| 5249 |
\expandafter\endinput% |
| 5250 |
\fi |
| 5251 |
%</extract> |
| 5252 |
% \end{macrocode} |
| 5253 |
% \end{macro}^^A \svg@extract |
| 5254 |
% |
| 5255 |
% \iffalse |
| 5256 |
%</package&body> |
| 5257 |
%<*package&body&extract> |
| 5258 |
% \fi |
| 5259 |
% |
| 5260 |
% \begin{macro}{\svgx@stream@in} |
| 5261 |
% \begin{macro}{\svgx@read@line} |
| 5262 |
% \begin{macro}{\svgx@stream@out} |
| 5263 |
% \begin{macro}{\if@svgx@preamble@write} |
| 5264 |
% Both an input stream and an output stream are necessary for this as well as a |
| 5265 |
% token register, which is used to store all commands which should be executed |
| 5266 |
% on shell. |
| 5267 |
% \begin{macrocode} |
| 5268 |
\newread\svgx@stream@in |
| 5269 |
\newcommand*\svgx@read@line{} |
| 5270 |
\newwrite\svgx@stream@out |
| 5271 |
\newif\if@svgx@preamble@write |
| 5272 |
% \end{macrocode} |
| 5273 |
% \end{macro}^^A \if@svgx@preamble@write |
| 5274 |
% \end{macro}^^A \svgx@stream@out |
| 5275 |
% \end{macro}^^A \svgx@read@line |
| 5276 |
% \end{macro}^^A \svgx@stream@in |
| 5277 |
% \begin{macro}{\svg@extract} |
| 5278 |
% If flag \file{-{}-shell-escape} is enabled, the command is defined with its |
| 5279 |
% intended functionality. It runs all necessary processes to extract and |
| 5280 |
% convert graphic files. |
| 5281 |
% \begin{macrocode} |
| 5282 |
\renewcommand*\svg@extract[1]{% |
| 5283 |
% \end{macrocode} |
| 5284 |
% If option \opt{extract} is enabled\dots |
| 5285 |
% \begin{macrocode} |
| 5286 |
\if@svgx@run% |
| 5287 |
% \end{macrocode} |
| 5288 |
% \dots the macro \cs{svgx@get@out@sec} is used to get the current level |
| 5289 |
% numbering within the document and the counter for extracted graphics is |
| 5290 |
% stepped. After that, a separate auxiliary \LaTeX~file is created for |
| 5291 |
% extracting independent graphic files. The macro \cs{svgx@get@out@sec} is used |
| 5292 |
% to get the current level numbering within the document. The specified |
| 5293 |
% preamble is read for this task, if it exists. It is first searched in the |
| 5294 |
% same folder as the SVG~file and if it wasn't found, in any other valid folder |
| 5295 |
% for SVG~files. |
| 5296 |
% \begin{macrocode} |
| 5297 |
\if@svgx@out@sec% |
| 5298 |
\svgx@get@out@sec% |
| 5299 |
\fi% |
| 5300 |
\stepcounter{svgx@out@count}% |
| 5301 |
\begingroup% |
| 5302 |
\def\svg@tempa##1.##2\@nil{% |
| 5303 |
\IfArgIsEmpty{##2}{\edef\svgx@preamble{##1.\svgx@latex@ext}}{}% |
| 5304 |
}% |
| 5305 |
\expandafter\svg@tempa\svgx@preamble.\@nil% |
| 5306 |
\IfFileExists{\svg@file@path\svgx@preamble}{% |
| 5307 |
\@svg@file@foundtrue% |
| 5308 |
}{% |
| 5309 |
\svg@get@path[]{\svgx@preamble}{\svg@out@path}% |
| 5310 |
\def\svg@tempa####1.####2\@nil{% |
| 5311 |
\edef\svgx@preamble{\svg@file@name.####2}% |
| 5312 |
}% |
| 5313 |
\expandafter\svg@tempa\svgx@preamble\@nil% |
| 5314 |
}% |
| 5315 |
\edef\svg@tempa{% |
| 5316 |
\endgroup% |
| 5317 |
\if@svg@file@found% |
| 5318 |
\ifx\svg@file@path\@empty% |
| 5319 |
\def\noexpand\svgx@preamble{./\svgx@preamble}% |
| 5320 |
\else% |
| 5321 |
\def\noexpand\svgx@preamble{\svg@file@path\svgx@preamble}% |
| 5322 |
\fi% |
| 5323 |
\fi% |
| 5324 |
}% |
| 5325 |
\svg@tempa% |
| 5326 |
\begingroup% |
| 5327 |
\endlinechar=\m@ne% |
| 5328 |
\IfFileExists{\svgx@preamble}{% |
| 5329 |
\PackageInfo{svg-extract}{% |
| 5330 |
The preamble file `\svgx@preamble'\MessageBreak% |
| 5331 |
is used for the generation of the auxiliary file\MessageBreak% |
| 5332 |
`\svgx@out@name.\svgx@latex@ext'% |
| 5333 |
}% |
| 5334 |
% \end{macrocode} |
| 5335 |
% The catcodes for |#| need to be changed to prevent doubling when |
| 5336 |
% reading the line. |
| 5337 |
% \begin{macrocode} |
| 5338 |
\catcode`\#=12\relax% |
| 5339 |
\immediate\openout\svgx@stream@out=\svgx@out@name.\svgx@latex@ext% |
| 5340 |
\immediate\openin\svgx@stream@in=\svgx@preamble% |
| 5341 |
\@svg@tempswatrue% |
| 5342 |
\@svgx@preamble@writetrue% |
| 5343 |
\def\svgx@read@line{}% |
| 5344 |
% \end{macrocode} |
| 5345 |
% The given preamble file is read line by line and written to the separate |
| 5346 |
% auxiliary \LaTeX~file \file{\cs{svgx@out@name}.\cs{svgx@latex@ext}} via the |
| 5347 |
% output stream. |
| 5348 |
% \begin{macrocode} |
| 5349 |
\@whilesw\if@svg@tempswa\fi{% |
| 5350 |
\immediate\read\svgx@stream@in to\svgx@read@line% |
| 5351 |
\ifx\svgx@read@line\@empty% |
| 5352 |
\ifeof\svgx@stream@in\@svg@tempswafalse\fi% |
| 5353 |
\else% |
| 5354 |
% \end{macrocode} |
| 5355 |
% With \cs{svghidepreamblestart} and \cs{svghidepreambleend} it is possible for |
| 5356 |
% the user to omit certain parts of the preamble. Therefor the two macros |
| 5357 |
% \cs{svgx@read@preamble@till} and \cs{svgx@read@preamble@from} are toggling |
| 5358 |
% the switch \cs{if@svgx@preamble@write} |
| 5359 |
% \begin{macrocode} |
| 5360 |
\svgx@read@preamble@till{\svghidepreamblestart}{}% |
| 5361 |
\svgx@read@preamble@from{\svghidepreambleend}{}% |
| 5362 |
% \end{macrocode} |
| 5363 |
% If the desired end of the preamble (\cs{svgx@endpreamble}) was found, the |
| 5364 |
% readout is terminated by switching \cs{if@svg@tempswa} to \val{false}. |
| 5365 |
% \begin{macrocode} |
| 5366 |
\svgx@read@preamble@till{\svgx@endpreamble}{\@svg@tempswafalse}% |
| 5367 |
\if@svgx@preamble@write% |
| 5368 |
% \end{macrocode} |
| 5369 |
% During the readout process, it is searched with \cs{svgx@documentclass} for |
| 5370 |
% the appearance of \cs{documentclass} and \cs{if@svgx@classfound} is set to |
| 5371 |
% \val{true} if it was found. |
| 5372 |
% \begin{macrocode} |
| 5373 |
\if@svgx@classfound\else% |
| 5374 |
\expandafter\svgx@documentclass% |
| 5375 |
\svgx@read@line\documentclass\documentclass\@nil% |
| 5376 |
\fi% |
| 5377 |
% \end{macrocode} |
| 5378 |
% Writing out the---maybe manipulated---read in line. |
| 5379 |
% \begin{macrocode} |
| 5380 |
\ifx\svgx@read@line\@empty\else% |
| 5381 |
\immediate\write\svgx@stream@out{% |
| 5382 |
\unexpanded\expandafter{\svgx@read@line}% |
| 5383 |
}% |
| 5384 |
\fi% |
| 5385 |
\fi% |
| 5386 |
\fi% |
| 5387 |
}% |
| 5388 |
\immediate\closein\svgx@stream@in% |
| 5389 |
\immediate\closeout\svgx@stream@out% |
| 5390 |
\catcode`\#=6\relax% |
| 5391 |
% \end{macrocode} |
| 5392 |
% Once the separate auxiliary \LaTeX~file is written, it is read in again and |
| 5393 |
% its content is stored in \cs{svg@tempa}, since it is necessary to prepend |
| 5394 |
% some stuff to the preamble, for example a maybe not existent document class. |
| 5395 |
% \begin{macrocode} |
| 5396 |
\immediate\openin\svgx@stream@in=\svgx@out@name.\svgx@latex@ext% |
| 5397 |
\def\svg@tempa{}% |
| 5398 |
\loop\unless\ifeof\svgx@stream@in% |
| 5399 |
\readline\svgx@stream@in to\svgx@read@line% |
| 5400 |
\ifx\svgx@read@line\@empty\else% |
| 5401 |
\edef\svg@tempa{% |
| 5402 |
\unexpanded\expandafter{\svg@tempa}% |
| 5403 |
\unexpanded\expandafter{\svgx@read@line}^^J% |
| 5404 |
}% |
| 5405 |
\fi% |
| 5406 |
\repeat% |
| 5407 |
\immediate\closein\svgx@stream@in% |
| 5408 |
}{% |
| 5409 |
% \end{macrocode} |
| 5410 |
% If a file was given that doesn't exist, a warning is issued. |
| 5411 |
% \begin{macrocode} |
| 5412 |
\svg@quotes@remove{\svgx@preamble}% |
| 5413 |
\ifx\svgx@preamble\@empty\else% |
| 5414 |
\PackageWarning{svg-extract}{% |
| 5415 |
The preamble file `\svgx@preamble'\MessageBreak% |
| 5416 |
does not exist% |
| 5417 |
}% |
| 5418 |
\fi% |
| 5419 |
\def\svg@tempa{}% |
| 5420 |
}% |
| 5421 |
% \end{macrocode} |
| 5422 |
% After the preamble was read in and stored in \cs{svg@tempa}, the separate |
| 5423 |
% auxiliary \LaTeX~file is written again. Some information are written right at |
| 5424 |
% the beginning of the file. |
| 5425 |
% \begin{macrocode} |
| 5426 |
\immediate\openout\svgx@stream@out=\svgx@out@name.\svgx@latex@ext% |
| 5427 |
\immediate\write\svgx@stream@out{% |
| 5428 |
\@percentchar\@percentchar\space This file was generated by package |
| 5429 |
`svg-extract'^^J% |
| 5430 |
\@percentchar\@percentchar\space from source `\jobname'^^J% |
| 5431 |
\@percentchar\@percentchar\space It's intended to be compiled with |
| 5432 |
`\svgx@latex@exe\ifx\svgx@latex@opt\@empty\else\space\svgx@latex@opt\fi' |
| 5433 |
}% |
| 5434 |
% \end{macrocode} |
| 5435 |
% With the intention of passing the correct paper dimensions, the calculating |
| 5436 |
% of the paper size is executed with \cs{AtBeginDocument} even before the |
| 5437 |
% document class, so that this is definitely the first thing to happen at the |
| 5438 |
% beginning of the document. Additionally, it is ensured that the \cs{special} |
| 5439 |
% command is definitely used with the correct paper size, when creating a |
| 5440 |
% DVI~file. |
| 5441 |
% \begin{macrocode} |
| 5442 |
\immediate\write\svgx@stream@out{% |
| 5443 |
\string\AtBeginDocument{\@percentchar^^J% |
| 5444 |
\space\space\string\svgxsetpapersize\@percentchar^^J% |
| 5445 |
\ifxetex\else\ifpdf\else% |
| 5446 |
\space\space\string\AtBeginDvi{\string\special{% |
| 5447 |
papersize=\string\the\string\paperwidth,% |
| 5448 |
\string\the\string\paperheight% |
| 5449 |
}}\@percentchar^^J% |
| 5450 |
\fi\fi% |
| 5451 |
}^^J% |
| 5452 |
\string\PassOptionsToPackage{hidelinks}{hyperref}% |
| 5453 |
}% |
| 5454 |
% \end{macrocode} |
| 5455 |
% If no document class was found during reading the preamble file, then class |
| 5456 |
% \cs{article} is used. |
| 5457 |
% \begin{macrocode} |
| 5458 |
\if@svgx@classfound\else% |
| 5459 |
\immediate\write\svgx@stream@out{\string\documentclass{article}}% |
| 5460 |
\fi% |
| 5461 |
% \end{macrocode} |
| 5462 |
% And now the stored preamble. |
| 5463 |
% \begin{macrocode} |
| 5464 |
\ifx\svg@tempa\@empty\else% |
| 5465 |
\immediate\write\svgx@stream@out{\unexpanded\expandafter{\svg@tempa}}% |
| 5466 |
\fi% |
| 5467 |
% \end{macrocode} |
| 5468 |
% After the given preamble was written, package \pkg{svg-extract} will be |
| 5469 |
% loaded in case it was forgotten. |
| 5470 |
% \begin{macrocode} |
| 5471 |
\immediate\write\svgx@stream@out{\string\usepackage{svg-extract}}% |
| 5472 |
% \end{macrocode} |
| 5473 |
% Now all parameters relevant for the extraction are evaluated and appended. |
| 5474 |
% \begin{macrocode} |
| 5475 |
\def\svg@tempa##1{% |
| 5476 |
\immediate\write\svgx@stream@out{\string\svgsetup{##1}}% |
| 5477 |
}% |
| 5478 |
\if@svg@ink@latex\else% |
| 5479 |
\svg@tempa{inkscapelatex=false}% |
| 5480 |
\fi% |
| 5481 |
\ifdim\svgx@param@width>\z@\relax% |
| 5482 |
\svg@tempa{width=\svgx@param@width}% |
| 5483 |
\fi% |
| 5484 |
\ifdim\svgx@param@height>\z@\relax% |
| 5485 |
\svg@tempa{height=\svgx@param@height}% |
| 5486 |
\fi% |
| 5487 |
\if@svgx@param@distort% |
| 5488 |
\svg@tempa{distort=true}% |
| 5489 |
\fi% |
| 5490 |
\ifdim\dimexpr\svgx@param@scale\p@\relax=\p@\relax\else% |
| 5491 |
\svg@tempa{scale=\svgx@param@scale}% |
| 5492 |
\fi% |
| 5493 |
\def\svg@tempb{\svg@param@pretex}% |
| 5494 |
\ifx\svgx@param@pretex\svg@tempb\relax% |
| 5495 |
\let\svgx@param@pretex\svg@param@pretex% |
| 5496 |
\fi% |
| 5497 |
\ifx\svgx@param@pretex\relax\else% |
| 5498 |
\svg@tempa{pretex=\unexpanded\expandafter{\svgx@param@pretex}}% |
| 5499 |
\fi% |
| 5500 |
\def\svg@tempb{\svg@param@apptex}% |
| 5501 |
\ifx\svgx@param@apptex\svg@tempb\relax% |
| 5502 |
\let\svgx@param@apptex\svg@param@apptex% |
| 5503 |
\fi% |
| 5504 |
\ifx\svgx@param@apptex\relax\else% |
| 5505 |
\svg@tempa{apptex=\unexpanded\expandafter{\svgx@param@apptex}}% |
| 5506 |
\fi% |
| 5507 |
% \end{macrocode} |
| 5508 |
% Parameter \prm{lastpage} is only considered for including PDF~files with |
| 5509 |
% \LaTeX~support. |
| 5510 |
% \begin{macrocode} |
| 5511 |
\let\svg@tempa\@empty% |
| 5512 |
\if@svg@ink@latex% |
| 5513 |
\Ifstr{\svg@ink@format}{pdf}{% |
| 5514 |
\ifnum\value{svg@param@lastpage}>\z@\relax% |
| 5515 |
\edef\svg@tempa{lastpage=\the\value{svg@param@lastpage}}% |
| 5516 |
\else% |
| 5517 |
\ifnum\value{svg@param@lastpage}=\z@\relax% |
| 5518 |
\def\svg@tempa{lastpage=true}% |
| 5519 |
\else% |
| 5520 |
\def\svg@tempa{lastpage=false}% |
| 5521 |
\fi% |
| 5522 |
\fi% |
| 5523 |
}{}% |
| 5524 |
\fi% |
| 5525 |
% \end{macrocode} |
| 5526 |
% The rotation angle, if given. |
| 5527 |
% \begin{macrocode} |
| 5528 |
\ifdim\dimexpr\svgx@param@angle\p@\relax=\z@\relax\else% |
| 5529 |
\edef\svg@tempa{% |
| 5530 |
angle=\svgx@param@angle\ifx\svg@tempa\@empty\else,\svg@tempa\fi% |
| 5531 |
}% |
| 5532 |
\fi% |
| 5533 |
% \end{macrocode} |
| 5534 |
% As this is now the end of the preamble and just before the beginning of the |
| 5535 |
% document, the paper dimension are set again to make sure, that these settings |
| 5536 |
% are active at the end of the preamble. Additionally, it is executed again at |
| 5537 |
% the very end of \cs{AtBeginDocument} to ensure, that no other package used |
| 5538 |
% this hook for manipulating the paper size. |
| 5539 |
% \begin{macrocode} |
| 5540 |
\ifx\svg@tempa\@empty% |
| 5541 |
\def\svg@tempa{\string\svgxsetbox{#1}}% |
| 5542 |
\else% |
| 5543 |
\edef\svg@tempa{\noexpand\string\noexpand\svgxsetbox[\svg@tempa]{#1}}% |
| 5544 |
\fi% |
| 5545 |
\immediate\write\svgx@stream@out{\svg@tempa}% |
| 5546 |
% \end{macrocode} |
| 5547 |
% Package \pkg{xr} is used to evaluate possible labels within the included |
| 5548 |
% \app{Inkscape}~\LaTeX~file. |
| 5549 |
% \begin{macrocode} |
| 5550 |
\if@svg@ink@latex% |
| 5551 |
\IfFileExists{xr.sty}{% |
| 5552 |
\immediate\write\svgx@stream@out{% |
| 5553 |
\string\usepackage{xr}^^J% |
| 5554 |
\string\externaldocument{\jobname}^^J% |
| 5555 |
}% |
| 5556 |
}{}% |
| 5557 |
\fi% |
| 5558 |
\immediate\write\svgx@stream@out{% |
| 5559 |
\string\begin{document}^^J% |
| 5560 |
\string\pagestyle{empty}^^J% |
| 5561 |
\string\svgxoutputbox\@percentchar^^J% |
| 5562 |
\string\end{document}% |
| 5563 |
}% |
| 5564 |
\immediate\closeout\svgx@stream@out% |
| 5565 |
\endgroup% |
| 5566 |
% \end{macrocode} |
| 5567 |
% After creating the separate auxiliary \LaTeX~file, the actual extraction and |
| 5568 |
% conversion can be done. |
| 5569 |
% \begin{macrocode} |
| 5570 |
\Ifstr{\svgx@format\svgx@cnv@format}{}{% |
| 5571 |
\PackageWarning{svg-extract}{% |
| 5572 |
Both keys `extractformat' and `convertformat' are\MessageBreak% |
| 5573 |
empty, so nothing to do so far% |
| 5574 |
}% |
| 5575 |
}{% |
| 5576 |
% \end{macrocode} |
| 5577 |
% As the extraction maybe needs to include the main~auxiliary~file with |
| 5578 |
% \cs{externaldocument} provided by package \pkg{xr} it is necessary to do all |
| 5579 |
% related stuff after the main~auxiliary~file was written. This is done with |
| 5580 |
% \cs{AfterReadingMainAux} provided by package \pkg{scrlfile}. |
| 5581 |
% \begin{macrocode} |
| 5582 |
\svg@quotes@remove{\svgx@out@path}% |
| 5583 |
\svg@quotes@remove{\svgx@out@name}% |
| 5584 |
% \end{macrocode} |
| 5585 |
% All generated files will be moved to the desired output folder, which is |
| 5586 |
% given by option \opt{extractpath}. Therefor, this folder is created. |
| 5587 |
% \begin{macrocode} |
| 5588 |
\edef\svg@tempb{% |
| 5589 |
\noexpand\svg@shell@mkdir{\svgx@out@path}% |
| 5590 |
}% |
| 5591 |
\expandafter\AfterReadingMainAux\expandafter{\svg@tempb}% |
| 5592 |
% \end{macrocode} |
| 5593 |
% First of all the separate auxiliary \LaTeX~file is compiled with the detected |
| 5594 |
% \LaTeX~engine (\cs{svgx@latex@exe}) as often as defined by counter option |
| 5595 |
% \opt{extractruns}. |
| 5596 |
% \begin{macrocode} |
| 5597 |
\edef\svg@tempb{% |
| 5598 |
\noexpand\PackageInfo{svg-extract}{% |
| 5599 |
Running LaTeX (\svgx@latex@exe) for graphic extraction% |
| 5600 |
\ifx\svgx@latex@opt\@empty\else% |
| 5601 |
\MessageBreak with added options `\svgx@latex@opt'% |
| 5602 |
\fi% |
| 5603 |
}% |
| 5604 |
}% |
| 5605 |
\expandafter\AfterReadingMainAux\expandafter{\svg@tempb}% |
| 5606 |
\edef\svg@tempb{% |
| 5607 |
\noexpand\ShellEscape{% |
| 5608 |
\svgx@latex@exe\space\svgx@latex@opt\space% |
| 5609 |
"\svgx@out@name.\svgx@latex@ext"% |
| 5610 |
}% |
| 5611 |
}% |
| 5612 |
\loop\ifnum\value{svgx@runs}>\z@\relax% |
| 5613 |
\expandafter\AfterReadingMainAux\expandafter{\svg@tempb}% |
| 5614 |
\advance\c@svgx@runs\m@ne% |
| 5615 |
\repeat% |
| 5616 |
% \end{macrocode} |
| 5617 |
% All files requested with option \opt{extractformat} are created with internal |
| 5618 |
% conversion tools supplied by most \LaTeX~distributions if necessary. |
| 5619 |
% \begin{macrocode} |
| 5620 |
\def\svg@tempa##1##2##3{% |
| 5621 |
\edef\svg@tempb{% |
| 5622 |
\noexpand\ShellEscape{% |
| 5623 |
\@nameuse{svgx@##1@exe}\space\@nameuse{svgx@##1@opt}\space% |
| 5624 |
"\svgx@out@name.##2"% |
| 5625 |
}% |
| 5626 |
}% |
| 5627 |
\AfterReadingMainAux{\PackageInfo{svg-extract}{Running ##1}}% |
| 5628 |
\expandafter\AfterReadingMainAux\expandafter{\svg@tempb}% |
| 5629 |
}% |
| 5630 |
\@svg@tempswafalse% |
| 5631 |
\ifxetex\else\ifpdf\else% |
| 5632 |
\@svg@tempswatrue% |
| 5633 |
\fi\fi% |
| 5634 |
\if@svg@tempswa% |
| 5635 |
\svg@tempa{dvips}{dvi}{ps}% |
| 5636 |
\svgx@ifinlist{eps}{\svgx@format}{\svg@tempa{pstoeps}{ps}{eps}}{}% |
| 5637 |
\svgx@ifinlist{pdf}{\svgx@format}{\svg@tempa{pstopdf}{ps}{pdf}}{}% |
| 5638 |
\else% |
| 5639 |
\svgx@ifinlist{eps}{\svgx@format}{\svg@tempa{pdftoeps}{pdf}{eps}}{}% |
| 5640 |
\svgx@ifinlist{ps}{\svgx@format}{\svg@tempa{pdftops}{pdf}{ps}}{}% |
| 5641 |
\fi% |
| 5642 |
% \end{macrocode} |
| 5643 |
% Now the desired conversion tool is invoked if requested. |
| 5644 |
% \begin{macrocode} |
| 5645 |
\if@svgx@cnv@run% |
| 5646 |
% \end{macrocode} |
| 5647 |
% If no density was given at all, the density for PNG~files is set to |
| 5648 |
% \val{300dpi} by default. |
| 5649 |
% \begin{macrocode} |
| 5650 |
\ifx\svgx@cnv@dpi\relax% |
| 5651 |
\ifx\svgx@cnv@dpi@png\@undefined% |
| 5652 |
\def\svgx@cnv@dpi@png{300}% |
| 5653 |
\fi% |
| 5654 |
\fi% |
| 5655 |
% \end{macrocode} |
| 5656 |
% The first given file type with option \opt{extractformat} is used as source |
| 5657 |
% for the conversion process. |
| 5658 |
% \begin{macrocode} |
| 5659 |
\expandafter\svgx@cnv@get@informat\expandafter{\svgx@format}% |
| 5660 |
% \end{macrocode} |
| 5661 |
% The conversion is done for each desired file type given in a list by option |
| 5662 |
% \opt{convertformat}. |
| 5663 |
% \begin{macrocode} |
| 5664 |
\@for\svg@tempa:=\svgx@cnv@format\do{% |
| 5665 |
\ifx\svg@tempa\@empty\else% |
| 5666 |
\expandafter\svgx@ifinlist\expandafter{\svg@tempa}{\svgx@format}{% |
| 5667 |
\PackageWarning{svg-extract}{% |
| 5668 |
File type `\svg@tempa' was specified for option\MessageBreak% |
| 5669 |
`extractformat' (\svgx@format) as well as for \MessageBreak% |
| 5670 |
option `convertformat' (\svgx@cnv@format) so the\MessageBreak% |
| 5671 |
conversion won't be done% |
| 5672 |
}% |
| 5673 |
}{% |
| 5674 |
\edef\svg@tempb{% |
| 5675 |
\noexpand\PackageInfo{svg-extract}{% |
| 5676 |
Converting `\svgx@out@name.\svgx@cnv@informat'\MessageBreak% |
| 5677 |
to `\svgx@out@name.\svg@tempa'% |
| 5678 |
}% |
| 5679 |
}% |
| 5680 |
\expandafter\AfterReadingMainAux\expandafter{\svg@tempb}% |
| 5681 |
\edef\svg@tempb{% |
| 5682 |
\noexpand\ShellEscape{% |
| 5683 |
\svgx@cnv@cmd{\svgx@out@name}{\svgx@cnv@informat}{\svg@tempa}% |
| 5684 |
}% |
| 5685 |
}% |
| 5686 |
\expandafter\AfterReadingMainAux\expandafter{\svg@tempb}% |
| 5687 |
}% |
| 5688 |
\fi% |
| 5689 |
}% |
| 5690 |
\fi% |
| 5691 |
% \end{macrocode} |
| 5692 |
% As both extraction and conversion are done, all files are moved to the |
| 5693 |
% desired output folder (\opt{extractpath}). |
| 5694 |
% \begin{macrocode} |
| 5695 |
\edef\svg@tempa{\svgx@format\if@svgx@cnv@run,\svgx@cnv@format\fi}% |
| 5696 |
\@for\svg@tempb:=\svg@tempa\do{% |
| 5697 |
\ifx\svg@tempb\@empty\else% |
| 5698 |
\edef\svg@tempb{% |
| 5699 |
\noexpand\svgx@move{\svgx@out@name}{\svg@tempb}{\svgx@out@path}% |
| 5700 |
}% |
| 5701 |
\expandafter\AfterReadingMainAux\expandafter{\svg@tempb}% |
| 5702 |
\fi% |
| 5703 |
}% |
| 5704 |
% \end{macrocode} |
| 5705 |
% At the very end, all unwanted auxiliary files are deleted. |
| 5706 |
% \begin{macrocode} |
| 5707 |
\@for\svg@tempa:=\svgx@clean\do{% |
| 5708 |
\expandafter\svgx@ifinlist\expandafter{\svg@tempa}{\svg@tempb}{}{% |
| 5709 |
\edef\svg@tempb{% |
| 5710 |
\noexpand\IfFileExists{"\svgx@out@name".\svg@tempa}{% |
| 5711 |
\noexpand\svg@shell@rm{\svgx@out@name.\svg@tempa}% |
| 5712 |
}{}% |
| 5713 |
}% |
| 5714 |
\expandafter\AtEndDocument\expandafter{% |
| 5715 |
\expandafter\AfterReadingMainAux\expandafter{\svg@tempb}% |
| 5716 |
}% |
| 5717 |
}% |
| 5718 |
}% |
| 5719 |
}% |
| 5720 |
\fi% |
| 5721 |
} |
| 5722 |
% \end{macrocode} |
| 5723 |
% \end{macro}^^A \svg@extract |
| 5724 |
% \begin{macro}{\svgx@get@out@sec} |
| 5725 |
% The macro \cs{svgx@get@out@sec} reads all sectioning counters in order to |
| 5726 |
% get the numbering of the current sectioning level. The value is stored in |
| 5727 |
% \cs{svgx@out@sec}. |
| 5728 |
% \begin{macrocode} |
| 5729 |
\newcommand*\svgx@get@out@sec{% |
| 5730 |
\begingroup% |
| 5731 |
\def\svg@tempa{}% |
| 5732 |
\@for\svg@tempb:={% |
| 5733 |
part,chapter,section,subsection,subsubsection,paragraph,subparagraph% |
| 5734 |
}\do{% |
| 5735 |
\ifx\svg@tempb\@empty\else% |
| 5736 |
\scr@ifundefinedorrelax{the\svg@tempb}{}{% |
| 5737 |
\ifnum\value{\svg@tempb}>\z@\relax% |
| 5738 |
\edef\svg@tempa{\svg@tempb}% |
| 5739 |
\fi% |
| 5740 |
}% |
| 5741 |
\fi% |
| 5742 |
}% |
| 5743 |
\edef\svg@tempb{% |
| 5744 |
\endgroup% |
| 5745 |
\ifx\svg@tempa\@empty\else% |
| 5746 |
\def\noexpand\svgx@out@sec{\csname the\svg@tempa\endcsname}% |
| 5747 |
\fi% |
| 5748 |
}% |
| 5749 |
\svg@tempb% |
| 5750 |
} |
| 5751 |
% \end{macrocode} |
| 5752 |
% \end{macro}^^A \svgx@get@out@sec |
| 5753 |
% \begin{macro}{\svgx@documentclass} |
| 5754 |
% \begin{macro}{\if@svgx@classfound} |
| 5755 |
% This delimited macro is used to find the occurrence of \cs{documentclass} |
| 5756 |
% within a read in line. The delimiter \cs{documentclass} is used twice in |
| 5757 |
% order to ignore the possible occurrence of white space or anything else right |
| 5758 |
% before \cs{documentclass}. |
| 5759 |
% \begin{macrocode} |
| 5760 |
\newif\if@svgx@classfound |
| 5761 |
\newcommand*\svgx@documentclass{} |
| 5762 |
\def\svgx@documentclass#1\documentclass#2\documentclass#3\@nil{% |
| 5763 |
\IfArgIsEmpty{#2}{}{\@svgx@classfoundtrue}% |
| 5764 |
} |
| 5765 |
% \end{macrocode} |
| 5766 |
% \end{macro}^^A \if@svgx@classfound |
| 5767 |
% \end{macro}^^A \svgx@documentclass |
| 5768 |
% \begin{macro}{\svgx@read@preamble@till} |
| 5769 |
% \begin{macro}{\svgx@read@preamble@from} |
| 5770 |
% \begin{macro}{\svgx@read@preamble@skip} |
| 5771 |
% These macros are used to skip some parts of a read in preamble file. |
| 5772 |
% \begin{macrocode} |
| 5773 |
\newcommand*\svgx@read@preamble@till[2]{% |
| 5774 |
\svgx@read@preamble@skip#1\@nil{till}{#2}% |
| 5775 |
} |
| 5776 |
\newcommand*\svgx@read@preamble@from[2]{% |
| 5777 |
\svgx@read@preamble@skip#1\@nil{from}{#2}% |
| 5778 |
} |
| 5779 |
% \end{macrocode} |
| 5780 |
% In principle, the functionality is the same as for \cs{svgx@documentclass}. |
| 5781 |
% \begin{macrocode} |
| 5782 |
\newcommand*\svgx@read@preamble@skip{} |
| 5783 |
\def\svgx@read@preamble@skip#1\@nil#2#3{% |
| 5784 |
% \end{macrocode} |
| 5785 |
% A given token is used to create the macro \cs{svg@tempa} delimited by the |
| 5786 |
% token itself which is used twice to get any stuff right before or after the |
| 5787 |
% occurrence. |
| 5788 |
% \begin{macrocode} |
| 5789 |
\def\svg@tempa##1{% |
| 5790 |
\def\svg@tempa####1##1####2##1####3\@nil{% |
| 5791 |
\IfArgIsEmpty{####3}{}{% |
| 5792 |
% \end{macrocode} |
| 5793 |
% Write everything which was found right before the macro which starts hiding |
| 5794 |
% area to the output stream and stop writing with \cs{if@svgx@preamble@write}. |
| 5795 |
% \begin{macrocode} |
| 5796 |
\Ifstr{#2}{till}{% |
| 5797 |
\IfArgIsEmpty{####1}{}{% |
| 5798 |
\immediate\write\svgx@stream@out{####1}% |
| 5799 |
}% |
| 5800 |
\@svgx@preamble@writefalse% |
| 5801 |
}{% |
| 5802 |
% \end{macrocode} |
| 5803 |
% Write everything which was found right after the macro which ends the hiding |
| 5804 |
% area and start writing again with \cs{if@svgx@preamble@write}. |
| 5805 |
% \begin{macrocode} |
| 5806 |
\Ifstr{#2}{from}{% |
| 5807 |
\IfArgIsEmpty{####2}{% |
| 5808 |
\def\svgx@read@line{}% |
| 5809 |
}{% |
| 5810 |
\def\svgx@read@line{####2}% |
| 5811 |
}% |
| 5812 |
\@svgx@preamble@writetrue% |
| 5813 |
}{}% |
| 5814 |
}% |
| 5815 |
% \end{macrocode} |
| 5816 |
% Additonal stuff which should be done. |
| 5817 |
% \begin{macrocode} |
| 5818 |
#3% |
| 5819 |
}% |
| 5820 |
}% |
| 5821 |
}% |
| 5822 |
% \end{macrocode} |
| 5823 |
% Creating the macro \cs{svg@tempa} delimited by the first argument. |
| 5824 |
% \begin{macrocode} |
| 5825 |
\edef\svg@tempb{\expandafter\detokenize\expandafter{#1}}% |
| 5826 |
\expandafter\svg@tempa\expandafter{\svg@tempb}% |
| 5827 |
% \end{macrocode} |
| 5828 |
% Calling the created macro. |
| 5829 |
% \begin{macrocode} |
| 5830 |
\edef\svg@tempb{% |
| 5831 |
\expandafter\detokenize\expandafter{\svgx@read@line}\svg@tempb\svg@tempb% |
| 5832 |
}% |
| 5833 |
\expandafter\svg@tempa\svg@tempb\@nil% |
| 5834 |
} |
| 5835 |
% \end{macrocode} |
| 5836 |
% \end{macro}^^A \svgx@read@preamble@skip |
| 5837 |
% \end{macro}^^A \svgx@read@preamble@from |
| 5838 |
% \end{macro}^^A \svgx@read@preamble@till |
| 5839 |
% \begin{macro}{\svgx@cnv@informat} |
| 5840 |
% \begin{macro}{\svgx@cnv@get@informat} |
| 5841 |
% The first list entry from argument (\cs{svgx@format}) is extracted by |
| 5842 |
% \cs{svgx@cnv@get@informat}. |
| 5843 |
% \begin{macrocode} |
| 5844 |
\newcommand*\svgx@cnv@informat{} |
| 5845 |
\newcommand*\svgx@cnv@get@informat[1]{% |
| 5846 |
\begingroup% |
| 5847 |
\def\svg@tempa##1,##2\@nil{% |
| 5848 |
\def\svg@tempa{##1}% |
| 5849 |
}% |
| 5850 |
\svg@tempa#1,\@nil% |
| 5851 |
\edef\svg@tempa{% |
| 5852 |
\endgroup% |
| 5853 |
\def\noexpand\svgx@cnv@informat{\svg@tempa}% |
| 5854 |
}% |
| 5855 |
\svg@tempa% |
| 5856 |
% \end{macrocode} |
| 5857 |
% If the first argument (\cs{svgx@format}) was empty, \cs{svgx@cnv@informat} is |
| 5858 |
% set to the a file type, which is generated anyway. |
| 5859 |
% \begin{macrocode} |
| 5860 |
\ifx\svgx@cnv@informat\@empty% |
| 5861 |
\renewcommand*\svgx@cnv@informat{pdf}% |
| 5862 |
\ifxetex\else\ifpdf\else% |
| 5863 |
\renewcommand*\svgx@cnv@informat{ps}% |
| 5864 |
\fi\fi% |
| 5865 |
\fi% |
| 5866 |
} |
| 5867 |
% \end{macrocode} |
| 5868 |
% \end{macro}^^A \svgx@cnv@get@informat |
| 5869 |
% \end{macro}^^A \svgx@cnv@informat |
| 5870 |
% \begin{macro}{\svgx@move} |
| 5871 |
% If the file doesn't exist |
| 5872 |
% \begin{macrocode} |
| 5873 |
\newcommand*\svgx@move[3]{% |
| 5874 |
\begingroup% |
| 5875 |
\IfFileExists{"#1".#2}{% |
| 5876 |
\svg@shell@mv{#1.#2}{#3#1.#2}% |
| 5877 |
}{% |
| 5878 |
\edef\svg@tempa{#2}% |
| 5879 |
\@svg@tempswafalse% |
| 5880 |
\expandafter\svgx@ifinlist\expandafter{\svg@tempa}{\svgx@cnv@format}{% |
| 5881 |
\@svg@tempswatrue% |
| 5882 |
\def\svg@tempb{conversion}% |
| 5883 |
}{% |
| 5884 |
\expandafter\svgx@ifinlist\expandafter{\svg@tempa}{pdf,ps,eps}{% |
| 5885 |
\@svg@tempswatrue% |
| 5886 |
\def\svg@tempb{extraction}% |
| 5887 |
}{}% |
| 5888 |
}% |
| 5889 |
\if@svg@tempswa% |
| 5890 |
\edef\svg@tempb{% |
| 5891 |
The graphic file \svg@tempb\space failed\MessageBreak% |
| 5892 |
for `#1.#2'\MessageBreak% |
| 5893 |
Troubleshooting: Please check the log file how\MessageBreak% |
| 5894 |
the invocation of the extraction took place and\MessageBreak% |
| 5895 |
try to execute it yourself in the terminal% |
| 5896 |
}% |
| 5897 |
\else% |
| 5898 |
\def\svg@tempb{% |
| 5899 |
The extraction to format `#2' failed\MessageBreak% |
| 5900 |
for `#1.#2'\MessageBreak% |
| 5901 |
Only file types `pdf,ps,eps' are supported for\MessageBreak% |
| 5902 |
key `exportformat'% |
| 5903 |
}% |
| 5904 |
\fi% |
| 5905 |
\PackageWarning{svg-extract}{\svg@tempb}% |
| 5906 |
}% |
| 5907 |
\endgroup% |
| 5908 |
} |
| 5909 |
% \end{macrocode} |
| 5910 |
% \end{macro}^^A \svgx@move |
| 5911 |
% |
| 5912 |
% \iffalse |
| 5913 |
%</package&body&extract> |
| 5914 |
%<*package&standalone&extract> |
| 5915 |
% \fi |
| 5916 |
% |
| 5917 |
% |
| 5918 |
% |
| 5919 |
% |
| 5920 |
% \subsection{Commands for the separate auxiliary \LaTeX-file} |
| 5921 |
% |
| 5922 |
% For the extraction of independent graphics, an auxiliary \LaTeX~file is |
| 5923 |
% needed. Within this file, the following commands are used to include the |
| 5924 |
% desired graphic. |
| 5925 |
% |
| 5926 |
% \begin{macro}{\svgxsetbox} |
| 5927 |
% \changes{v2.02}{2018/09/07}{late execution of \cs{svgxsetpapersize}}^^A |
| 5928 |
% \begin{macro}{\svgx@setbox} |
| 5929 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 5930 |
% \begin{macro}{\if@svgx@standalone} |
| 5931 |
% \changes{v2.02}{2018/09/07}{new}^^A |
| 5932 |
% Within the preamble of the auxiliary \LaTeX~file, the desired graphic is used |
| 5933 |
% to setup a box, which is used both to define the papersize as well as for the |
| 5934 |
% output itself. The macro \cs{svgx@setbox} is executed twice, the first time |
| 5935 |
% in the preamble and the second time at the very end of \cs{AtBeginDocument} |
| 5936 |
% if package \pkg{etoolbox} was loaded. |
| 5937 |
% |
| 5938 |
% The switch \cs{if@svgx@standalone} is defined for enabling classes to |
| 5939 |
% implement a different behaviour for \pkg{svg-extract} in standalone mode. |
| 5940 |
% for example, \TUDScript-classes are using this switch. |
| 5941 |
% \begin{macrocode} |
| 5942 |
\newif\if@svgx@standalone |
| 5943 |
\newcommand*\svgxsetbox[2][]{% |
| 5944 |
\@svgx@standalonetrue% |
| 5945 |
\svgx@setbox{#1}{#2}% |
| 5946 |
\scr@ifundefinedorrelax{AtEndPreamble}{% |
| 5947 |
\let\svg@tempa\@firstofone% |
| 5948 |
}{% |
| 5949 |
\def\svg@tempa{\AtEndPreamble}% |
| 5950 |
}% |
| 5951 |
\svg@tempa{\AtBeginDocument{\svgx@setbox{#1}{#2}}}% |
| 5952 |
} |
| 5953 |
\newcommand*\svgx@setbox[2]{% |
| 5954 |
\sbox\svg@box{\svg@@input[{#1},draft=false]{#2}}% |
| 5955 |
\svgxsetpapersize% |
| 5956 |
} |
| 5957 |
% \end{macrocode} |
| 5958 |
% \end{macro}^^A \if@svgx@standalone |
| 5959 |
% \end{macro}^^A \svgx@setbox |
| 5960 |
% \end{macro}^^A \svgxsetbox |
| 5961 |
% \begin{macro}{\svgxsetpapersize} |
| 5962 |
% \changes{v2.00a}{2017/02/28}{Bug fix for checking stock- and mediasizes}^^A |
| 5963 |
% This macro sets all well known length macros for defining the paper size as |
| 5964 |
% well as the type area to the size of \cs{svg@box}. |
| 5965 |
% \begin{macrocode} |
| 5966 |
\newcommand*\svgxsetpapersize{% |
| 5967 |
\setlength\paperwidth{\the\wd\svg@box}% |
| 5968 |
% \end{macrocode} |
| 5969 |
% Due to the fact, that the lengths for stock- and mediasizes are maybe set to |
| 5970 |
% \cs{relax}, these macros are checked with \cs{scr@ifundefinedorrelax}. |
| 5971 |
% \begin{macrocode} |
| 5972 |
\scr@ifundefinedorrelax{stockwidth}{}{% |
| 5973 |
\setlength\stockwidth{\paperwidth}% |
| 5974 |
}% |
| 5975 |
\scr@ifundefinedorrelax{mediawidth}{}{% |
| 5976 |
\setlength\mediawidth{\paperwidth}% |
| 5977 |
}% |
| 5978 |
\setlength\textwidth{\paperwidth}% |
| 5979 |
\setlength\paperheight{\the\dimexpr\ht\svg@box+\dp\svg@box\relax}% |
| 5980 |
\scr@ifundefinedorrelax{stockheight}{}{% |
| 5981 |
\setlength\stockheight{\paperheight}% |
| 5982 |
}% |
| 5983 |
\scr@ifundefinedorrelax{mediaheight}{}{% |
| 5984 |
\setlength\mediaheight{\paperheight}% |
| 5985 |
}% |
| 5986 |
\setlength\textheight{\paperheight}% |
| 5987 |
% \end{macrocode} |
| 5988 |
% Any other length regarding the layout is set to have no influence at all. |
| 5989 |
% Hence the document has the same size as the graphic. |
| 5990 |
% \begin{macrocode} |
| 5991 |
\hoffset=-1in% |
| 5992 |
\oddsidemargin=\z@% |
| 5993 |
\evensidemargin=\z@% |
| 5994 |
\voffset=-1in% |
| 5995 |
\topmargin=\z@% |
| 5996 |
\headheight=\z@% |
| 5997 |
\headsep=\z@% |
| 5998 |
\topskip=\z@% |
| 5999 |
\footskip=\z@% |
| 6000 |
\marginparsep=\z@% |
| 6001 |
\marginparwidth=\z@% |
| 6002 |
\marginparpush=\z@% |
| 6003 |
} |
| 6004 |
\@onlypreamble\svgxsetpapersize |
| 6005 |
% \end{macrocode} |
| 6006 |
% \end{macro}^^A \svgxsetpapersize |
| 6007 |
% \begin{macro}{\svgxoutputbox} |
| 6008 |
% \begin{macro}{\if@svgx@beamer} |
| 6009 |
% With \cs{svgxoutputbox} the created box is displayed. |
| 6010 |
% \begin{macrocode} |
| 6011 |
\newif\if@svgx@beamer |
| 6012 |
\@ifclassloaded{beamer}{\@svgx@beamertrue}{}% |
| 6013 |
\newcommand*\svgxoutputbox{% |
| 6014 |
\begingroup% |
| 6015 |
\setlength\parindent{\z@}% |
| 6016 |
\setlength\parskip{\z@}% |
| 6017 |
\setlength\parfillskip{\z@}% |
| 6018 |
\if@svgx@beamer% |
| 6019 |
\setbeamertemplate{navigation symbols}{}% |
| 6020 |
\begin{frame}[plain]% |
| 6021 |
\usebox\svg@box% |
| 6022 |
\end{frame}% |
| 6023 |
\else% |
| 6024 |
\usebox\svg@box% |
| 6025 |
\fi% |
| 6026 |
\endgraf% |
| 6027 |
\endgroup% |
| 6028 |
} |
| 6029 |
% \end{macrocode} |
| 6030 |
% \end{macro}^^A \if@svgx@beamer |
| 6031 |
% \end{macro}^^A \svgxoutputbox |
| 6032 |
% |
| 6033 |
% \iffalse |
| 6034 |
%</package&standalone&extract> |
| 6035 |
%<*package&option> |
| 6036 |
% \fi |
| 6037 |
% |
| 6038 |
% |
| 6039 |
% |
| 6040 |
% \section{Processing Options} |
| 6041 |
% |
| 6042 |
% Setting the default options and processing the given ones during when loading |
| 6043 |
% the packages. |
| 6044 |
% \begin{macrocode} |
| 6045 |
%<*main> |
| 6046 |
\FamilyExecuteOptions{SVG}{% |
| 6047 |
inkscape=true,inkscapeversion=auto,inkscapepath=basesubdir,% |
| 6048 |
inkscapelatex=true,inkscapearea=drawing,distort=false,% |
| 6049 |
usexcolor=true,usetransparent=true% |
| 6050 |
} |
| 6051 |
%</main> |
| 6052 |
%<*extract> |
| 6053 |
\FamilyExecuteOptions{SVG}{% |
| 6054 |
extract=true,extractpath=basesubdir,% |
| 6055 |
extractruns=2,extractname=namenumbered,extractdistort=false,% |
| 6056 |
convert=magick,convert=false,% |
| 6057 |
gsdevice={png=png16m},gsdevice={jpeg=jpeg},gsdevice={jpg=jpeg},% |
| 6058 |
gsdevice={tif=tiff48nc},gsdevice={tiff=tiff48nc},% |
| 6059 |
gsdevice={eps=eps2write},gsdevice={ps=ps2write}% |
| 6060 |
} |
| 6061 |
%</extract> |
| 6062 |
\FamilyProcessOptions{SVG} |
| 6063 |
% \end{macrocode} |
| 6064 |
% |
| 6065 |
% \iffalse |
| 6066 |
%</package&option> |
| 6067 |
% \fi |
| 6068 |
% |
| 6069 |
% \Finale |
| 6070 |
% |
| 6071 |
\endinput |