Debian Codegraph @

texmf-dist/doc/latex/import/import.tex

raw
1 \documentclass[DIV=8, parskip=half, pagesize=auto]{scrartcl}
2
3 \usepackage{fixltx2e}
4 \usepackage{etex}
5 \usepackage{xspace}
6 \usepackage{lmodern}
7 \usepackage[T1]{fontenc}
8 \usepackage{textcomp}
9 \usepackage{microtype}
10 %\usepackage{hyperref}
11
12 %\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}}
13 \newcommand*{\pkg}[1]{\textsf{#1}}
14 \newcommand*{\cls}[1]{\textsf{#1}}
15 \newcommand*{\cs}[1]{\texttt{\textbackslash#1}}
16 \makeatletter
17 \newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}}
18 \makeatother
19 \newcommand*{\env}[1]{\texttt{#1}}
20 \newcommand*{\opt}[1]{\texttt{#1}}
21 \newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle}
22 \newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}}
23 \newcommand*{\oarg}[1]{\texttt{[}\meta{#1}\texttt{]}}
24 \renewcommand{\^}{\nolinebreak[2]}
25 %\addtokomafont{title}{\rmfamily}
26
27 \title{The import package}
28 \author{Donald Arseneau (\texttt{[email protected]})}
29 \date{Version 6.2, \quad 01--Apr--2020}
30 \setlength{\parskip}{5pt plus 2pt minus 1pt}
31
32
33 \begin{document}
34
35 \maketitle
36
37 This software is in the public domain; free of any restrictions.
38
39 \medskip
40
41 Two new \LaTeX\ commands:
42 \begin{verse}
43 \cmd{\import} \marg{full-path} \marg{file}\hspace{8em} and\\[2pt]
44 \cmd{\subimport} \marg{path-extension} \marg{file}
45 \end{verse}
46 are defined to input a file from another directory, allowing that file
47 to find its own inputs (using \cmd{\input}, \cmd{\includegraphics}
48 etc.\@) in that directory.
49
50 Alias command names are ``\cmd{\inputfrom}'' and ``\cmd{\subinputfrom}''.
51 (If \cmd{\import} was defined previously, it will not be redefined.)
52 Also provided are the similar commands ``\cmd{\includefrom}'' and
53 ``\cmd{\subincludefrom}'', which are based on the \cmd{\include} command,
54 rather than \cmd{\input}.
55
56 For example, if a remote file \texttt{/user/friend/work/report.tex} has
57 contents:
58 %
59 \begin{verbatim}
60 My graph: \includegraphics{picture}
61 \input{explanation}
62 \end{verbatim}
63 %
64 then you can input that file to a document with
65 \verb+\import{/user/friend/+\^\verb+work/}+\^\verb+{report}+
66 so that both the explanation and picture will be taken from the
67 \texttt{/user/friend/\^work/} directory.
68
69 The \meta{full-path} argument for \cmd{\import} can be a full absolute path
70 or a relative path starting from the main working directory for the document.
71 The \cmd{\subimport} command facilitates nesting of file imports. It takes a
72 relative \meta{path-extension} based on the location of the current imported file.
73 For example, if a file is imported (using either command) from directory
74 \texttt{abc/} and that file contains the command \verb+\subimport{lmn/}{xyz}+ then
75 file \texttt{abc/lmn/xyz.tex} is input, and any \cmd{\input} commands in that file
76 will read files from directory \texttt{abc/lmn/}.\footnote{~Note that the sub-import
77 path is merely appended to the current import path. Syntactical mistakes from this
78 method may be corrected by \cmd{\import@path@fix}.}
79
80 Depending on on how your \TeX\ system is configured, if a file does not
81 exist in the specified import directory, it will be looked for in previous
82 import directories (when nesting \cmd{\subimport} files), then in any
83 directory listed in the pre-existing \cmd{\input@path}, then in the current
84 working directory, and finally in the \texttt{TEXINPUTS} path. Therefore, for
85 \cmd{\import} and for other \cmd{\input} used within an imported file,
86 a file found on the path of import(s) will be read in preference to others with
87 the same name located elsewhere. So here is the real behavior of the previous
88 example: Given the nested sequence:
89 \begin{verse}
90 \verb+\import{abc/}{one}+\quad (in main document);\\
91 \verb+\subimport{lmn/uvw/}{two}+\quad (in file \texttt{abc/one.tex});\\
92 \verb+\input{three}+\quad (in file \texttt{abc/lmn/uvw/two.tex});
93 \end{verse}
94 \LaTeX\ first looks for \texttt{abc/lmn/uvw/three} (or \texttt{abc/lmn/uvw/three.tex});\\
95 if not found, it tries \texttt{abc/three} (or \texttt{abc/three.tex});\\
96 if still not found, it looks in the \cmd{\input@path}, if there was one defined;\\
97 if \cmd{\input@path} was not defined, or if the file was not found on it,
98 \LaTeX\ then tries to open \texttt{three} in the main document directory;\\
99 finally, if still not found, it searches the \texttt{TEXINPUTS} search path.
100
101 Historically, `star' versions of the commands were defined (to avoid searching
102 the \texttt{TEXINPUTS} path) but now the ``$*$'' is ignored.
103
104
105 A command ``\cmd{\import@path@fix}'' is provided to reformat the import path
106 to fit the syntax of a particular operating system. It \emph{could} be
107 defined to convert unix-style path names to the local format. The default
108 definition ensures paths end with a single ``\texttt{/}'' on most systems
109 (unless the path is empty), but on VMS systems it removes
110 ``\texttt{]\hspace{-2pt}[}'' from within combined paths.
111
112 Note that the import package works by manipulating the internal `commands'
113 \cmd{\input@path} and \cmd{\Ginput@path}, so may behave badly if you
114 redefine them manually, or via another package, within the document.
115
116 Presently, the paths are defined `locally' (not globally) so input files must
117 have balanced grouping.
118
119 \end{document}