• Omnia Communia @omniasuntcommunia ·

    I get an error based on the Acronyms.sty file. Is this a file that should be part of a TeX installation?

  • It seems that should be part of "acronym". But when I install that I still get the same error. The path it is looking at seems to be a subfolder of my working dir instead of wherever the latex packages live.

  • hm... should it be acronym.sty instead?

  • the texmf/Acronyms.sty file is probably used by @schrieveslaach as some global file with acronyms. If you swap that for your own filename with acronyms, it works.

    I updated this script to use the acronym definition instead of the label for the short form:

    #!/usr/bin/python3
    
    import os
    from panflute import *
    import re
    
    acronyms = {}
    
    refcounts = {}
    
    def resolveAcronyms(elem, doc):
        if isinstance(elem, Span) and "acronym-label" in elem.attributes:
            label = elem.attributes["acronym-label"]
    
            if label in acronyms:
                # this is the case: "singular" in form and "long" in form:
                acronym, value = acronyms[label]
    
                form = elem.attributes["acronym-form"]
                if label in refcounts and "short" in form:
                    if "singular" in form:
                        value = acronym
                    else:
                        value = acronym + "s"
    
                elif "full" in form or "short" in form:
                    # remember that label has been used
                    if "short" in form:
                        refcounts[label] = True
    
                    if "singular" in form:
                        value = value + " (" + acronym + ")"
                    else:
                        value = value + "s (" + acronym + "s)"
    
                elif "abbrv" in form:
                    if "singular" in form:
                        value = acronym
                    else:
                        value = acronym + "s"
    
                return Span(Str(value))
    
    def loadAcronyms():
        pattern = re.compile(r"\\newacronym(\[.*\])?\{(?P<label>[A-Za-z]+)\}\{(?P<acronym>[A-Za-z]+)\}\{(?P<value>[A-Za-z 0-9\-]+)\}")
    
        d = os.path.dirname(__file__)
        filename = os.path.join(d, 'main.tex')
        with open(filename, 'r', encoding='utf-8') as acronymsFile:
            for line in acronymsFile:
                match = pattern.match(line)
                if match:
                    acronyms[match.group('label')] = (match.group('acronym'), match.group('value'))
    
    def main(doc=None):
        loadAcronyms()
        return run_filter(resolveAcronyms, doc=doc)
    
    
    if __name__ == "__main__":
        main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment