James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.42k stars 519 forks source link

Structure panel is not considering files included by custom inclusion macros #4276

Closed marlondecol closed 1 month ago

marlondecol commented 1 month ago

Pre-checks

Environment

The Issue

The structure panel doesn't show anything when my document uses a custom file inclusion macro.

Let's suppose I have the following file:

% methodology.tex

\chapter{Methodology}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam sed venenatis at.

When this file is included as shown below, the structure panel works as expected:

% main.tex

\begin{document}
\input{methodology}
\end{document}

But when it is included using a custom macro, the structure panel is empty:

% main.tex

\NewDocumentCommand\append{}{\cleardoublepage\input}

\begin{document}
\append{methodology}
\end{document}

The thing is that the structure panel only interpret standard file inclusion commands.

Expected Behavior

What I expect is that the structure panel considers files included by custom inclusion macros that implement the standard ones. The extension could, e.g., offer a setting to define the macros to be considered.


I believe this is enough to understand the issue. If not, I can include other information as needed.

James-Yu commented 1 month ago

Unfortunately, the extension does not have the capability of expanding macros. We use regex and static grammar parsing to build the structure of a document.

It is highly unlikely to provide such support, as it requires reimplementing the whole TeX macro expansion logic, which is way to complex.