1

My LaTeX document consists of many .tex files distributed in a hierarchical directory structure. Something like this:

> myBook.tex
> myBook_structure.tex

> part1_Introduction
    |
    |--- Introduction_to_FreeRTOS
    |       |-- someFile.tex
    |       '-- someFile.tex
    |
    '--- How_to_use_FreeRTOS
            |-- someFile.tex
            '-- someFile.tex

> part2_FreeRTOS_examples
    |
    |--- First_example
    |       |-- someFile.tex
    |       '-- someFile.tex
    |
    '--- Second_Example
            |-- someFile.tex
            '-- someFile.tex
...

The myBook_structure.tex file keeps track of the overall project structure. I do this by defining directory paths:

    %% myBook_structure.tex
    %% --------------------
    \def\part1ch1{./part1_Introduction/Introduction_to_FreeRTOS}
    \def\part1ch2{./part1_Introduction/How_to_use_FreeRTOS}
    \def\part2ch1{./part2_FreeRTOS_examples/First_example}
    \def\part2ch2{./part2_FreeRTOS_examples/Second_example}
    ...

Now I can use these directory paths to include specific .tex files:

    %% myBook.tex
    %% -----------

    \input{./myBook_structure}
    ..
    \begin{document}
        ..
        %% Include a file from chapter 1 within part 1:
        \include{\part1ch1/someFile}
        %% Include a file from chapter 2 within part 1:
        \include{\part1ch2/someFile}
        ..
    \end{document}

This is very convenient. Imagine I change the directory name Introduction_to_FreeRTOS to FreeRTOS_intro. All I need to do is change one line in the myBook_structure.tex file:

    %% myBook_structure.tex
    %% --------------------
    \def\part1ch1{./part1_Introduction/FreeRTOS_intro} %% <- this line changed
    \def\part1ch2{./part1_Introduction/How_to_use_FreeRTOS}
    ... all other lines remain the same

It works perfectly. The project compiles without errors and delivers the pdf document as expected. Even in TeXstudio. I can simply click the 'compile' button, and it outputs the expected pdf document.

But there is one issue. TeXstudio gets a bit confused when showing the project tree on the left. TeXstudio doesn't expand the \part1ch1 macros, and doesn't know where to look for the file. The project tree in the left margin of TeXstudio is now completely useless - I can no longer jump from one file to another.

enter image description here

How can I circumvent this problem, such that I can continue to use my favourite LaTeX IDE?

EDIT:

Apparently LaTeX doesn't accept a defined keyword that contains digits. So this is not accepted:

    \def\part1ch1{...}

But this is accepted:

    \def\myFirstChapter{...}  %% <- no digits in name 'myFirstChapter'

This unfortunate fact makes my plan to build a neat document structure even harder. Any help on this issue would be appreciated.

  • 1
    instead of digits, you could substitute letters -- \partAchA etc. that should get you through unless you have more than 26 parts or 26 chapters. – barbara beeton Jun 28 '16 at 13:46
  • That's a good idea :-) – K.Mulier Jun 28 '16 at 13:47

Your Answer

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

Browse other questions tagged or ask your own question.