diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-11 23:53:11 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-11 23:53:11 +0000 |
commit | 9c042e8eec53eb979ec5ae9c871cfc6a45fdff5c (patch) | |
tree | 82d190c2422c5c15623b49b603b8f8a930f0e068 /Master/texmf-dist/source/latex/fancynum/tables.c | |
parent | 66f2494d26e40765a30ea2825506b869088fd07d (diff) |
trunk/Master/texmf-dist/source/latex/fancynum
git-svn-id: svn://tug.org/texlive/trunk@275 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/fancynum/tables.c')
-rw-r--r-- | Master/texmf-dist/source/latex/fancynum/tables.c | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/fancynum/tables.c b/Master/texmf-dist/source/latex/fancynum/tables.c new file mode 100644 index 00000000000..049f092e116 --- /dev/null +++ b/Master/texmf-dist/source/latex/fancynum/tables.c @@ -0,0 +1,118 @@ +/* + tables.c + Produce figures illustrating fancynum + Part of the fancynum package + Copyright (c) J.J.Green 1999. + j.j.green@sheffield.ac.uk + $Id: tables.c,v 1.7 2000/03/15 18:53:47 ap1jjg Exp $ +*/ + + +#include <stdlib.h> +#include <stdio.h> + +/* + static constants +*/ + +static const double sampledouble = 3.141592653589793238462643383; + +static const char table_line[] = + "\\verb|\%%%s| & \\verb|%s| & $\\fnum{%s}$"; +static char texformat[100]; + +/* + static prototypes +*/ + +static void maketable(char*, + char* (*)(char*,const char*), + const char**, + char*, + char*); +static void tabulate(FILE*, + char* (*)(char*,const char*), + const char**, + char*, + char*); +static char* dblsample(char*,const char*); + +int main(void) +{ + const char* dblformats[] = + {"%f","%e","%g","%.9f","%.9e","%.9g",NULL}; + + maketable( + "dbltable.tex", + dblsample, + dblformats, + "Double conversions for $\\pi$", + "dbltable"); + + return EXIT_SUCCESS; +} + +static void maketable( + char* filename, + char* (*linefn)(char*,const char*), + const char** samples, + char* title, + char* label) +{ + FILE* texfile; + + texfile = fopen(filename,"w"); + if (texfile == NULL) return; + + tabulate(texfile,linefn,samples,title,label); + (void)fclose(texfile);; +} + + +static char* dblsample(char* buffer,const char* format) +{ + double a = sampledouble; + + sprintf(texformat,table_line,format,format,format); + sprintf(buffer,(const char*)texformat,a,a); + + return buffer; +} + +static void tabulate( + FILE* texfile, + char* (*linefn)(char*,const char*), + const char** samples, + char* title, + char* label) +{ + char* line; + char buffer[500]; + + fprintf(texfile,"%% automatically generated by tables.c\n"); + fprintf(texfile,"\\begin{table}[tbh]\n"); + fprintf(texfile,"\\begin{center}\n"); + fprintf(texfile,"\\begin{tabular}{|c|c|c|}\n"); + fprintf(texfile,"\\hline\n"); + fprintf(texfile,"Format & Output & Typeset \\\\ \\hline \n"); + while (*samples != NULL) + { + line = linefn(buffer,*samples); + fprintf(texfile,"%s \\\\\n",line); + samples++; + } + fprintf(texfile,"\\hline\n"); + fprintf(texfile,"\\end{tabular}\n"); + fprintf(texfile,"\\end{center}\n"); + fprintf(texfile,"\\caption{%s\\label{%s}}\n",title,label); + fprintf(texfile,"\\end{table}\n"); +} + + + + + + + + + |