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:
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 :
How can I use the command \subimport*
, and obtain the good result, as the first image ?