Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

DTX files are based on LaTeX comments, which means that any editor that can highlight LaTeX code will print most of the DTX files - all the documentation - as a comment and thus not highlight the code.

I found that Emacs can handle that problem, however I rather do not want to learn how to use Emacs just because of that. WinEdt should be able to handle the problem as well, but that is not Open Source. TeXworks does not handle it (I am using Window). I read that gedit should be able to do it, but it also only highlights standard LaTeX Code.

In Editors/IDEs for LaTeX documented source (.dtx) files a script for highlighting in TeXworks was introduced, but I have not idea how to tell TeXworks to use that. The settings dialog does not allow to do it.

share|improve this question
    
DTX support has been added to TeXstudio recently: sourceforge.net/p/texstudio/feature-requests/241. However, I haven't tried this myself. It might be that DTX support still is incomplete: sourceforge.net/p/texstudio/bugs/547. –  krlmlr Jan 11 '13 at 11:23
1  
I use it for my development for some time already. Basically because I was involved in the realization of dtx support in texstudio... –  Matthias Pospiech Jan 11 '13 at 14:56
add comment

2 Answers

up vote 13 down vote accepted

I use TeXworks for editing .dtx files: I'll explain how I set it up.

On Windows, the 'vanilla' TeXworks stores its settings in C:\Users\<user>\TeXworks\configuration (Windows 7)/ C:\Documents and Settings\<user>\TeXworks\configuration (Windows XP). There, you will find a file called syntax-patterns.txt, which is best edited using TeXworks itself (the line ending are *nix, so Notepad will mess the formatting up). I have added a section to that file which reads

[LaTeX DTX]

# comments
red        Y    \^\^A.*

# Guards
orange        N    %<(?:[A-Za-z0-9!\|\&]+|.)>
limegreen    N    %<\*(?:[A-Za-z0-9!\|\&]+|.)>
crimson        N    %</(?:[A-Za-z0-9!\|\&]+|.)>

# special characters
darkred        N    \^\^\^\^\^[0-9a-z]{5}
darkred        N    \^\^\^\^[0-9a-z]{4}
darkred        N    \^\^\^[0-9a-z]{3}
darkred        N    \^\^[0-9a-z]{2}
darkred        N    [$#^_{}&]
gray        N    ^%%.*
gray        N    ^%

# Macrocode
green        N    \\(?:begin|end)\{macrocode\}

# LaTeX environments
darkgreen    N    \\(?:begin|end)\s*\{[^}]*\}

# control sequences
blue        N    \\(?:[A-Za-z@:_]+|.)

Adding this, and restarting TeXworks, adds a new option to the Format -> Syntax Coloring menu. When I edit .dtx file, I use these highlighting settings.

If you are using TeXworks installed by TeX Live, the settings are in C:\Users\<user>\.texlive<year>\texmf-config\texworks\configuration (pick your year as appropriate).

For Mac users, the settings live in ~/Library/TeXworks/configuration, while on Linux they are in ~/TeXworks/configuration: other set up details remain the same.

An alternative to TeXworks on Windows is WinEdt. It has a pretty advanced 'DTX mode', available from the community support site. The colour scheme in my settings above is based on those from WinEdt's DTX mode: I used to use WinEdt before switching to TeXworks.

share|improve this answer
add comment

VIM recognizes .dtx files out of the box.¹ It does not treat lines beginning with % and %% as comments and highlights the code correctly. In the same time, ^^A (the comment character inside the \DocInputed part of the .dtx) is recognized as a proper comment character.


¹ What else did you expect from VIM? ;-)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.