TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to test in my template if a call of




is valid or will fail because of an unkown style.

However I could no find out in the sty files how these styles are saved and checked.

share|improve this question
up vote 6 down vote accepted

glossaries defines an internal macro named \@glsstyle@<style> for each style <style>.

In case of listings it's a little bit trickier than that. Basically listings defines a macro \lststy@<style>$ for each style. However, \lstdefinestyle has an undocumented optional argument whose purpose is not quite clear to me. \lstdefinestyle[foo]{mystyle} would define a macro \lststy@mystyle$foo. I have never seen a use case for the optional argument before, though, and my (very superficial) tests didn't reveal how to load such a style, anyway.

Maybe something like the following would work for you:



% ignore the optional argument:



\ifdeflststyle{mystyle}{true}{false}     % => true
\ifdeflststyle{myotherstyle}{true}{false}% => false

\ifdefglsstyle{list}{true}{false}   % => true
\ifdefglsstyle{mystyle}{true}{false}% => false
\ifdefglsstyle{mystyle}{true}{false}% => true

share|improve this answer

Your Answer


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.