LaTeX-Workshop icon indicating copy to clipboard operation
LaTeX-Workshop copied to clipboard

LaTeX outline for dtx files

Open stone-zeng opened this issue 6 years ago • 3 comments

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:

image

stone-zeng avatar Jul 18 '18 11:07 stone-zeng

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.

jlelong avatar Jul 19 '18 07:07 jlelong

I think supporting .dtx is out of the scope of LaTeX Workshop.

tamuratak avatar Aug 22 '19 23:08 tamuratak

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.

jlelong avatar Aug 25 '19 14:08 jlelong

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 😆

James-Yu avatar Feb 12 '23 09:02 James-Yu

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

jlelong avatar Feb 13 '23 21:02 jlelong

f1161d1 implements a basic .dtx outline feature. Now the outline displays sections, floats, and macro/environments. macrocodes 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.

James-Yu avatar Feb 15 '23 06:02 James-Yu

For some strange reason, the outline in the Explorer view is fine but the Structure view in the TeX badge remains empty.

jlelong avatar Feb 16 '23 10:02 jlelong