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.