1

I have finished writing my report that contains about 100 pages with a lot of acronyms but i didn't manage them while writing the report.

Now i want to customize the acronym list to be generated because the convention i have done is as follows LNR (latex nomenclature report)

Is there any method to generate the acronym list from that format wich i have used for all acronyms

I don't want to manually do something like this for every acronym:

\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[french]{nomencl}
\makenomenclature
\begin{document}
\nomenclature{$Nmmm$}{le nombre d'éléments}
Supposons que $Nmmm$...
\printnomenclature
\end{document}

thanks

  • Please add a minimal working example (we don't know how you create your list at the first place – I can think of at least four different packages for the task) – clemens Jun 3 '16 at 8:25
  • @clemens i haven't created any list yet but i've found the method described above (updated) but i don't want to use for every acronym .. it will be too much time consuming , thanks – The Beast Jun 3 '16 at 17:45
  • 1
    You can extract the acronyms and their definitions to a separate file using regular expressions (maybe a bit tricky, but not that hard). At that point, it will be more or less trivial to "wrap" them with the appropriate LaTeX commands of your package of choice (e.g. glossaries) and then include that file in your preamble. – Zé Loff Jun 3 '16 at 20:42
  • @ZéLoff thanks but how can i do this , have you any examples ? – The Beast Jun 3 '16 at 20:52
  • 1
    If you're on a UNIX machine (Linux, OS X, BSD...) you can try something like this: grep -Eo '[A-Z]{1,} \([A-Za-z0-9 ]*\)' test.tex > acrlist.txt Note that this has some limitations, the main one being the acronym and its definition have to be on a single line. If you're using Windows you'll probably need something like MinGW to get grep. Also, this isn't meant to be an answer (I don't have time for it, at the moment), just a starting point... – Zé Loff Jun 3 '16 at 20:56
1

You can try something like

grep -Eo '[A-Z]{1,} \([A-Za-z0-9 ]*\)' test.tex > acrlist.txt

Note that this has some limitations, the main one being the acronym and its definition have to be on a single line. Better results can be obtained if using something PCRE-capable.

Now that you have one acronym per line you can "wrap" them in your LaTeX commands of choice, like \nomenclature, from the nomencl package or \newacronym from glossaries:

sed -e 's/\([A-Z]*\) (\(.*\))/\\nomenclature{$\1$}{\2}/' acrlist.txt > acrlist2.tex

You can then insert the acronym file in your main .tex file using \input. And you can also pipe grep and sed together to avoid creating the intermediate file.

Caveats: As noted, the regexes above might not work perfectly with all cases, do check the final result manually. And if you're using Windows you'll probably need something like MinGW to get grep and sed.

  • i do have minGw installed too but after inserting the second line containing sed command it gives me undefined control sequence ... have you tested the solution – The Beast Jun 3 '16 at 22:48
  • Yes, I did (on OS X, but shouldn't make a difference). I assume it is LaTeX giving you the "undefined command sequence" error. Did you check the file created by sed (acrlist2.tex in my example) for errors? – Zé Loff Jun 4 '16 at 13:40
  • the file was not created but i can use the first produced file to do the operation manually – The Beast Jun 4 '16 at 13:59

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.