summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/fancynum
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2006-01-11 23:53:11 +0000
committerKarl Berry <karl@freefriends.org>2006-01-11 23:53:11 +0000
commit9c042e8eec53eb979ec5ae9c871cfc6a45fdff5c (patch)
tree82d190c2422c5c15623b49b603b8f8a930f0e068 /Master/texmf-dist/source/latex/fancynum
parent66f2494d26e40765a30ea2825506b869088fd07d (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')
-rw-r--r--Master/texmf-dist/source/latex/fancynum/CHANGES16
-rw-r--r--Master/texmf-dist/source/latex/fancynum/Makefile71
-rw-r--r--Master/texmf-dist/source/latex/fancynum/fancynum.dtx312
-rw-r--r--Master/texmf-dist/source/latex/fancynum/fancynum.ins23
-rw-r--r--Master/texmf-dist/source/latex/fancynum/tables.c118
5 files changed, 540 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/fancynum/CHANGES b/Master/texmf-dist/source/latex/fancynum/CHANGES
new file mode 100644
index 00000000000..d5c69391a33
--- /dev/null
+++ b/Master/texmf-dist/source/latex/fancynum/CHANGES
@@ -0,0 +1,16 @@
+fancynum changelog
+------------------
+
+0.9.2
+ Handling of exponents rewritten to fix a bug affecting
+ one-digit exponents, and exponents with lots of leading
+ zeros.
+
+0.9.1
+ Some spelling mistakes corrected, licence notes added
+ to the file README and the file CHANGES added.
+
+0.9
+ Initial public release.
+
+$Id: CHANGES,v 1.2 2000/08/08 22:32:52 jjg Exp $ \ No newline at end of file
diff --git a/Master/texmf-dist/source/latex/fancynum/Makefile b/Master/texmf-dist/source/latex/fancynum/Makefile
new file mode 100644
index 00000000000..05e48547acd
--- /dev/null
+++ b/Master/texmf-dist/source/latex/fancynum/Makefile
@@ -0,0 +1,71 @@
+# Makefile for fancynum
+# This is mainly for development purposes
+#
+# Copyright (c) J.J.Green 1999
+# $Id: Makefile,v 1.16 2000/08/08 22:40:17 jjg Exp $
+
+VERSION = 0.9.2
+RUBBISH = *~ *.dvi *.log *.aux tables tables.o \
+ fancynum.ps examples.ps
+DISTNAME = fancynum-$(VERSION)
+
+CC = gcc
+LATEX = latex
+XDVI = xdvi
+DVIPS = dvips -Pcmz
+
+# phoney targets
+
+.PHONEY : clean dist docs test check show
+
+install: fancynum.sty
+ # fancynum.sty is up to date. Now move it to where
+ # TeX can find it. Try "make docs" for documentation
+
+clean:
+ $(RM) $(RUBBISH)
+
+dist:
+ cd .. ; \
+ tar -cvf $(DISTNAME).tar --exclude=fancynum/RCS fancynum ; \
+ gzip $(DISTNAME).tar
+
+docs: examples.ps fancynum.ps
+
+test: show
+
+check: show
+
+show: examples.dvi
+ $(XDVI) examples
+
+# real targets
+
+tables : tables.o
+
+dbltable.tex : tables
+ ./tables
+
+examples.dvi : examples.tex dbltable.tex fancynum.sty
+ $(LATEX) examples
+ $(LATEX) examples
+
+fancynum.sty : fancynum.dtx fancynum.ins
+ $(LATEX) fancynum.ins
+
+fancynum.dvi : fancynum.dtx
+ $(LATEX) fancynum.dtx
+ $(LATEX) fancynum.dtx
+
+# suffix rules
+
+.SUFFIXES: .dvi .ps
+
+.dvi.ps:
+ $(DVIPS) $* -o
+
+
+
+
+
+
diff --git a/Master/texmf-dist/source/latex/fancynum/fancynum.dtx b/Master/texmf-dist/source/latex/fancynum/fancynum.dtx
new file mode 100644
index 00000000000..a049dad5d24
--- /dev/null
+++ b/Master/texmf-dist/source/latex/fancynum/fancynum.dtx
@@ -0,0 +1,312 @@
+%
+% \iffalse
+%
+%% fancynum.dtx Copyright (C) J.J.Green 1999, 2000.
+%% $Id: fancynum.dtx,v 1.8 2000/08/08 22:28:38 jjg Exp $
+%%
+%% This file is part of the fancynum package.
+%%
+%% It may be distributed under the terms of the LaTeX Project Public
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.0 or, at your option, any later version.
+%%
+%<*dtx>
+ \ProvidesFile{fancynum.dtx}
+%</dtx>
+%<package>\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+%<package>\ProvidesPackage{fancynum}
+%<driver> \ProvidesFile{fancynum.sty}
+% \fi
+% \ProvidesFile{fancynum.dtx}
+ [2000/08/08 0.92 Fancynum package]
+%
+% \iffalse
+%<*driver>
+\documentclass{ltxdoc}
+\newenvironment{option}[1]{\expandafter\macro\expandafter{%
+ \csname ds@#1\endcsname}}{\endmacro}
+\begin{document}
+ \DocInput{fancynum.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{0}
+%
+% \GetFileInfo{fancynum.dtx}
+%
+% \title{The \textsf{fancynum} package\thanks{This file
+% has version number \fileversion, last
+% revised \filedate.}}
+% \author{J. J. Green}
+% \date{\filedate}
+% \maketitle%
+%
+% \changes{0.5}{2000/04/01}{Beta release}
+%
+% \def\star{{\ttfamily*}}
+% \makeatletter
+% \def\Describe@Macro#1{\endgroup
+% \setbox0=\lastbox\llap{\PrintDescribeMacro{#1}}}%
+% \makeatother
+% \marginparsep0pt
+%
+% \section{Introduction}
+%
+% The fancynum package is designed to aid the typesetting of numbers,
+% particularly (but not exclusively) the ASCII representation of
+% floating point numbers as written by computers.
+%
+% In the sequel we refer to the glyph used to separate the
+% integer and decimal parts of a decimal number as the
+% \emph{decimal symbol}, and that used to group the
+% digits of the integer and decimal parts as the
+% \emph{group symbol}.
+%
+% The author invites suggestions on improvements to the package.
+% In particular, any information on the typographic conventions
+% for setting numbers in different languages would be most
+% welcome.
+%
+% \section{Usage}
+%
+% The fancynum package is quite standard in its usage. After
+% including the package in the preamble,
+% the macro |\fnum| is available in mathematics mode. A call to
+% |$\fnum{3.141593e+05}$| will be set as $3{\cdot}141{,}593\times10^{5}$,
+% and so on. Further examples can be found in the file |examples.tex|
+% included in the distribution.
+%
+% The operation of the |\fnum| macro can be modified with
+% the commands |\setfnumdsym|, |\setfnumgsym| and |\setfnummsym|,
+% which set the value of the decimal, group and multiplication
+% symbols, respectively.
+%
+%\section{Limitations}
+%
+% The |\fnum| has some limitations on the form of its
+% argument:
+% \begin{itemize}
+% \item A decimal must have at least one digit either
+% side of the decimal symbol;
+% \item The optional exponential symbol must be |e|;
+% \item If the exponent must have at least one digit.
+% \end{itemize}
+% Consequently the strings |.312e20|, |312.e20|
+% and |3.142E20| are not acceptable arguments.
+% I hope to remove these restrictions at some point.
+%
+% \section{Package Options}
+% The package supports a small number of options. The
+% locale-specific options set default values for all of
+% the typographic parameters. The \textbf{english} option
+% uses the centred dot as the decimal symbol and a comma
+% as the group symbol.
+% The \textbf{french} option uses the comma as the decimal
+% symbol and a lower dot as the group symbol. Compare
+% the English $3{\cdot}141{,}593$ against the French $3{,}141.593$.
+% If no local-specific option is specified then English will
+% be taken as the default.
+%
+% The remaining options give specific values over the
+% typographic parameters, and override the locale-specific
+% options.
+%
+% The \textbf{tight} and \textbf{loose} options specify
+% space around the $\times$ in the setting of numbers in
+% exponential form. Compare the loose $2.3\times 10^{3}$ with
+% the tight $2.3{\times}10^{3}$. This option is useful where space
+% is at a premium, or may be preferred for {\ae}sthetic reasons.
+%
+% The \textbf{commas}, \textbf{thinspaces} and \textbf{plain} options
+% specify the group symbol to be used, respectively
+% |{,}|, |\,| and |\relax|.
+%
+% \section{Thanks}
+% I am grateful to Heiko Oberdiek, Norman Gray, Michael Downes
+% and Donald Arseneau for their assistance on |comp.text.tex|,
+% and to Jerzy Kucharczyk for providing a bug report.
+%
+% \section{Implementation}
+%
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+%
+% \subsection{Typographic parameters}
+%
+% The decimal, group and multiplication symbols are stored in the
+% global variables |\fn@decimalsym| etc.
+% The following macros give access to the values used in the package.
+% \begin{macrocode}
+\def\setfnumdsym#1{\gdef\fn@decimalsym{#1}}
+\def\setfnumgsym#1{\gdef\fn@groupsym{#1}}
+\def\setfnummsym#1{\gdef\fn@multsym{#1}}
+% \end{macrocode}
+%
+% \subsection{Package options}
+%
+% The package options are simply calls the macro for the appropriate
+% parameter.
+% \begin{macrocode}
+\DeclareOption{english}{\setfnumdsym{{\cdot}}\setfnumgsym{{,}}}
+\DeclareOption{french}{\setfnumdsym{{,}}\setfnumgsym{{.}}}
+\DeclareOption{tight}{\setfnummsym{{\times}}}
+\DeclareOption{loose}{\setfnummsym{\times}}
+\DeclareOption{commas}{\setfnumgsym{{,}}}
+\DeclareOption{thinspaces}{\setfnumgsym{\,}}
+\DeclareOption{plain}{\setfnumgsym{\relax}}
+% \end{macrocode}
+% We set the default values before processing the options
+% \begin{macrocode}
+\ExecuteOptions{english,loose}
+\ProcessOptions\relax
+% \end{macrocode}
+%
+% \subsection{Utility macros}
+%
+% \begin{macro}{\fn@length}
+% Find the length of a string mod 3 (taken directly
+% from the example on p.~219 of the \TeX{}book). Here
+% though, a call to |\fn@length| assigns the calculated
+% value the (global) variable |\fn@strlen|.
+% \begin{macrocode}
+\newcount\fn@strlen
+\def\fn@length#1{\fn@strlen=0 \fn@getlength#1\end}
+\def\fn@getlength#1{\ifx #1\end \let\next=\relax \else
+ \advance\fn@strlen by1
+ \ifnum\fn@strlen=3 \fn@strlen=0 \fi
+ \let\next=\fn@getlength\fi \next}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Typesetting}
+%
+% \subsubsection{The decimal}
+%
+% \begin{macro}{\fn@fracpunct}
+% Punctuate the fractional part of a decimal. An
+% easy cyclic recursion.
+% \begin{macrocode}
+\def\fn@fracpunct#1{\fn@fpa#1@ }
+\def\fn@fpa#1#2#3 {#1\if #2@ \else \fn@fpb#2#3 \fi}
+\def\fn@fpb#1#2#3 {#1\if #2@ \else \fn@fpc#2#3 \fi}
+\def\fn@fpc#1#2#3 {#1\if #2@ \else \fn@groupsym\fn@fpa#2#3 \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fn@intpunct}
+% Punctuate the integer part of a decimal. This is not as
+% easy as the fractional part since we need to know the length
+% before we start (no doubt there is a direct recursive method
+% to do this, but I'm not clever enough to work it out).
+% \begin{macrocode}
+\def\fn@intpunct#1{\fn@ipa#1 }
+% \end{macrocode}
+% The macro |\fn@ipa| prints the string's initial $\pm$ and passes
+% on the rest of the string to the |\fn@ipb| macro. It might be
+% worthwhile stripping the redundant `+' here, but I am minded not
+% to do this since whether it is present is the choice of the user
+% (unlike the redundancy in the sign of the exponent --- see below).
+% \begin{macrocode}
+\def\fn@ipa#1#2 {%
+ \if +#1 +\fn@ipb#2 \else
+ \if -#1 -\fn@ipb#2 \else
+ \fn@ipb#1#2 \fi \fi}
+% \end{macrocode}
+% The |\fn@ipab| macro finds the length (modulo 3) with |\fn@strlen|
+% and calls the appropriate output macro.
+% \begin{macrocode}
+\def\fn@ipb#1 {\fn@length{#1}
+ \ifcase\fn@strlen
+ \fn@ipc#1 \or
+ \fn@ipd#1 \or
+ \fn@ipe#1 \fi}
+% \end{macrocode}
+% The |\fn@ip[cde]| macro prints the first couple of characters
+% and then calls |\fn@ipf| which calls |\fn@fpa| (see above) to
+% finish the job.
+% \begin{macrocode}
+\def\fn@ipc#1#2#3#4 {#1#2#3\fn@ipf#4@ }
+\def\fn@ipd#1#2 {#1\fn@ipf#2@ }
+\def\fn@ipe#1#2#3 {#1#2\fn@ipf#3@ }
+\def\fn@ipf#1#2 {\if #1@ \else \fn@groupsym\fn@fpa#1#2 \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fn@decimal}
+% Set a proper decimal.
+% The pattern matching trick used here (and for the
+% exponent) is due to a conversation between
+% Heiko Oberdiek and Michael Downs on |comp.text.tex|.
+% See the file |ctt.txt| included in the distribution for details.
+% \begin{macrocode}
+\def\fn@propdecimal#1#2{\fn@intpunct{#1}\fn@decimalsym\fn@fracpunct{#2}}
+\def\fn@impropdecimal#1#2{\fn@intpunct{#1}}
+\def\fn@decimalsplit#1.#2.#3#4#5{#4{#1}{#2}}
+\def\fn@decimal#1{\fn@decimalsplit#1..\fn@propdecimal\fn@impropdecimal\empty}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{The exponent}
+%
+% \begin{macro}{\fn@signedint}
+% Set a signed exponent.
+% The C standard I/O library functions \textit{printf},
+% \textit{fprintf}, etc., as well as many Fortran compilers,
+% write a `+' in the exponent if it is positive.
+% Since this is superfluous, both typographically
+% and mathematically, we remove it if we find it.
+% \begin{macrocode}
+\def\fn@signedint#1#2 {%
+ \if +#1
+ \fn@unsignedint#2\relax
+ \else
+ \if -#1
+ -\fn@unsignedint#2\relax
+ \else
+ \fn@unsignedint#1#2\relax
+ \fi
+ \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\fn@unsignedint}
+% Set an unsigned exponent. Here we remove leading zeros.
+% \begin{macrocode}
+\def\fn@unsignedint#1#2{%
+ \ifx #2\relax \let\next=#1
+ \else
+ \ifx 0#1 \let\next=\fn@unsignedint
+ \else
+ \let\next=#1
+ \fi
+ \fi
+ \next #2}
+% \end{macrocode}
+% \end{macro}
+%
+% \subsubsection{The general number}
+%
+% \begin{macro}{\fnum}
+% The setting of an floating point number.
+% Our processing is dependent on whether the argument contains
+% the letter `e'.
+% \begin{macrocode}
+\def\fn@exp#1#2{\fn@decimal{#1}\fn@multsym10^{\fn@signedint#2 }}
+\def\fn@noexp#1#2{\fn@decimal{#1}}
+\def\fn@realsplit#1e#2e#3#4#5{#4{#1}{#2}}
+\def\fnum#1{\fn@realsplit#1ee\fn@exp\fn@noexp\empty}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+%
+% \Finale
+
+
+
+
+
diff --git a/Master/texmf-dist/source/latex/fancynum/fancynum.ins b/Master/texmf-dist/source/latex/fancynum/fancynum.ins
new file mode 100644
index 00000000000..c9c2600787c
--- /dev/null
+++ b/Master/texmf-dist/source/latex/fancynum/fancynum.ins
@@ -0,0 +1,23 @@
+%%
+%% This file is part of the fancynum package, (c) J.J.Green 2000.
+%% It may be distributed under the terms of the LaTeX Project Public
+%% License, as described in lppl.txt in the base LaTeX distribution.
+%% Either version 1.0 or, at your option, any later version.
+%%
+
+% This file requires docstrip version 2.4 available from
+% ftp.dante.de tex-archive/macros/latex/unpacked/docstrip.tex
+
+\input docstrip
+
+\preamble
+\endpreamble
+
+\keepsilent
+\askforoverwritefalse
+
+% The packages
+
+\generate{\file{fancynum.sty}{\from{fancynum.dtx}{package}}}
+
+\endbatchfile
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");
+}
+
+
+
+
+
+
+
+
+