0

I undertook to build a database of my exercises and to store them, i wrote in subfolders. When needed, i called them with xsim package.

At the moment, the classification acts as follows :

enter image description here

And there are 4 difficulty.tex files at the end. I tried to use tags but was unsuccessful.

To make the call easier in a document and to compile only a part of a document, i've build the two files :

  • 5M4_AlgebreFinanciere_CollectDeclaration.tex (in '5M4_AlgebreFinanciere')
  • 5M4_AlgebreFinanciere_CollectExercises.tex (also)

So i can (un)comment the import if i don't need to compile those parts.

In those two files, i want to call the corresponding .tex files with commands to make it more flexible if i've to change names, create a new folder,...

Compilation when i write all the files manually works. But when i use something like : \collectexercises{\ExOption_\ExPart_\ExSubPart_\ExDifficulty1} with command defined to make a good path, everything work except that no exercise are printed. Collection seems to be declared in a good way and exercises are collected (see 'Exercises_Generating_Folder').

My question is : Why exercises are printed with path/names properly wrote and are not, although it compiles successfully, when i use \command ?

Here, i reduce the project to a MWE :

Main.tex :

\documentclass[10pt,a4paper]{book}
\usepackage[verbose,clear-aux]{xsim}
\usepackage{import}

\xsimsetup%
{%
    path = {Exercises_Generating_Folder},   %%Avoid flooding of exercises files
}

%%Declaration exercices
\newcommand{\ExOption}{default}
\newcommand{\ExPart}{default}
\newcommand{\ExSubPart}{default}
\newcommand{\ExDifficulty}{Difficulty}

\import{5M4/AlgebreFinanciere/}{5M4_AlgebreFinanciere_CollectDeclaration.tex}

\begin{document}
\chapter{Algebre Financière}
\import{5M4/AlgebreFinanciere/}{5M4_AlgebreFinanciere_CollectExercises.tex}
    \printcollection{5M4_AlgebreFinanciere}
    \printsolutions*[collection=5M4_AlgebreFinanciere]
\end{document}

5M4/AlgebreFinanciere/5M4_AlgebreFinanciere_CollectDeclaration.tex

 %%Set up the commands to implement correctly this file
 \renewcommand{\ExOption}{5M4}
 \renewcommand{\ExPart}{AlgebreFinanciere}
 \renewcommand{\ExSubPart}{default}

 %%Declare Global Collection for the part
 \DeclareExerciseCollection{\ExOption_\ExPart}

 %%Declare a subpart of the Global Collection
 \renewcommand{\ExSubPart}{InteretsSimples}
 \DeclareExerciseCollection{\ExOption_\ExPart_\ExSubPart}    %%To declare Collection{5M4_AlgebreFinanciere_InteretsSimples}
 \DeclareExerciseCollection{\ExOption_\ExPart_\ExSubPart_\ExDifficulty1} %%And   Collection{5M4_AlgebreFinanciere_InteretsSimples_Difficulty1}

5M4/AlgebreFinanciere/5M4_AlgebreFinanciere_CollectExercises.tex

 %%Set up the commands to implement correctly this file
 \renewcommand{\ExOption}{5M4}
 \renewcommand{\ExPart}{AlgebreFinanciere}
 \renewcommand{\ExSubPart}{default}


 \collectexercises{\ExOption_\ExPart}         %%Open Global collection.
  \renewcommand{\ExSubPart}{InteretsSimples}
  \collectexercises{\ExOption_\ExPart_\ExSubPart}      %%Open Global subpart collection.
   \collectexercises{\ExOption_\ExPart_\ExSubPart_\ExDifficulty1} %%Open Global subpart collection for the corresponding difficulty.
    \subimport*{\ExSubPart/}{\ExOption_\ExPart_\ExSubPart_\ExDifficulty1.tex} %%
                   %%Import the files where corresponding exercises are.
                   %%This file is in the folder 'AlgebreFinanciere/InteretsSimples'
   \collectexercisesstop{\ExOption_\ExPart_\ExSubPart_\ExDifficulty1}
  \collectexercisesstop{\ExOption_\ExPart_\ExSubPart}
 \collectexercisesstop{\ExOption_\ExPart}

5M4/AlgebreFinanciere/InteretsSimples/5M4_AlgebreFinanciere_InteretsSimples_Difficulty1.tex

\begin{exercise}
    Can you print me ?
\end{exercise}
\begin{solution}
    No, you can't !
\end{solution}

Thanks for any help or advice !

EDIT : The problem comes from the command \ExOption and \ExPart in collection name. In the .aux file, there are spaces or brackets (if i add them after using commands) in collection name who do not allowed me to call the collection with the proper name. I'm looking for a solution to make these commands usable.

0

The question is solved in this post.

The problem came from the usage of \ExOption and ExPart who did not expand when i call them in \DeclareExerciseCollection{\ExOption_\ExPart} and in \collectexercises{\ExOption_\ExPart}. Tracked by looking the .aux files where the collection was declared with the following name : {collection:\ExOption _\ExPart }{}

So i wasn't able to call the collection to print it in my document with a wrong name.

Thanks to David Carlisle and Frougon for their help to expand the command.

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.