1

I have a LaTeX manuscript prepared using a publisher class file (agutex) where I've used four packages (booktabs, glossaries, siunitx, graphicx). I use glossaries in particular for acronyms. After submission, the editing office has replied that they have problems with all my packages, and that I am not allowed to use any custom commands. Is there any tool to “downgrade” the LaTeX document, such as automatically replacing each occurence of \gls by the appropiate text (acronym with or without expansion), and similarly for siunitx?

It would be a bit painful to do this by hand.

  • 6
    Perhaps you should have asked your publisher or read the author guide (if available) before inserting all the forbidden stuff. – Thorsten Donig Nov 16 '13 at 13:12
  • 1
    It sounds like they have a very old TeX distribution if they don't even have graphicx! – Nicola Talbot Nov 16 '13 at 14:38
  • 2
    this could be done with perl – cmhughes Nov 16 '13 at 15:00
  • What about removing packages the editing office refused and using \newcommand to define specials commands which don't work anymore like \gls ? – ppr Nov 16 '13 at 15:09
  • @ppr not allowed to use any custom commands – cmhughes Nov 16 '13 at 21:16
1

I used this script to rid my manuscript of all \gls and \glspl occurences, and replace them by acronyms using a very simple algorithm. Some editing was still needed afterwards. The script is quick and dirty.

#!/usr/bin/env python3.2

f_in = "manuscript.tex"
f_out = "manuscript_mod.tex"
lines = open(f_in).readlines()
acros = dict([(w[1][:-1], w[3].strip()[:-1]) for w in [line.split('{') for line in
                lines if line.startswith(r"\newacronym")]])
had = dict.fromkeys(acros, False)
with open(f_out, 'w') as fp:
    for line in lines:
        if r"\glsresetall" in line:
            had = dict.fromkeys(acros, False)
        if line.startswith("%"):
            fp.write(line)
            continue
        for m in ("gls", "glspl"):
            pl = ("s" if "pl" in m else "")
            ln = 7 if "pl" in m else 5
            while "\\" + m + "{" in line:
                print("Working on: " + line)
                strt = line.find("\\" + m + "{")
                end = line.find("}", strt)
                acr = line[strt+ln:end]
                if had[acr]:
                    line = line[:strt] + acr + pl + line[end+1:]
                else:
                    line = line[:strt] + acros[acr] + pl + " (" + acr + pl + ")" + line[end+1:]
                    had[acr] = True
        fp.write(line)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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