0

I use the package import to import several files for writing a book in the following manner:

I put every chapter in its own folder, where I put a file for course and a file for exercises with solutions, called here ChapterOneExos.tex. The exercises are made using the tcolorbox package, and I put it in the subfolder Exos, lying in each chapter' folder. The file ChapterOneExos.tex contains the exercises of the chapter...

I use a Main file to import all this material, and I write it for only one chapter, which contains for this MWE, only exercises:

I synthetize: in the folder Book, I put the file Main.tex, and the folder ChapterOne, which contains the file ChapterOneExos.tex, and the "subfolder" Exos, which contains the exercises' files.

The file Main.tex:

\documentclass{book}

\usepackage{import}

\usepackage[most]{tcolorbox} 

\NewTColorBox[auto counter,number within=chapter]{exo}{m+O{}}{%
    enhanced,
    breakable,
%%    sharp corners,
    colframe=green!20!black,
    colback=yellow!10!white,
    coltitle=green!40!black,
    fonttitle=\bfseries,
    underlay={\begin{tcbclipinterior}
        \shade[inner color=green!80!yellow,outer color=yellow!10!white]
            (interior.north west) circle (2cm);
        \end{tcbclipinterior}},
    title={Exercise~\thetcbcounter:},
    label={exo:#1},
    segmentation style={double=white,draw=green!20!black,double distance=1pt,solid},
    attach title to upper=\par,
    colback=white,
    after upper={\vspace*{5mm}\par\textcolor{green!40!black}%
            {\bfseries Solution of the exercise \ref{exo:#1}}},
    lowerbox=visible,
    savelowerto=Solutions/Solutions_Chap\thechapter/#1-Sol.tex,
    record={\string\solution{#1}{Solutions/Solutions_Chap\thechapter/#1-Sol.tex}},
    #2
    }

\begin{document}

\setcounter{chapter}{1}
\import{ChapterOne/}{ChapterOneExos}

\end{document}

I put in the folder ChapterOne the folder Exos, where I put the exercises, and the file ChapterOneExos.tex is then as the following:

\section{Exercises of the chapter 1}
\subimport{Exos/}{ExoOne}
\subimport{Exos/}{ExoTwo}

and the two exercises are:

\begin{exo}{labelone}
Exercise one
\tcblower
The solution of exercise one
\end{exo}

\begin{exo}{labeltwo}
Exercise two
\tcblower
The solution of exercise two
\end{exo}

All is good now ! The compilation gives the suited result, as the following:

enter image description here

Now, we can read in the doc of the import package, the following:

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

This can be more useful when we have several files....

but when I use the command \subimport*, the lower part of the exercise doesn't appear !. One can see the result when I use it :

enter image description here

How can I use the command \subimport*, and obtain the good result, as the first image ?

2

Use the latest import.sty, where the * modifier does nothing, and is deprecated. If you are stuck using an old version of import.sty, avoid using \import* unless you have a specific collision with a file name installed in TEXINPUTS, and even then it is better to change your file name.

For background, file searches in LaTeX normally give priority to the current main directory, then the installation, and finally the user-set input path. The \import* variant was created to allow access to personal files where the name collided with installed files, but only by blocking access to installed files. As you may guess, this breaks down when files need to be loaded on demand for loading new fonts and such.

With version 6, import redefines some LaTeX internals to change the search priority (temporarily), eliminating the need for a * variation.

You also didn't say, but did you create directories like Solutions/Solutions_Chap1 as specified in your main file? It looks like a problem.

4
  • Thank you for your answer. I will update the package, and I hope that all will be good now. I haven't said about the " directories like Solutions/Solutions_Chap1" because all is good ! I don't understand your sentence " It looks like a problem.". What's the problem ? Apr 23 '20 at 8:57
  • I have updated the package, and it compiles as expected now. Thanks P.S: You say that "eliminating the need for a * variation"... I still use the starred version or not ? Many thanks Apr 23 '20 at 9:10
  • Don't use \import*, but don't go to the trouble to get rid of it (it is the same as \import). If those directories didn't exist, it would be a problem, leading to missing solutions. Apr 23 '20 at 9:26
  • Ok. Many thanks Apr 23 '20 at 11:43

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.