BaroqueW

BaroqueW

and his sidekick nikkitaa

BaroqueW RSS Feed
 
 
 
 

Latex – Comment faire un glossaire ?

Pour faciliter la lecture de vos rapports techniques, qui foisonnent toujours d’abréviations, il est bon de leur ajouter un glossaire. Ci-dessous, un exemple de document LaTeX avec glossaire. Notez que le chapitre de glossaire n’est pas numéroté (\chapter*) mais apparaît dans la table des matières (\addcontentsline{toc}{chapter}{Glossary}).

\makeglossary
\begin{document}

Ce site est fait en PHP\glossary{[PHP] PHP Hypertext Preprocessor}.

%%%%%%%%%%%
%debut du glossaire%
%%%%%%%%%%%

\chapter*{Glossary}\label{glossary}\addcontentsline{toc}{chapter}{Glossary}

\begin{itemize}
\input{Glossary}
\end{itemize}
\end{document}

Ci-dessous, un script que vous pouvez ajouter à TexShop (MacOSX) pour générer le glossaire proprement. Cliquez sur Macros>Open Macros Editor. Choisissez “New Item” et copiez le script ci-dessous. Associez-lui un raccourci clavier pour régénérer le glossaire rapidement. Pour obtenir le glossaire dans votre pdf, voici la marche à suivre : compilez vos fichiers .tex, compilez votre glossaire et recompilez vos .tex.

–AppleScript direct

set fileName to #NAMEPATH#
set n to (number of characters of contents of fileName)
set fileNamequoted to quoted form of fileName
set baseName to do shell script "basename " & fileNamequoted
set m to (number of characters of contents of baseName)
set dirName to quoted form of (characters 1 thru (n-m-1) of fileName as string)

set shellScript to "cd " & dirName & ";"
set shellScript to shellScript & "./script.sh;"
do shell script shellScript

Notez que le script ci-dessus nécessite la présence d’un fichier “script.sh” dans le dossier contenant vos fichiers .tex. Ce fichier utilise le script PERL “writeglossary.prl” (ci-dessous) pour générer une liste d’items LaTeX à partir des données du glossaire. Il trie ensuite les entrées dans l’ordre alphabétique et élimine les doublons. Pensez à remplacer “Paper.glo” dans le script ci-dessous par ‘Nom de votre fichier’.glo.

#!/bin/tcsh
perl writeglossary.prl Paper.glo > Glossary.tmp
#perl script.pl
perl -e ‘while(<>) {push @lines, $_;}warn "\nSorted $. lines in ascending alphabetical order, ignoring case\n\n";print sort {lc($a) cmp lc($b)}@lines’ Glossary.tmp > Glossary.tex

Et voilà le fichier “writeglossary.prl”:

# Simple perl script for converting glossary data (*.glo) files produced by
# Latex and converting them to a form suitable for including
# as a Glossary.tex file in a report.
#
# To use:   perl writeglossary.prl filename.glo > Glossary.tex
# Then, in your Latex report file, set up a "description" environment using \begin{description}
# and use \input{Glossary} to import the formatted glossary items.
# (See me310report.tex for example.)
#
# Started 2 August 2006 -mrc
# Note: Macs and Linux usually have perl installed by default. On Windows you might need
# to install it or else use Visual Basic or simply use find/replace in MS Word to
# accomplish the same string replacements as done by this perl script.

############
# Main loop: keep reading new lines until end of file.
# Next line always goes into $_ and pattern matching is done
# on $_ by default.
line: while (<>) {

# Replace any instance of "glossaryentry{" with "item " on every line.
# /g is for global matching (as many times as applies)
s/glossaryentry{/item /g;

#Then take what comes before "}" and throw away the rest.
if(/}/){
$_ = $`;
}

#Append a newline and print to the output.
print($_,"\n");

} # end while(<>)

  • Share/Save/Bookmark

Related posts


5 Responses to “Latex – Comment faire un glossaire ?”

  1. 1
    BaroqueW:

    Bonne idée. Merci

  2. 2
    john:

    Thanks so very much for taking your time to create this very useful and informative site. I have learned a lot from your site. Thanks!!

  3. 3
    Timmy:

    Great Site – really useful information!

  4. 4
    Willem:

    Thank for making this valuable information available to the public.s

  5. 5
    Timmy:

    A fantastic site, and brilliant effort. A great piece of work.:

Leave a Reply

Status

  • BaroqueW sorting the first pictures
    2 hours ago
  • BaroqueW holy cow
    4 hours ago
  • BaroqueW ecoute desproges dans les fjords
    2 days ago
  • BaroqueW : it is in fact NOT funny to point people in the wrong direction when they're lost
    2 days ago

Popular posts

My Social Networks

DandyID 43 Things Clipmarks coComment Dailymotion Delicious deviantART Digg Diigo Facebook Flickr Get Satisfaction Guitar Hero HelloTxt Hulu ICQ Imdb Imeem Kiva last.fm Linkedin Netvibes orkut PeoplePond Picasa Plaxo PostCrossing RockBand Scribd Stumbleupon Tagged TripAdvisor Twitpic Twitter Xbox LIVE YouTube

Expand the experience

Blogroll

Internet Map

Meta