diff options
-rw-r--r-- | Master/texmf-dist/doc/latex/import/README | 15 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/import/import.pdf | bin | 251209 -> 243633 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/import/import.tex | 132 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/import/import.sty | 94 |
4 files changed, 146 insertions, 95 deletions
diff --git a/Master/texmf-dist/doc/latex/import/README b/Master/texmf-dist/doc/latex/import/README new file mode 100644 index 00000000000..2a3886a5063 --- /dev/null +++ b/Master/texmf-dist/doc/latex/import/README @@ -0,0 +1,15 @@ +import.sty Version 6.0 22-Jan-2020 +Donald Arseneau (asnd@triumf.ca) Vancouver, Canada. + +This software is in the public domain; free of any restrictions. +All right are waived. No obligations are acknowleged. + +Two new LaTeX commands, "\import {<full-path>} {<file>}" and +"\subimport {<path-extension>} {<file>}" are defined to input +a file from another directory, allowing that file to find its +own inputs (using \input, \includegraphics etc.) in that directory. +Alias command names are "\inputfrom" and "\subinputfrom". + +Also provided are \includefrom and \subincludefrom, which are +based on the \include command, rather than \input. + diff --git a/Master/texmf-dist/doc/latex/import/import.pdf b/Master/texmf-dist/doc/latex/import/import.pdf Binary files differindex f85e8c702f2..5f3f88f7a42 100644 --- a/Master/texmf-dist/doc/latex/import/import.pdf +++ b/Master/texmf-dist/doc/latex/import/import.pdf diff --git a/Master/texmf-dist/doc/latex/import/import.tex b/Master/texmf-dist/doc/latex/import/import.tex index afa323d504a..36ff9a63d83 100644 --- a/Master/texmf-dist/doc/latex/import/import.tex +++ b/Master/texmf-dist/doc/latex/import/import.tex @@ -8,7 +8,7 @@ \usepackage{textcomp} \usepackage{booktabs} \usepackage{microtype} -\usepackage{hyperref} +%\usepackage{hyperref} \newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}} \newcommand*{\pkg}[1]{\textsf{#1}} @@ -22,19 +22,13 @@ \newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle} \newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}} \newcommand*{\oarg}[1]{\texttt{[}\meta{#1}\texttt{]}} -\newcommand*{\BibTeX}{Bib\kern-0.08em\TeX\@\xspace} -\newcommand*{\BigTeX}{Big\kern-0.08em\TeX\@\xspace} +\renewcommand{\^}{\nolinebreak[2]} +%\addtokomafont{title}{\rmfamily} -\pdfstringdefDisableCommands{% - \def\BibTeX{BibTeX\xspace}% - \def\BigTeX{BigTeX\space}% -} - -\addtokomafont{title}{\rmfamily} - -\title{The \pkg{import} package\thanks{This manual corresponds to \pkg{import}~v5.1, dated~23--Mar--2009.}} -\author{Donald Arseneau (\mail{asnd@triumf.ca})} -\date{23--Mar--2009} +\title{The import package} +\author{Donald Arseneau (\texttt{asnd@triumf.ca})} +\date{Version 6.0, \quad 22--Jan--2020} +\setlength{\parskip}{3pt plus 2pt} \begin{document} @@ -43,60 +37,84 @@ This software is in the public domain; free of any restrictions. -Two new \LaTeX\ commands, ``\cmd{\import}\marg{full\_path}\marg{file}''\\ and -``\cmd{\subimport}\-\marg{path\_extension}\marg{file}'' are defined to input a file -from another directory, allowing that file to find its own inputs -(using ``\cmd{\input}'', ``\cmd{\includegraphics}'' etc.)\ in that directory. +\medskip -Alias command names are ``\cmd{\inputfrom}'' and ``\cmd{\subinputfrom}''. +Two new \LaTeX\ commands: +\begin{verse} + \cmd{\import} \marg{full-path} \marg{file}\hspace{8em} and\\[2pt] + \cmd{\subimport} \marg{path-extension} \marg{file} +\end{verse} +are defined to input a file from another directory, allowing that file +to find its own inputs (using \cmd{\input}, \cmd{\includegraphics} +etc.\@) in that directory. -Also provided are ``\cmd{\includefrom}'' and ``\cmd{\subincludefrom}'', which are -based on the ``\cmd{\include}'' command, rather than ``\cmd{\input}''. There are -also ``\texttt{*}'' variants described below. +Alias command names are ``\cmd{\inputfrom}'' and ``\cmd{\subinputfrom}''. +(If \cmd{\import} was defined previously, it will not be redefined.) +Also provided are the similar commands ``\cmd{\includefrom}'' and +``\cmd{\subincludefrom}'', which are based on the \cmd{\include} command, +rather than \cmd{\input}. -For example, if a remote file ``\texttt{/usr5/friend/work/report.tex}'' has contents: +For example, if a remote file \texttt{/user/friend/work/report.tex} has +contents: % \begin{verbatim} -My graph: \includegraphics{picture} -\input{explanation} + My graph: \includegraphics{picture} + \input{explanation} \end{verbatim} % -then you can safely input that file in your own document with the command -``\verb+\import{/usr5/friend/work/}{report}+''; the explanation and picture will -be taken from the ``\texttt{/usr5/friend/work/}'' directory. - -The ``\cmd{\subimport}'' command takes a relative path instead of a full absolute -file path, and it allows imported files to import files themselves, using -their own directory as the root of another ``\meta{path\_extension}''. Do not use -both ``\cmd{\import}'' and ``\cmd{\subimport}'' in the same file. - +then you can input that file to a document with +\verb+\import{/user/friend/+\^\verb+work/}+\^\verb+{report}+ +so that both the explanation and picture will be taken from the +\texttt{/user/friend/\^work/} directory. + +The \meta{full-path} argument for \cmd{\import} can be a full absolute path +or a relative path starting from the main working directory for the document. +The \cmd{\subimport} command facilitates nesting of file imports. It takes a +relative \meta{path-extension} based on the location of the current imported file. For example, if a file is imported (using either command) from directory -``\texttt{abc/}'' and that file contains the command ``\verb+\subimport{lmn/}{xyz}+'' then -file ``\texttt{abc/lmn/xyz.tex}'' is input, and any ``\cmd{\input}'' commands in that file -will read files from directory ``\texttt{abc/lmn/}''. - -Note that the sub-import path is merely appended to the current import -path. Mistakes from this method must be rectified by ``\cmd{\import@path@fix}''. - -Depending on on how your \TeX\ system is configured, if a file with the -same name as the import file exists in the current directory or in the -\texttt{TEXINPUTS} path, that other file will be read in preference to one in the -import directory. So here is the real behavior of the previous example: -Given the sequence ``\verb+\import{abc/}{one}+'', ``\verb+\subimport{lmn/uvw/}{two}+'' (in -file \texttt{one}), ``\verb+\input{three}+'' (in file \texttt{two}), \LaTeX\ first looks for \texttt{three.tex} -in the \texttt{TEXINPUTS} search path; if not found, it tries ``\texttt{abc/lmn/uvw/three}''; -if that doesn't exist, it tries ``\texttt{abc/three}''; if still not found, it tries -the defined ``\cmd{\input@path}'', if there is one. - -To avoid searching the \texttt{TEXINPUTS} path when importing files, use the `star' -versions of the commands: ``\cmd{\import*}'' and ``\cmd{\subimport*}''. - -A hook ``\cmd{\import@path@fix}'' is provided to reformat the import path +\texttt{abc/} and that file contains the command \verb+\subimport{lmn/}{xyz}+ then +file \texttt{abc/lmn/xyz.tex} is input, and any \cmd{\input} commands in that file +will read files from directory \texttt{abc/lmn/}.\footnote{~Note that the sub-import + path is merely appended to the current import path. Syntactical mistakes from this + method may be corrected by \cmd{\import@path@fix}.} + +Depending on on how your \TeX\ system is configured, if a file does not +exist in the specified import directory, it will be looked for in previous +import directories (when nesting \cmd{\subimport} files), then in any +directory listed in the pre-existing \cmd{\input@path}, then in the current +working directory, and finally in the \texttt{TEXINPUTS} path. Therefore, for +\cmd{\import} and for other \cmd{\input} used within an imported file, +a file found on the path of import(s) will be read in preference to others with +the same name located elsewhere. So here is the real behavior of the previous +example: Given the nested sequence: +\begin{verse} +\verb+\import{abc/}{one}+\quad (in main document);\\ +\verb+\subimport{lmn/uvw/}{two}+\quad (in file \texttt{abc/one.tex});\\ +\verb+\input{three}+\quad (in file \texttt{abc/lmn/uvw/two.tex}); +\end{verse} +\LaTeX\ first looks for \texttt{abc/lmn/uvw/three} (or \texttt{abc/lmn/uvw/three.tex});\\ +if not found, it tries \texttt{abc/three} (or \texttt{abc/three.tex});\\ +if still not found, it looks in the \cmd{\input@path}, if there was one defined;\\ +if \cmd{\input@path} was not defined, or if the file was not found on it, +\LaTeX\ then tries to open \texttt{three} in the main document directory;\\ +finally, if still not found, it searches the \texttt{TEXINPUTS} search path. + +Historically, `star' versions of the commands were defined (to avoid searching +the \texttt{TEXINPUTS} path) but now the ``$*$'' is ignored. + + +A command ``\cmd{\import@path@fix}'' is provided to reformat the import path to fit the syntax of a particular operating system. It \emph{could} be -defined to convert unix-style path names to the local format, but -all it does now is remove ``\texttt{][}'' from VMS sub-import directories. +defined to convert unix-style path names to the local format. The default +definition ensures paths end with ``\texttt{/}'' on most systems, but +removes ``\texttt{]\hspace{-2pt}[}'' from within sub-import directory paths +on VMS systems. + +Note that the import package works by manipulating the internal `commands' +\cmd{\input@path} and \cmd{\Ginput@path}, so may behave badly if you +redefine them manually, or via another package, within the document. -Presently, the paths are defined ``locally'' so input files must have +Presently, the paths are defined `locally' so input files must have balanced grouping. \end{document} diff --git a/Master/texmf-dist/tex/latex/import/import.sty b/Master/texmf-dist/tex/latex/import/import.sty index cce424c46ad..338fcc2b1cb 100644 --- a/Master/texmf-dist/tex/latex/import/import.sty +++ b/Master/texmf-dist/tex/latex/import/import.sty @@ -1,63 +1,48 @@ -% import.sty Ver 5.1 23-Mar-2009 Donald Arseneau (asnd@triumf.ca) +% import.sty Ver 6.0 22-Jan-2020 Donald Arseneau (asnd@triumf.ca) % % This software is in the public domain; free of any restrictions. % -% Two new \LaTeX\ commands, "\import {full_path} {file}" and -% "\subimport {path_extension} {file}" are defined to input a file +% Two new \LaTeX\ commands, "\import {<full-path>} {<file>}" and +% "\subimport {<path-extension>} {<file>}" are defined to input a file % from another directory, allowing that file to find its own inputs % (using "\input", "\includegraphics" etc.) in that directory. -% % Alias command names are "\inputfrom" and "\subinputfrom". % % Also provided are "\includefrom" and "\subincludefrom", which are -% based on the "\include" command, rather than "\input". There are -% also "*" variants described below. +% based on the "\include" command, rather than "\input". % -% For example, if a remote file "/usr5/friend/work/report.tex" has contents: +% For example, if a remote file "/user/friend/work/report.tex" has contents: % % My graph: \includegraphics{picture} % \input{explanation} % % then you can safely input that file in your own document with the command -% "\import{/usr5/friend/work/}{report}"; the explanation and picture will -% be taken from the "/usr5/friend/work/" directory. +% "\import{/user/friend/work/}{report}"; the explanation and picture will +% be taken from the "/user/friend/work/" directory. % -% The "\subimport" command takes a relative path instead of a full absolute -% file path, and it allows imported files to import files themselves, using -% their own directory as the root of another "path_extension". Do not use -% both "\import" and "\subimport" in the same file. +% The <full-path> argument for "\import" can be a full absolute path +% or a relative path starting from the main working directory for the document. +% The "\subimport" command facilitates nesting of file imports. It takes a +% relative <path-extension> based on the location of the current file. % % For example, if a file is imported (using either command) from directory % "abc/" and that file contains the command "\subimport{lmn/}{xyz}" then % file "abc/lmn/xyz.tex" is input, and any "\input" commands in that file -% will read files from directory "abc/lmn/". +% will read files from directory "abc/lmn/". % -% Note that the sub-import path is merely appended to the current import -% path. Mistakes from this method must be rectified by "\import@path@fix". -% -% Depending on on how your \TeX\ system is configured, if a file with the -% same name as the import file exists in the current directory or in the -% TEXINPUTS path, that other file will be read in preference to one in the -% import directory. So here is the real behavior of the previous example: -% Given the sequence "\import{abc/}{one}", "\subimport{lmn/uvw/}{two}" (in -% file one), "\input{three}" (in file two), \LaTeX\ first looks for three.tex -% in the TEXINPUTS search path; if not found, it tries "abc/lmn/uvw/three"; -% if that doesn't exist, it tries "abc/three"; if still not found, it tries -% the defined "\input@path", if there is one. -% -% To avoid searching the TEXINPUTS path when importing files, use the `star' -% versions of the commands: "\import*" and "\subimport*". +% Find more documentation in import.tex or import.pdf. % % A hook "\import@path@fix" is provided to reformat the import path % to fit the syntax of a particular operating system. It *could* be -% defined to convert unix-style path names to the local format, but -% all it does now is remove "][" from VMS sub-import directories. +% defined to convert unix-style path names to the local format. The default +% definition ensures paths end with "/" on most systems, but removes +% "][" from within sub-import directory paths on VMS systems. % % Presently, the paths are defined ``locally'' so input files must have % balanced grouping. %====================== END INSTRUCTIONS =========================== -\ProvidesPackage{import}[2009/03/23 \space v 5.1] +\ProvidesPackage{import}[2020/01/22 \space v 6.0] \ProcessOptions \@ifundefined{import}{% @@ -72,8 +57,9 @@ \newcommand{\includefrom}{\global\let\import@path\@empty \@doimport\include} \newcommand{\subincludefrom}{\@doimport\include} +% Consume now-meaningless "*" \def\@doimport#1{\@ifstar - {\@sub@import#1\@iffileonpath}{\@sub@import#1\IfFileExists}} + {\@sub@import#1\im@iffileexists}{\@sub@import#1\im@iffileexists}} % #1 = import command, #2 = switch for *, #3 = import path extension \def\@sub@import#1#2#3{% @@ -94,22 +80,54 @@ % #6 = previous \IfFileExists. #7 = file name. % \def\@import#1#2#3#4#5#6#7{% - \gdef\import@path{#4}% - \protected@edef\input@path{{\import@path@fix{#4}}#2}% - \protected@edef\Ginput@path{{\import@path@fix{#4}}#3}% - #1{#7}% + \protected@xdef\import@path{\import@path@fix{#4}}% + \protected@edef\input@path{{\import@path}#2}% + \protected@edef\Ginput@path{{\import@path}#3}% + \protected@edef\import@path@file{% use full path/file for non-* + \ifx\IfFileExists\@iffileonpath\else \import@path\fi #7}% +% + \expandafter#1\expandafter{\import@path@file}% +% \let\IfFileExists#6% restore after \import* \gdef\import@path{#5}% \def\input@path{#2}\ifx\input@path\@empty \let\input@path\@undefined \fi \def\Ginput@path{#3}\ifx\Ginput@path\@empty \let\Ginput@path\@undefined \fi } +% Our version of \IfFileExists that gives priority to files on \input@path, +% #1 = file name, #2 = action when exists, #3 = action when not exists +\long\def \im@iffileexists#1#2#3{% + \let\@filef@und\@undefined + \ifx\input@path\@undefined\else + \@iffileonpath{#1}{% (also defines \@filef@und) + \def\reserved@a{#2}% + }{}% no action yet for not found + \fi + \ifx\@filef@und\@undefined % not found on \input@path + \openin\@inputcheck#1 % + \ifeof\@inputcheck + \def\reserved@a{#3}% + \else + \closein\@inputcheck + \edef\@filef@und{#1 }% + \def\reserved@a{#2}% + \fi\fi + \reserved@a +} + \let\im@@IfFileExists\IfFileExists \gdef\import@path{} \let\import@path@fix\@firstofone % default -% Check for vms file names and set \import@path@fix appropriately +% Check for "./" currdir, and make \import@path@fix ensure trailing / +\gdef\@gtempa{./} +\ifx\@gtempa\@currdir % *x style paths + \gdef\import@path@fix#1{\@ensure@one@trailing@slash#1////\delimiter}% + \gdef\@ensure@one@trailing@slash#1////#2\delimiter{#1/}% +\fi + +% Check for "[]" currdir (VMS file names) and set \import@path@fix appropriately \gdef\@gtempa{[]} \ifx\@gtempa\@currdir % VMS directory syntax \gdef\import@path@fix#1{\@gobbleVMSbrack#1][>} |