summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/symbolindex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/symbolindex
Initial commit
Diffstat (limited to 'macros/latex/contrib/symbolindex')
-rw-r--r--macros/latex/contrib/symbolindex/README14
-rw-r--r--macros/latex/contrib/symbolindex/makesym.c411
-rw-r--r--macros/latex/contrib/symbolindex/makesym.h37
-rw-r--r--macros/latex/contrib/symbolindex/symbolindex.sty42
4 files changed, 504 insertions, 0 deletions
diff --git a/macros/latex/contrib/symbolindex/README b/macros/latex/contrib/symbolindex/README
new file mode 100644
index 0000000000..6e7d3ed15c
--- /dev/null
+++ b/macros/latex/contrib/symbolindex/README
@@ -0,0 +1,14 @@
+This extension can be used indeferently to the platform.
+
+It performs a new command
+\addsymbol[group]{symbol}{description}
+and the list of the symbols sorted by groups and symbols with
+\listofsymbols
+
+it needs an additional software which works directly under Dos or must be recompiled with the source code:
+makesym file
+It will generate the pages to integrate at the place of \listofsymbols
+
+For any problem contact me at holzmann.frederic@gmx.net
+
+Frederic Holzmann \ No newline at end of file
diff --git a/macros/latex/contrib/symbolindex/makesym.c b/macros/latex/contrib/symbolindex/makesym.c
new file mode 100644
index 0000000000..e392f4d258
--- /dev/null
+++ b/macros/latex/contrib/symbolindex/makesym.c
@@ -0,0 +1,411 @@
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "makesym.h"
+
+int main(int argc, char *argv[])
+{
+ FILE * pFile = NULL;
+ char* mode;
+ int modus = 0;
+ char * pFilename = NULL;
+ char c;
+ char * line = NULL;
+ char line_temp[MAX_LINE];
+ int j = 0;
+ int lines=0;
+ char * pch;
+ char * group_temp;
+ char * symbol_temp;
+ char * description_temp;
+ char * date_temp;
+
+ group_symbol = NULL;
+
+ // ///////////////////////////////////////////
+ if (argc <= 1)
+ {
+ printf("Please specify a file\n");
+ return -1;
+ }
+ if (argc > 2)
+ {
+ mode = argv[2];
+ if (strcmp(mode, "verbose") == 0)
+ {
+ modus = 1;
+ }
+ else
+ {
+ printf("Modus not defined\n");
+ }
+ }
+
+ // ///////////////////////////////////////////
+ pFilename = malloc((strlen(argv[1]) + 4)*sizeof(char));
+ if (pFilename == NULL)
+ {
+ printf("Problem of memory allocation\n");
+ return -1;
+ }
+ strcpy(pFilename, argv[1]);
+ strcat(pFilename, ".los");
+
+ // ///////////////////////////////////////////
+ pFile = fopen (pFilename,"r");
+ free (pFilename);
+ if (pFile!=NULL)
+ {
+ do
+ {
+ // extraction of the symbols
+ for (lines=0; (c=fgetc(pFile))!= EOF && c!='\n' && c!='\0' && lines<=MAX_LINE;lines++)
+ {
+ line_temp[lines]=c;
+ if (modus == 1) // verbose mode
+ {
+ printf("%c", c);
+ }
+ }
+ line_temp[lines]='\n';
+ if (modus == 1) // verbose mode
+ {
+ printf("\t%i\n", lines);
+ }
+
+ line = malloc (lines*sizeof(char));
+ for (j=0; j<lines; j++)
+ {
+ line[j] = line_temp[j];
+ }
+
+
+ // if line exists
+ if ((lines !=-1) && (lines !=-0))
+ {
+ // analysis of the line
+ if (modus == 1) // verbose mode
+ {
+ printf("%s\n", line);
+ }
+ pch = strtok (line, "/");
+ if (modus == 1) // verbose mode
+ {
+ printf("%s\n", pch);
+ }
+ group_temp = malloc(strlen(pch)*sizeof(char));
+ strcpy(group_temp, pch);
+ pch = strtok (NULL, "/");
+ if (modus == 1) // verbose mode
+ {
+ printf("%s\n", pch);
+ }
+ symbol_temp = malloc(strlen(pch)*sizeof(char));
+ strcpy(symbol_temp, pch);
+ pch = strtok (NULL, "/");
+ if (modus == 1) // verbose mode
+ {
+ printf("%s\n", pch);
+ }
+ description_temp = malloc(strlen(pch)*sizeof(char));
+ strcpy(description_temp, pch);
+ pch = strtok (NULL, "/");
+ if (modus == 1) // verbose mode
+ {
+ printf("%s\n", pch);
+ }
+ date_temp = malloc(strlen(pch)*sizeof(char));
+ strcpy(date_temp, pch);
+ if (modus == 1) // verbose mode
+ {
+ printf("%s: %s - %s , %s\n", group_temp, symbol_temp, description_temp, date_temp);
+ }
+
+ // storing the new symbol
+ // sorting directly done during the extraction
+ symbol_add(&group_symbol, group_temp, symbol_temp, description_temp, date_temp);
+
+ free(group_temp);
+ free(symbol_temp);
+ free(description_temp);
+ free(date_temp);
+ }
+ free (line);
+ line = NULL;
+ }while ((lines !=-1)&(lines !=0));
+
+ fclose (pFile);
+
+ if (modus == 1) // verbose mode
+ {
+ printf("List of symbols get\n");
+ }
+
+
+ // storing the symbols
+ pFilename = malloc((strlen(argv[1]) + 4)*sizeof(char));
+ if (pFilename == NULL)
+ {
+ printf("Problem of memory allocation\n");
+ return -1;
+ }
+ strcpy(pFilename, argv[1]);
+ strcat(pFilename, ".los");
+
+ // ///////////////////////////////////////////
+ pFile = fopen (pFilename,"w");
+ if (pFile!=NULL)
+ {
+ symbol_store (pFile, group_symbol);
+ fclose (pFile);
+ }
+ if (modus == 1) // verbose mode
+ {
+ printf("List of symbols stored into %s\n", pFilename);
+ }
+ free (pFilename);
+ }
+
+ return 0;
+}
+
+
+// ////////////////////////////////////////////
+int get_line (FILE * Fin, char * line)
+{
+ int c, i;
+
+ for (i=0; (c=fgetc(Fin))!= EOF && c!='\n' && i<=MAX_LINE;i++)
+ {
+ line[i]=c;
+ }
+
+ line[i]='\n'; // replace NEW LINE or last by '\0'
+
+ if (c==EOF)
+ {
+ return(-1); // EOF encountered
+ }
+ else
+ {
+ return (i);
+ }
+}
+
+
+// ////////////////////////////////////////////
+void symbol_add(struct st_symbol_group **group_symbol_current, char* group, char* symbol, char* description, char* date)
+{
+ struct st_symbol_group *group_new = NULL;
+ int comparison = 0;
+ int is_voidgroup = 0;
+
+ if (*group_symbol_current == NULL)
+ {
+ // adding a new group
+ group_new = (struct st_symbol_group*) malloc (sizeof(struct st_symbol_group));
+ if (group_new != NULL)
+ {
+ group_new->group_name = malloc(strlen(group)*sizeof(char));
+ strcpy(group_new->group_name, group);
+ group_new->group_list = malloc(sizeof(struct st_symbol_list));
+
+ group_new->group_list->symbol.symbol = malloc(strlen(symbol)*sizeof(char));
+ strcpy(group_new->group_list->symbol.symbol, symbol);
+ group_new->group_list->symbol.description = malloc(strlen(description)*sizeof(char));
+ strcpy(group_new->group_list->symbol.description, description);
+ group_new->group_list->symbol.date = malloc(strlen(date)*sizeof(char));
+ strcpy(group_new->group_list->symbol.date, date);
+
+ group_new->group_list->next = NULL;
+ group_new->next = NULL;
+ *group_symbol_current = group_new;
+ }
+ }
+ else
+ {
+ comparison = strcmp((*group_symbol_current)->group_name, group);
+ is_voidgroup = strcmp((*group_symbol_current)->group_name, "voidgroup");
+
+ if (is_voidgroup == 0)
+ {
+ if (comparison == 0)
+ {
+ // right group -> adding the symbol to the list
+ symbol_add_list (&(*group_symbol_current)->group_list, symbol, description, date);
+ }
+ else
+ {
+ // adding the voidgroup before
+ group_new = (struct st_symbol_group*) malloc (sizeof(struct st_symbol_group));
+ if (group_new != NULL)
+ {
+ group_new->group_name = malloc(strlen(group)*sizeof(char));
+ strcpy(group_new->group_name, group);
+ group_new->group_list = malloc(sizeof(struct st_symbol_list));
+
+ group_new->group_list->symbol.symbol = malloc(strlen(symbol)*sizeof(char));
+ strcpy(group_new->group_list->symbol.symbol, symbol);
+ group_new->group_list->symbol.description = malloc(strlen(description)*sizeof(char));
+ strcpy(group_new->group_list->symbol.description, description);
+ group_new->group_list->symbol.date = malloc(strlen(date)*sizeof(char));
+ strcpy(group_new->group_list->symbol.date, date);
+
+ group_new->group_list->next = NULL;
+ group_new->next = *group_symbol_current;
+ *group_symbol_current = group_new;
+ }
+ }
+ }
+ else
+ {
+ // normal group -> to sort alphabeticaly
+ if (comparison == 0)
+ {
+ // right group -> adding the symbol to the list
+ symbol_add_list (&(*group_symbol_current)->group_list, symbol, description, date);
+ }
+ else
+ {
+ if (comparison > 0)
+ {
+ // the group has to be integrated before
+ group_new = (struct st_symbol_group*) malloc (sizeof(struct st_symbol_group));
+ if (group_new != NULL)
+ {
+ group_new->group_name = malloc(strlen(group)*sizeof(char));
+ strcpy(group_new->group_name, group);
+ group_new->group_list = malloc(sizeof(struct st_symbol_list));
+
+ group_new->group_list->symbol.symbol = malloc(strlen(symbol)*sizeof(char));
+ strcpy(group_new->group_list->symbol.symbol, symbol);
+ group_new->group_list->symbol.description = malloc(strlen(description)*sizeof(char));
+ strcpy(group_new->group_list->symbol.description, description);
+ group_new->group_list->symbol.date = malloc(strlen(date)*sizeof(char));
+ strcpy(group_new->group_list->symbol.date, date);
+
+ group_new->group_list->next = NULL;
+ group_new->next = *group_symbol_current;
+ *group_symbol_current = group_new;
+ }
+ }
+ else
+ {
+ if ((*group_symbol_current)->next != NULL)
+ {
+ symbol_add(&(*group_symbol_current)->next, group, symbol, description, date);
+ }
+ else
+ {
+ // creation of the next
+ group_new = (struct st_symbol_group*) malloc (sizeof(struct st_symbol_group));
+ if (group_new != NULL)
+ {
+ group_new->group_name = malloc(strlen(group)*sizeof(char));
+ strcpy(group_new->group_name, group);
+ group_new->group_list = malloc(sizeof(struct st_symbol_list));
+
+ group_new->group_list->symbol.symbol = malloc(strlen(symbol)*sizeof(char));
+ strcpy(group_new->group_list->symbol.symbol, symbol);
+ group_new->group_list->symbol.description = malloc(strlen(description)*sizeof(char));
+ strcpy(group_new->group_list->symbol.description, description);
+ group_new->group_list->symbol.date = malloc(strlen(date)*sizeof(char));
+ strcpy(group_new->group_list->symbol.date, date);
+
+ group_new->group_list->next = NULL;
+ group_new->next = NULL;
+ (*group_symbol_current)->next = group_new;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
+// ////////////////////////////////////////////
+void symbol_add_list (struct st_symbol_list ** list_current, char* symbol, char* description, char* date)
+{
+ struct st_symbol_list * symbol_new = NULL;
+
+ if ((*list_current)->next != NULL)
+ {
+ // sorting the element
+ if (strcmp((*list_current)->next->symbol.symbol, symbol) < 0)
+ {
+ symbol_add_list (&(*list_current)->next, symbol, description, date);
+ }
+ else
+ {
+ // adding the element before
+ symbol_new = malloc (sizeof(struct st_symbol_list));
+ if (symbol_new != NULL)
+ {
+ symbol_new->symbol.symbol = malloc(strlen(symbol)*sizeof(char));
+ strcpy(symbol_new->symbol.symbol, symbol);
+ symbol_new->symbol.description = malloc(strlen(description)*sizeof(char));
+ strcpy(symbol_new->symbol.description, description);
+ symbol_new->symbol.date = malloc(strlen(date)*sizeof(char));
+ strcpy(symbol_new->symbol.date, date);
+
+ symbol_new->next = (*list_current)->next;
+ (*list_current)->next = symbol_new;
+ }
+ }
+ }
+ else
+ {
+ // last element of the list -> creating a new element
+ symbol_new = malloc (sizeof(struct st_symbol_list));
+
+ if (symbol_new != NULL)
+ {
+ (*list_current)->next = symbol_new;
+
+ symbol_new->symbol.symbol = malloc(strlen(symbol)*sizeof(char));
+ strcpy(symbol_new->symbol.symbol, symbol);
+ symbol_new->symbol.description = malloc(strlen(description)*sizeof(char));
+ strcpy(symbol_new->symbol.description, description);
+ symbol_new->symbol.date = malloc(strlen(date)*sizeof(char));
+ strcpy(symbol_new->symbol.date, date);
+
+ symbol_new->next = NULL;
+ }
+ }
+}
+
+
+
+// ////////////////////////////////////////////
+void symbol_store (FILE* pFile, struct st_symbol_group *group_current)
+{
+ if (group_current != NULL)
+ {
+ if (strncmp(group_current->group_name, "voidgroup", 9)!=0)
+ {
+ // group void must be stored without name !
+ fprintf(pFile, "\\noindent \\hspace*{1em} \\large \\bfseries \\MakeTextUppercase{%s} \\normalsize \\newline\n", group_current->group_name);
+ }
+ symbol_store_list(pFile, group_current->group_list);
+ symbol_store (pFile, group_current->next);
+ }
+ else
+ {
+ fprintf(pFile, "\\newline\n");
+ }
+}
+
+void symbol_store_list(FILE * pFile, struct st_symbol_list *list_current)
+{
+ if (list_current != NULL)
+ {
+ fprintf(pFile, "\\begin{minipage}[t]{3cm} %s \\end{minipage} \\begin{minipage}[t]{4cm} %s, %s \\end{minipage} \\newline\n", list_current->symbol.symbol, list_current->symbol.description, list_current->symbol.date);
+ symbol_store_list(pFile, list_current->next);
+ }
+ else
+ {
+ fprintf(pFile, "\\vspace{1em} \\newline");
+ }
+}
diff --git a/macros/latex/contrib/symbolindex/makesym.h b/macros/latex/contrib/symbolindex/makesym.h
new file mode 100644
index 0000000000..0a84c408f0
--- /dev/null
+++ b/macros/latex/contrib/symbolindex/makesym.h
@@ -0,0 +1,37 @@
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef SYMBOL_LATEX
+ #define SYMBOL_LATEX
+
+#define MAX_LINE 120
+
+struct st_symbol {
+ char* symbol;
+ char* description;
+ char* date;
+ };
+
+struct st_symbol_list {
+ struct st_symbol symbol;
+ struct st_symbol_list *next;
+ };
+
+struct st_symbol_group {
+ char* group_name;
+ struct st_symbol_list* group_list;
+ struct st_symbol_group *next;
+ };
+
+struct st_symbol_group *group_symbol;
+
+#endif
+
+int main(int argc, char *argv[]);
+int get_line (FILE * Fin, char * line);
+void symbol_add (struct st_symbol_group **group_symbol_current, char* group, char* symbol, char* description, char* date);
+void symbol_add_list (struct st_symbol_list ** list_current, char* symbol, char* description, char* date);
+void symbol_store (FILE* pFile, struct st_symbol_group *group_current);
+void symbol_store_list(FILE * pFile, struct st_symbol_list *list_current);
+
diff --git a/macros/latex/contrib/symbolindex/symbolindex.sty b/macros/latex/contrib/symbolindex/symbolindex.sty
new file mode 100644
index 0000000000..cc485be8a6
--- /dev/null
+++ b/macros/latex/contrib/symbolindex/symbolindex.sty
@@ -0,0 +1,42 @@
+% List of Symbols
+% for LaTeX-2e
+% Copyright -- 2005 Frederic Holzmann
+%
+% E-mail holzmann.frederic@gmx.net
+%
+% This style file is free software; you can redistribute it and/or
+% modify it under the terms of the GNU Lesser General Public
+% License as published by the Free Software Foundation; either
+% version 2 of the License, or (at your option) any later version.
+%
+% This style file is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+% Lesser General Public License for more details.
+%
+% You should have received a copy of the GNU Lesser General Public
+% License along with this style file; if not, write to the
+% Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+% Boston, MA 02111-1307, USA.
+%
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{symbolindex}
+\typeout{Creation of a list of symbols}
+\RequirePackage{ifthen}
+%\RequirePackage{minipage}
+\RequirePackage{textcase}
+
+% Setting a symbol
+% \addymbol [group]{symbol}{description}
+\newcommand{\addsymbol}[3][voidgroup]{\addtocontents{los}{#1 / #2 / #3 / \thepage /}}
+
+% Generation of the list of symbols
+% Need a call to the makesym software for the transcription of the los file to a loc file
+\def\losymbolsname{List of Symbols}\def\listofsymbols{
+ \chapter*{\losymbolsname}
+ \@starttoc{los}
+ \newline
+ }
+
+% Generation of a symbol into the list