LaTeX-Workshop
LaTeX-Workshop copied to clipboard
LaTeX outline for dtx files
Description
The LaTeX outline panel is pretty helpful when writing large files. Please consider to add support for dtx file (DocTeX) as well.
In dtx files, besides the TOC (headers), "Guards" are also important to be listed, as WinEdt does:
This requires some refactoring of the current Outline feature. The main difficulties I can imagine:
- the leading
%
in dtx files is not a comment - everything inside
macrocode
environment must be ignored - guards consist in an open and close statement. Maybe, we could just base the outline on the open statement but it would break nesting guards.
I think supporting .dtx
is out of the scope of LaTeX Workshop.
I implemented syntax highlighting for .dtx
files two years ago. This is what actually motivated me to start contributing to this extension. I do not think this is out of the scope of the extension although this is definitely not a priority. I believe we should keep this extension open and maybe one day someone will contribute a PR or i will do it.
House keeping time! I want to make this request the next feature to implement, yet I have no prior experience with doctex. Can you provide some example dtx
files for me as references @stone-zeng @jlelong ? I have the official dtx documentation, too lengthy to me though 😆
The doctex syntax is far more complicated than the standard tex syntax. You can have a look at https://mirror.ibcp.fr/pub/CTAN/info/dtxtut/dtxtut.pdf for the basics of how all this works. Most latex packages are actually implemented as a .dtx
file, so you can find examples in most packages' sources. See also the long discussion in #457
f1161d1 implements a basic .dtx
outline feature. Now the outline displays sections, floats, and macro/environments. macrocode
s are properly handled.
The major leftover is the support to "guards", which I in fact don't know what they are. I will look into doctex
basics later and see if I can implement that. I do think this issue can be closed as a basic version of the feature request is provided. Improvements to dtx outline can be filed via new issues.
For some strange reason, the outline in the Explorer view is fine but the Structure view in the TeX badge remains empty.