Index: trunk/SophyaPI/PIext/piacmd.cc
===================================================================
--- trunk/SophyaPI/PIext/piacmd.cc	(revision 2308)
+++ trunk/SophyaPI/PIext/piacmd.cc	(revision 2377)
@@ -1879,4 +1879,21 @@
 */
 
+// Fonction qui remplace tout caractere non alphanumerique en Z
+static void check_latex_reflabel(string & prl)
+{
+  for(int k=0; k<prl.length(); k++) 
+    if (! isalnum(prl[k]) )  prl[k] = 'Z';
+}
+// Fonction qui remplace _ en \_
+static string check_latex_underscore(string const & mot)
+{
+  string rs;
+  for(int k=0; k<mot.length(); k++) {
+    if (mot[k] == '_') rs += "\\_";
+    else rs += mot[k];
+  }
+  return rs;
+}
+
 /* --Methode-- */
 void PIACmd::HelptoLaTeX(string const & fname)
@@ -1891,9 +1908,13 @@
 fputs("List of {\\bf piapp} on-line Help groups: \n", fip);
 fputs("\\begin{itemize} \n",fip);
+string prl;
+string mol;
 CmdHGroup::iterator it;
 for(it = cmdhgrp.begin(); it != cmdhgrp.end(); it++) {
   if ((*it).first == "All") continue;
+  prl = (*it).first;  check_latex_reflabel(prl);
+  mol = check_latex_underscore((*it).first);
   fprintf(fip,"\\item {\\bf %s }  (p. \\pageref{%s}) \n", 
-         (*it).first.c_str(), (*it).first.c_str());
+	  mol.c_str(), prl.c_str());
 }
 
@@ -1903,12 +1924,16 @@
 
 CmdExmap::iterator ite;
-fputs("% ----- Liste de toutes les commandes ----- \n",fip);
+fputs("% ----- Liste de toutes les commandes et help item ----- \n",fip);
+fputs("\\vspace{5mm} \n",fip);
+// fputs("\\begin{table}[h!] \n", fip);
 fputs("\\begin{center} \n ", fip);
-fputs("\\rule{2cm}{1mm} List of {\\bf piapp} Help items \\rule{2cm}{1mm} \n", fip);
-fputs("\n \n  \\vspace{5mm} \n",fip);
+fputs("\\rule{2cm}{1mm} List of {\\bf piapp} Help items \\rule{2cm}{1mm} \\\\ \n", fip);
+fputs("\\vspace{3mm} \n",fip);
 fputs("\\begin{tabular}{llllll}  \n", fip);
 int kt = 0;
 for(ite = helpexmap.begin(); ite != helpexmap.end(); ite++) {
-  fprintf(fip,"%s & p. \\pageref{%s} ", (*ite).first.c_str(),  (*ite).first.c_str() );
+  prl = (*ite).first;  check_latex_reflabel(prl);
+  mol = check_latex_underscore((*ite).first);
+  fprintf(fip,"%s & p. \\pageref{%s} ", mol.c_str(),  prl.c_str() );
   kt++;
   if (kt < 3) fputs(" & ", fip);
@@ -1919,36 +1944,62 @@
 fputs("\\end{tabular} \n", fip);
 fputs("\\end{center} \n", fip);
-fputs("\n \n \\newpage  \\vspace{1cm} \n",fip);
-
-fputs("\\begin{center} \n ", fip);
-fputs("\\rule{2cm}{1mm} List of {\\bf piapp} Commands \\rule{2cm}{1mm} \n", fip);
-fputs("\n \n  \\vspace{5mm} \n",fip);
-fputs("\\begin{tabular}{llllll} \n", fip);
-kt = 0;
-for(ite = cmdexmap.begin(); ite != cmdexmap.end(); ite++) {
-  fprintf(fip,"%s & p. \\pageref{%s} ", (*ite).first.c_str(), (*ite).first.c_str() );
-  kt++;
-  if (kt < 3) fputs(" & ", fip);
-  else  { fputs(" \\\\  \n", fip);  kt = 0; }
-  }
-if (kt == 1) fputs("  &  &  &   \\\\  \n", fip);
-else if (kt == 2)  fputs("  &   \\\\  \n", fip);
-fputs("\\end{tabular} \n", fip);
-fputs("\\end{center} \n", fip);
-// fputs("\\newline \n",fip);
-
-fputs("% ----- Liste des commandes dans chaque groupe ----- \n",fip);
-fputs("\\newpage \n",fip);
+//fputs("\\end{table} \n", fip);
+fputs("\\newpage  \n",fip);
+
 int gid;
 for(it = cmdhgrp.begin(); it != cmdhgrp.end(); it++) {
   gid = (*it).second;
   if (gid == 0)  continue;
+  //  fputs("\\begin{table}[h!] \n",fip);
+  fputs("\\vspace{6mm} \n",fip);
+  fputs("\\begin{center} \n ", fip);
+  fprintf(fip, "\\rule{2cm}{1mm} \\makebox[60mm]{{ \\bf %s } help group} \\rule{2cm}{1mm} \\\\ \n", 
+	  (*it).first.c_str());
+  fputs("\\vspace{3mm} \n",fip);
+  fputs("\\begin{tabular}{llllll} \n", fip);
+  kt = 0;
+  for(ite = helpexmap.begin(); ite != helpexmap.end(); ite++) {
+    if ((*ite).second.group != gid)  continue;
+    prl = (*ite).first;  check_latex_reflabel(prl);
+    mol = check_latex_underscore((*ite).first);
+    fprintf(fip,"%s & p. \\pageref{%s} ", mol.c_str(),  prl.c_str() );
+    kt++;
+    if (kt < 3) fputs(" & ", fip);
+    else  { fputs(" \\\\  \n", fip);  kt = 0; }
+  }
+  for(ite = cmdexmap.begin(); ite != cmdexmap.end(); ite++) {
+    if ((*ite).second.group != gid)  continue;
+    prl = (*ite).first;  check_latex_reflabel(prl);
+    mol = check_latex_underscore((*ite).first);
+    fprintf(fip,"%s & p. \\pageref{%s} ", mol.c_str(),  prl.c_str() );
+    kt++;
+    if (kt < 3) fputs(" & ", fip);
+    else  { fputs(" \\\\  \n", fip);  kt = 0; }
+  }
+  if (kt == 1) fputs("  &  &  &   \\\\  \n", fip);
+  else if (kt == 2)  fputs("  &   \\\\  \n", fip);
+  fputs("\\end{tabular} \n", fip);
+  fputs("\\end{center} \n", fip);
+  //  fputs("\\end{table} \n",fip);
+  //  fputs("\\vspace{5mm} \n",fip);
+}
+// fputs("\\newline \n",fip);
+
+fputs("% ----- Liste des commandes dans chaque groupe ----- \n",fip);
+fputs("\\newpage \n",fip);
+
+for(it = cmdhgrp.begin(); it != cmdhgrp.end(); it++) {
+  gid = (*it).second;
+  if (gid == 0)  continue;
+  prl = (*it).first;  check_latex_reflabel(prl);
   fprintf(fip,"\\subsection{%s} \\label{%s} \n", 
-          (*it).first.c_str(), (*it).first.c_str());
+          (*it).first.c_str(), prl.c_str());
   fprintf(fip,"\\noindent \n");
   for(ite = helpexmap.begin(); ite != helpexmap.end(); ite++) {
     if ((*ite).second.group != gid)  continue;
+    prl = (*ite).first;  check_latex_reflabel(prl);
+    mol = check_latex_underscore((*ite).first);
     fprintf(fip,"\\piahelpitem{%s} \\label{%s} \n", 
-            (*ite).first.c_str(), (*ite).first.c_str());
+            mol.c_str(), prl.c_str());
     fputs("\\begin{verbatim} \n",fip);
     fprintf(fip,"%s\n", (*ite).second.us.c_str());
@@ -1957,6 +2008,8 @@
   for(ite = cmdexmap.begin(); ite != cmdexmap.end(); ite++) {
     if ((*ite).second.group != gid)  continue;
+    prl = (*ite).first;  check_latex_reflabel(prl);
+    mol = check_latex_underscore((*ite).first);
     fprintf(fip,"\\piacommand{%s} \\label{%s} \n", 
-            (*ite).first.c_str(), (*ite).first.c_str());
+            mol.c_str(), prl.c_str());
     fputs("\\begin{verbatim} \n",fip);
     fprintf(fip,"%s\n", (*ite).second.us.c_str());
