In a LaTeX package using DocStrip with pretty standard structure one could have the following files:


mypackage.dtx is the main file where the code is and from which the .sty is extracted, according to instructions in mypackage.ins. mypackage-code.tex is just a wrapper around mypackage.dtx:






So that we can generate a separate code documentation as mypackage-code.pdf.

mypackage.tex is the user manual, generating mypackage.pdf.

This is all good and produces desired results on the LaTeX side of things. The problem occurs because of the way AUCTeX names the auto generated style files for them (those stored in ./auto/). AUCTeX uses the basename of the file with .el extension. But in so doing the generated style files for mypackage.dtx and mypackage.tex conflict and override each other (technically mypackage.ins also conflicts, but it is less frequently edited, so less of a problem, but still...). So that whenever I open either of those files I start to notice things are amiss, until I say "Ah!!!", and call C-u C-c C-n to reparse the file. But that's pretty annoying.

So, the question is, is there a way to control on a per-file basis the name of the auto generated style file so that those won't conflict like that? Like a file local variable, or something of the sort?

Failing that, are there any common / known workarounds for this situation?


1 Answer 1


I'm not sure if there is an "one size fits all" solution for your issue. I'd probably write a mypackage.el supporting macros/environments provided by the final product mypackage.sty and save that under the directory in TeX-style-private, and rely on parsed information in ./auto/mypackage.el only for the .dtx file. This approach should give you enough flexibility that when you \usepackage{mypackage}, only the relevant part is loaded, and when you load your .dtx file, both AUCTeX styles are loaded (in theory, at least; I didn't try).

  • Arash, Thank you! But wouldn't the parsing of mypackage.tex still overwrite that of the .dtx? In the meantime, I did some further searching and, given that my main reason not to want to rename the user manual was texdoc and that texdoc also gives a high score to mypackage-doc, I went with that and renamed it.
    – gusbrs
    Commented Apr 26, 2023 at 15:45
  • Btw, the further search tells me this is an "old decision", so you probably answered this many times. But I really fail to understand why AUCTeX does not name the auto generated style files using the whole file name, like mypackage.tex.el, mypackage.dtx.el etc.
    – gusbrs
    Commented Apr 26, 2023 at 15:47
  • @gusbrs - You're welcome. I don't understand why you want to parse mypackage.tex when it is generated from mypackage.tex? Do you edit that file separately? Reg. naming: I think this had something to do with some OS which couldn't handle long file names correctly, but I can't tell for sure. At any rate, I think there is a patch to change this behavior, but noone dared to play with it ;-) Commented Apr 26, 2023 at 18:42
  • Yes, I edit the user manual (the .tex) file separately, the content is really there, not in the .dtx. The .dtx is input whole from mypackage-code.tex to generate the code documentation, separate from the manual. Regarding the origins of the problem and the patch: I see. :) It's that entangled then...
    – gusbrs
    Commented Apr 26, 2023 at 19:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .