# \importonly for only processing a single import?

I am composing a large document, and instead of using include/input, I use the \subimport* command from the import package. This allows me to take care of relatives paths very easily.

However, the nice thing with \include is that I can use \includeonly to only include certain files, without breaking references. Is there a similar command for \subimport?

## edit

I'm trying to put together some code that would do fix this, but my LaTeX knowledge is really very limited. I wrote some kind of weird pseudocode-like thing, may be of help?

\makeatletter
\AtBeginDocument{%
\let\origsubimport\subimport
\newcommand\subimportonly[1]{\let\somevar=#1}
\renewcommand\subimport[1]{\@ifstar
if #1 == letvar, use origsubimport*;
o/w just include aux?
}}
\makeatother

• \includeonly works fine. You need to use \subincludefrom variante. – touhami Dec 19 '15 at 16:31

Update all instances of \subimport to \subincludefrom, and remove the '.tex' extension from the path.

For example, this use of \subimport:

\begin{document}
\subimport{intro/}{intro.tex}
\subimport{chap1/}{chap1.tex}
\subimport{discussion/}{discussion.tex}
\end{document}


Would become this:

\begin{document}
\subincludefrom{intro/}{intro}
\subincludefrom{chap1/}{chap1}
\subincludefrom{discussion/}{discussion}
\end{document}


After you have compiled at least once, and you now only want the discussion (for example) included, you can add an \includeonly to the preamble, like so:

\includeonly{discussion}
\begin{document}
\subincludefrom{intro/}{intro}
\subincludefrom{chap1/}{chap1}
\subincludefrom{discussion/}{discussion}
\end{document}


And the document will only include discussion.tex. This makes the edit-compile-view loop faster by not including sections you aren't working on, but uses the *.aux files for the intro.tex and chap1.tex includes to prevent any references from breaking.

Thanks to @touhami's comment, this answer to Speed up compilation by (pre-)compiling chapters separately? and this answer to How do we do hierarchical includes with local paths? for helping me join the dots.

As of time of writing, the existing answer does not work on either Debian/TeXLive 2019 (LaTeX2e <2020-02-02> patch level 5), import 6.0 or Windows/MiKTeX 2.9 (LaTeX2e <2019-10-01> patch level 3), import 6.1. Both are fully updated.

Just two days ago, 2020-04-01, version 6.2 was released and is available on CTAN. Using that sty file manually, the issue was not fixed.

Meanwhile, I had to issue (borrowing @Paul-Calcraft 's example)

\includeonly{discussion/discussion}
\begin{document}
\subincludefrom{intro/}{intro}
\subincludefrom{chap1/}{chap1}
\subincludefrom{discussion/}{discussion}
\end{document}


That is, with the full path in includeonly. Otherwise, there is a very unexpected warning (pdf backend): no pages of output. greeting, since all document content is inside of subincludefrom commands.