3

\subimport*{}{} from the package import seems to break listings languages, but only if listings with a language hasn't been used in the root document:

! Package Listings Error: Couldn't load requested language.

My hypothesis is that the starred version of subimport is breaking the path for listings, but somehow it's cached if the listing is used outside the import first.

Is there a solution to this (outside of not using the starred sub import; I'd like to keep using it if possible...)

MWE below.


A/List.tex:

\documentclass{article} 
\usepackage{import}
\usepackage{listings}
\begin{document}

% Uncommenting the problem, oddly enough.
%\begin{lstlisting}[language=Java]
%public static void main(String[] args) {} 
%\end{lstlisting}
\subimport*{Nest/Nest/}{nested}

\end{document}  

A/Nest/Nest/nested.tex:

\begin{lstlisting}[language=Java]
//Returns true
private static bool P() { 
}
\end{lstlisting}
  • It's best to describe the problem as much as possible in your question. Can you specify what you mean by "break"? Do you get an error? – jub0bs Feb 20 '14 at 21:28
  • 1
    @Jubobs Whoops. Editing to add. – Matthew G. Feb 20 '14 at 22:05
4

From the package documentation:

To avoid searching the TEXINPUTS path when importing files, use the ‘star’ versions of the commands: \import* and \subimport*.

This means that pdflatex is not able to look for files other than those in the specified directory. However, settings for listings languages are imported at usage time, so the memory is not cluttered with tens of useless languages.

Solution: use \lstloadlanguages.

\documentclass{article}
\usepackage{import}
\usepackage{listings}

\lstloadlanguages{Java}

\begin{document}

\subimport*{mattnest/mattnest/}{nested}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.