3

It's clear that AUCTeX has some way of determining the documentclass, since some functions behave differently depending on which documentclass is selected. For example, LaTeX-insert-item behaves differently when the documentclass is beamer.

I'm writing some custom code that needs to test what the documentclass is. Obviously, I could roll my own code to do this, but I'd prefer to use the same functionality as AUCTeX. Is there a function or variable in AUCTeX that contains this information? I looked, but did not find anything.

Thanks!

0

2 Answers 2

6

AUCTeX doesn't really know the class used in a document, all the packages and class loaded are listed in the variable TeX-active-styles. The only problem with it is that it mixes packages and classes, but this isn't usually a big deal since packages tend not to have the same name of a class.

You can search for the wanted package/class with member:

(if (member "beamer" TeX-active-styles)
    ;; true...
  ;; false...
  )

In addition, starting from AUCTeX 11.88 there is also the possibility to check for the options passed to a specific package or class (and here packages and classes are separated) with functions LaTeX-provided-class-options-member and LaTeX-provided-package-options-member, but if there are no options passed to a package/class these functions are useless.

Before version 11.88, all the options were listed in TeX-active-styles too, making it impossible to distinguish between options and packages/classes.


Actually, the different behavior you describe for \item is obtained by adding the ("itemize" . LaTeX-item-beamer) entry to LaTeX-item-list in style/beamer.el, so TeX-active-styles is not used at all.

0
2

You can check TeX-style-hook-list:

(if (member '("beamer") TeX-style-hook-list)
    (message "beamer is used")
  (message "beamer is not used") )

Edit

My solution is based on expecting aux file auctex creates for each tex file you visit. When I wrote this solution emacs parsed that file and it worked. Now when I open the same tex file emacs doesn't seem to read this file anymore. So one has to force emacs to read it:

(load (concat (file-name-directory buffer-file-name)
              TeX-auto-local
              "/"
              (file-name-sans-extension (file-name-nondirectory  buffer-file-name))
              ".el") )
(if (member '("beamer") TeX-style-hook-list)
    (message "beamer is used")
  (message "beamer is not used") )

then it works.

1
  • The whole load can be reduced to (TeX-normal-mode), but querying TeX-style-hook-list with member doesn't make sense since it's an alist, assoc is more useful. Anyway, what AUCTeX really does internally is looking at TeX-active-styles, not TeX-style-hook-list.
    – giordano
    Commented May 20, 2015 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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