I'm fuzzy on the details, but the import package should do what you want. Off the top of my head, I think the syntax is
\usepackage{import}
...
\subimport{code/doc/latex/}{refman.tex}
Update: Thanks Willie for pointing out \subimport
which seems to be the better command to use here over \import
.
The commands \import{full_path}{file}
and \subimport{path_extension}{file}
set up input through standard LaTeX
mechanisms (\input
, \include
and
\includegraphics
) to load files
relative to the \import-ed directory.
There are also \includefrom
,
\subincludefrom
, and *
variants of the
commands. The author is Donald
Arseneau.
I don't know about a TeX only solution (I could however imagine that lualatex
could by handy) but what I usually do is the following:
1) use a command like dir /b *.tex > allFiles.txt?
to get a file of all the TeX files. (the /b
suppresses everything but the file name)
2) open up Excel, paste the content of allFiles.txt
and use string concatenation to build the include commands.
For once-only this is the most efficient solution. In cases where I regularly have to update my TeX file I'd write a short Python/Bash/Batch file.
EDIT:
I have found some suitable code to include via lualatex
Lua-calls in one of the answers here and was able to adjust it a little. It uses \write18
as well, so it must be used with --shell-escape
. I am pretty sure that a Lua-only solution is possible, but this is clearly beyond my Lua-knowledge.
%!TEX TS-program = LuaLaTeX
\documentclass[12pt,ngerman]{scrartcl}
\usepackage{luacode}
\begin{document}
Some text before the Lua call.
\begin{luacode}
function scandir(directory)
local i, t, popen = 0, {}, io.popen
for filename in popen('dir "'.. directory .. '" /b d*.tex'):lines() do
i = i + 1
t[i] = filename
tex.print('\\input{includes/' .. filename .. '} from ' .. filename ..'\\clearpage')
end
return t
end
scandir("C:/Users/Uwe/LuaLula/includes/")
\end{luacode}
\end{document}
Best Answer
The snapshot package gives you a list of the external dependencies of a LaTeX document. Use it by saying
before the
\documentclass
command (to have the information written to a.dep
file), or by sayingbefore the
\documentclass
command (to have the information written to the.log
file).