Thanks to this, automated abbreviation of species and some technical terms became understandable for me as a LaTeX beginner :-) My PhD supervisors (not LaTeX users) however, criticised that I used the abbreviations too often, reducing text comprehension.

I found a Basically: No. answer about a similar math question, but also the resetting options for the glossaries package. The latter however seem to require consciously setting the reset commands, which would not save much time over simply writing the terms out manually.

Therefore, I wonder about a way to globally redefine abbreviation macros to take the context of its use into account. In order for example to spell out a term in a rule-based or context sensitive way, like in every heading, upon every 1st use within a (sub)section, in every figure caption, etc., while continuing to use the abbreviation in normal paragraphs. Is there a package capable of that? If yes, how can it be done? Or if not, do you know of any software that can do it?

  • Context - aware means that TeX must look what is coming up (possible) but rarely possible with looking into past, what has been typeset to far. You could of course parse the input before it is really processed, but I am not sure if this really easy with TeX/LaTeX at all
    – user31729
    Commented Sep 17, 2015 at 12:22
  • I think I understand what you're getting at though it could be clearer. Are you saying you want for example Parus major initally and then P. major for subsequent calls to a macro? That could probably be done with acronym (not as full-featured as glossaries but it's what I've always used and so I can tweak it. What you do need to do though, is define where you want to reset to the full form. You could easily have that happen at every chapter for example.
    – Chris H
    Commented Sep 17, 2015 at 12:24
  • @ChristianHupfer that's true, but I wonder if in this case a history-aware approach would do: If the full version hasn't been given for n pages/paragraphs/sections... then expand, otherwise abbreviate.
    – Chris H
    Commented Sep 17, 2015 at 12:26
  • 1
    @ChrisH: Perhaps it would do, agreed, but this depends on the real document. If you have some ideas, go ahead please!
    – user31729
    Commented Sep 17, 2015 at 12:37
  • 1
    @ChrisH: You can count sections with (my) package assoccnt. It will give you the full number of sections etc. throughout the document, even if the section counters are reset. It does not work for TeX paragraphs (i.e. \par like stuff
    – user31729
    Commented Sep 17, 2015 at 12:43

1 Answer 1


Here's something which might do the trick, though it doesn't implement some of my more advanced ideas. It's based on an old related answer of mine and an even older trick from Marco Daniel (\ifenv).

The code:


     \expandafter\ifx\csname AC@#1\endcsname\AC@used%

\acn is a clone of acronym's \ac but instead of the full form of the name including the short form in brackets, it just prints the long form on first use. New compared to my old answer is a test of whether we're in a figure environment, in which case the long form is always used.

I've also told all acronyms to resest at the start of every section (the last line above). You could easily replace \section with \chapter or \subsection.


\acrodef{ecoli}[\emph{E. coli}]{\emph{Escherichia Coli}}

Here were are going to write about \acn{ecoli}.  We are interested in \acn{ecoli}.

Some more about \acn{ecoli}.  And a few more \acn{ecoli} facts.
    \centering\bfseries{This is a figure}
    \caption{A picture of \acn{ecoli}}

(just paste this immediately after the other block and compile twice) to get: output of above code


You must log in to answer this question.