Portál AbcLinuxu, 9. listopadu 2025 12:25
Nicméně pro tvorbu "slovníků" (krátkých) by se to docela hodilo.
$ cat pokus.tex
\documentclass{article}
\begin{document}
\begin{description}
\item[second]And something
else is here
\item[first]Something is
here
\item[andthird]Last
but
not
least
item
\end{description}
\end{document}
$ cat dsort.pl
#!/usr/bin/perl
while(<>){
if(/\\begin\{description\}/){
print;
$d=1; %d=(); undef $k;
}
if(/\\end\{description\}/){
print "\\item[$_]$d{$_}" for sort keys %d;
$d=0;
}
print and next unless $d;
if(/\\item\s*\[(.*?)\](.*)/){
$k=$1;
$d{$k}="$2\n";
} elsif(defined $k){
$d{$k}.=$_;
}
}
$ perl dsort.pl pokus.tex
\documentclass{article}
\begin{document}
\begin{description}
\item[andthird]Last
but
not
least
item
\item[first]Something is
here
\item[second]And something
else is here
\end{description}
\end{document}
a za par vterin nemas co resit. Co se tyce LaTeXu nikdy jsem neviděl tuto možnost
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.