Filter file alphabetically

53 Views Asked by At

I have a file kuerzel.tex. What is the best way to sort them alphabetically by the value in the square brackets [] or the second value inside the {} (e.g. [EU] or Europäische Union)? This should happen best automatically when I also create the latex file. Say at the end I would like to have the following:

\acro{eugh}[EuGH]{Europäischer Gerichtshof}
\acro{eu}[EU]{Europäische Union} 
\acro{gr}[GR]{Griechenland}

main.tex

\documentclass{report}
\usepackage[ngerman]{babel}
\usepackage[demo]{graphicx}
\usepackage[nohyperlinks, printonlyused]{acronym}
\usepackage{hyperref}
\usepackage[ngerman]{cleveref}
\usepackage[parfill]{parskip}
\begin{document}

\begin{acronym}[EuGH]
\input{kuerzel}
\end{acronym}


Der \ac{eugh} ist das oberste rechtsprechende Organ der 
\ac{eu}. Die \ac{eu} ist dabei ein Staatenverbund aus 27 europäischen Ländern. Und \ac{gr} hat eine sehr gute Landwirtschaft, welcher stark gefördert werden sollte. 

\end{document}

kuerzel.tex

\acro{gr}[GR]{Griechenland}
\acro{eu}[EU]{Europäische Union} 
\acro{eugh}[EuGH]{Europäischer Gerichtshof}
1

There are 1 best solutions below

0
samcarter_is_at_topanswers.xyz On

You can use the glossaries package instead:

\documentclass{report}
\usepackage[ngerman]{babel}
\usepackage[demo]{graphicx}
\usepackage[acronym,nonumberlist,nogroupskip]{glossaries}
\makeglossaries
\usepackage{hyperref}
\usepackage[ngerman]{cleveref}
\usepackage[parfill]{parskip}

\begin{filecontents*}[overwrite]{kuerzel.tex}
\newacronym{gr}{GR}{Griechenland}
\newacronym{eu}{EU}{Europäische Union} 
\newacronym{eugh}{EuGH}{Europäischer Gerichtshof}
\end{filecontents*}

\begin{document}

\include{kuerzel}
\printacronyms


Der \gls{eugh} ist das oberste rechtsprechende Organ der 
\gls{eu}. Die \gls{eu} ist dabei ein Staatenverbund aus 27 europäischen Ländern. Und \gls{gr} hat eine sehr gute Landwirtschaft, welcher stark gefördert werden sollte. 


\end{document}

enter image description here