From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/fancynum/CHANGES | 16 ++ macros/latex/contrib/fancynum/Makefile | 71 +++++++ macros/latex/contrib/fancynum/README | 39 ++++ macros/latex/contrib/fancynum/aue.txt | 182 +++++++++++++++++ macros/latex/contrib/fancynum/ctt.txt | 238 ++++++++++++++++++++++ macros/latex/contrib/fancynum/dbltable.tex | 17 ++ macros/latex/contrib/fancynum/examples.tex | 58 ++++++ macros/latex/contrib/fancynum/fancynum.dtx | 312 +++++++++++++++++++++++++++++ macros/latex/contrib/fancynum/fancynum.ins | 23 +++ macros/latex/contrib/fancynum/fancynum.pdf | Bin 0 -> 75003 bytes macros/latex/contrib/fancynum/tables.c | 118 +++++++++++ 11 files changed, 1074 insertions(+) create mode 100644 macros/latex/contrib/fancynum/CHANGES create mode 100644 macros/latex/contrib/fancynum/Makefile create mode 100644 macros/latex/contrib/fancynum/README create mode 100644 macros/latex/contrib/fancynum/aue.txt create mode 100644 macros/latex/contrib/fancynum/ctt.txt create mode 100644 macros/latex/contrib/fancynum/dbltable.tex create mode 100644 macros/latex/contrib/fancynum/examples.tex create mode 100644 macros/latex/contrib/fancynum/fancynum.dtx create mode 100644 macros/latex/contrib/fancynum/fancynum.ins create mode 100644 macros/latex/contrib/fancynum/fancynum.pdf create mode 100644 macros/latex/contrib/fancynum/tables.c (limited to 'macros/latex/contrib/fancynum') diff --git a/macros/latex/contrib/fancynum/CHANGES b/macros/latex/contrib/fancynum/CHANGES new file mode 100644 index 0000000000..d5c69391a3 --- /dev/null +++ b/macros/latex/contrib/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/macros/latex/contrib/fancynum/Makefile b/macros/latex/contrib/fancynum/Makefile new file mode 100644 index 0000000000..05e48547ac --- /dev/null +++ b/macros/latex/contrib/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/macros/latex/contrib/fancynum/README b/macros/latex/contrib/fancynum/README new file mode 100644 index 0000000000..aec23bb0e1 --- /dev/null +++ b/macros/latex/contrib/fancynum/README @@ -0,0 +1,39 @@ +README for the fancynum package +------------------------------- + +Fancynum is a LaTeX package for typestting numbers, in particular +those numbers written by computers. + +To install the package +* LaTeX the file fancynum.ins +* move fancynum.sty to somewhere where LaTeX can find it + +For documentation, LaTeX the file fancynum.dtx. + +An example file, examples.tex, requires the file dbltable.tex +which is produced by the "table" program. If you have the gcc +C compiler and "make" then + + make examples.dvi + +should do the work for you. + +All files in the package are released under the 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. + +The most recent version of the package will normally be +available on CTAN, or at the author's homepage + + www.arbs.demon.co.uk + +Bugs reports and suggestions can be sent to + + J. J. Green, + Dept Applied Mathematics, + University of Sheffield, UK. + j.j.green@shef.ac.uk + +$Id: README,v 1.3 2000/03/20 14:30:43 ap1jjg Exp $ + diff --git a/macros/latex/contrib/fancynum/aue.txt b/macros/latex/contrib/fancynum/aue.txt new file mode 100644 index 0000000000..58d9b75b2e --- /dev/null +++ b/macros/latex/contrib/fancynum/aue.txt @@ -0,0 +1,182 @@ +aue.txt +------- + +$Id: aue.txt,v 1.1 2000/03/15 18:29:52 ap1jjg Exp $ + +Some correspondance on alt.usage.english. I am curious as to +what you should call the decimal point in a number qua symbol. +The correspondance was inconclusive, and I decided to use +"decimal symbol" and "group symbol" after all. + +--------------------------------------------------------------- + +Punctuation of numbers + +Hello all + +I need to refer to the punctation used in numbers, eg., + + 3.141,592,653 + +in a language-independant fashion. Specifically to +* the "decimal separator" ("." or centered dot in English, "," in French) +* the "digit-triple separator" ("," in English, "." in French) + +Would anyone have any suggestions or references? + +Thanks + +-j +-- +J.J.Green, Dept. Applied Math. University of Sheffield, UK +http://www.arbs.demon.co.uk + +From: "Frank Peelo" +Subject: Re: Punctuation of numbers +Newsgroups: alt.usage.english +Date: Tue, 14 Mar 2000 14:19:26 -0000 +Xref: news.shef.ac.uk alt.usage.english:415923 + + +john green wrote in message +news:s8xpusxbud1.fsf@gold.cics.shef.ac.uk... +> Hello all +> +> I need to refer to the punctation used in numbers, eg., +> +> 3.141,592,653 +> +> in a language-independant fashion. Specifically to +> * the "decimal separator" ("." or centered dot in English, "," in French) +> * the "digit-triple separator" ("," in English, "." in French) + +Do all languages group digits in threes? Windows, at least, allows you to +specify the number of digits in a group, which suggests that some regions +use different groupings. +FP + + +From: brahms@mindspring.com (Stan Brown) +Subject: Re: Punctuation of numbers +Newsgroups: alt.usage.english +Date: Tue, 14 Mar 2000 15:46:36 -0500 +Organization: Oak Road Systems +Xref: news.shef.ac.uk alt.usage.english:416044 + +Said ap1jjg@gold.cics.shef.ac.uk (john green) in +alt.usage.english: +>Hello all +> +>I need to refer to the punctation used in numbers, eg., +> +> 3.141,592,653 +> +>in a language-independant fashion. Specifically to +>* the "decimal separator" ("." or centered dot in English, "," in French) +>* the "digit-triple separator" ("," in English, "." in French) + +First, I don't know of any widespread style that puts commas +*after* the decimal point. + +Second, in 234,123.33 the comma is a "thousands separator", in my +vocabulary anyway. ISO Handbook 1, /Units of Measurement/, calls +the separator between the whole and fractional parts a "decimal +sign". Microsloth Windows calls them "digit grouping symbol" and +"decimal symbol". + +The preferred decimal sign is the comma, and the preferred +thousands separator is a thin space. The American way is a period +and a comma, respectively. + +-- +Stan Brown, Oak Road Systems, Cleveland, Ohio, USA + http://www.mindspring.com/~brahms/ +alt.usage.English intro and FAQs: http://go.to/aue +WWWebster online dictionary: http://www.m-w.com/mw/netdict.htm +more FAQs: http://www.mindspring.com/~brahms/faqget.htm + +From: "Bruce McIntyre" +Subject: Re: Punctuation of numbers +Newsgroups: alt.usage.english +Date: Wed, 15 Mar 2000 02:20:53 GMT +Organization: @Home Network Canada +Xref: news.shef.ac.uk alt.usage.english:416159 + + +"Stan Brown" wrote in message +news:MPG.13386f363c85ff8298adbe@news.mindspring.com... +| Said ap1jjg@gold.cics.shef.ac.uk (john green) in +| alt.usage.english: +| +| Second, in 234,123.33 the comma is a "thousands separator", in +my +| vocabulary anyway. ISO Handbook 1, /Units of Measurement/, calls +| the separator between the whole and fractional parts a "decimal +| sign". Microsloth Windows calls them "digit grouping symbol" and +| "decimal symbol". +| +| The preferred decimal sign is the comma, and the preferred +| thousands separator is a thin space. The American way is a +period +| and a comma, respectively. +| + +I like the thin space as a thousands separator where possible. In +newsgroups, which most of us read in monospaced text (and if you +don't you probably should), I think the comma is a reasonable +second choice. My sense of logic says that if the comma is going +to be sometimes used as a thousands separator, it should never be +used as a decimal symbol, as is commonly done in Europe (and +perhaps elsewhere). + +Probably the reason Windows calls it a digit grouping symbol is +that sometimes long decimals are separated, as in "1 Plekka = +0.000 276 4 Euros." (Don't ask me what a Plekka is; I made it +up.) It's easier to see from this that 27,640 Plekka make 1 Euro. +I know, it's easier to write "27,640 Plekka = 1 Euro" but not if +it's part of a list... + +I agree that commas/periods should never be used as decimal +separators. + + +-- +.-------------.----------------------------------------. +| McBruce | Note new email: mcbruce1@home.com | +| ICQ 6797517 | Now surfing UseNet via cable modem! | +}-------------^----------------------------------------{ +| Bruce McIntyre, 6636 Dow Ave., #203 | +| 604/438-9735 Burnaby BC, Canada V5H 3C9 | +`------------------------------------------------------' + + +Date: Tue, 14 Mar 2000 18:04:35 +0100 (MET) +From: Arndt Jonasson +To: ap1jjg@gold.shef.ac.uk + +In article you write: +>Hello all +> +>I need to refer to the punctation used in numbers, eg., +> +> 3.141,592,653 +> +>in a language-independant fashion. Specifically to +>* the "decimal separator" ("." or centered dot in English, "," in French) +>* the "digit-triple separator" ("," in English, "." in French) +> +>Would anyone have any suggestions or references? + +I don't know good names for them, but note that a blank is sometimes +used as a "digit-triple separator", and that in Japanese, they separate +digit-quadruples instead. Maybe "digit-group separator" is a better +term. + +-- +Arndt Jonasson Ericsson Utvecklings AB +arndt@erix.ericsson.se ÄT2/UAB/F/P ++46 8 719 75 87 126 25 Stockholm + + + + diff --git a/macros/latex/contrib/fancynum/ctt.txt b/macros/latex/contrib/fancynum/ctt.txt new file mode 100644 index 0000000000..295e6907c7 --- /dev/null +++ b/macros/latex/contrib/fancynum/ctt.txt @@ -0,0 +1,238 @@ +Some anwsers from comp.text.tex (Nov 99) +======================================== + +$Id: ctt.txt,v 1.3 2000/03/15 18:31:04 ap1jjg Exp $ + +From: oberdiek@ruf.uni-freiburg.de (Heiko Oberdiek) +Subject: Re: TeX Macros +Newsgroups: comp.text.tex +Date: Wed, 03 Nov 1999 12:44:39 GMT +Organization: Rechenzentrum der Universitaet Freiburg, Germany + +john green wrote: + +>The macro \split should take one argument which +>may or may not contain an "e". If the argument +>contains an e, say 123e45, then \split should expand +>to \a{123}{45}, and if not, say 12345, then \split +>should expand to \b{12345}. +> +>You can probably guess that I want to use TeX to format +>floating point numbers. This problem arises since the +>C call +> +> printf("%g",x) +> +>will write x in exponetial format only for x of large or +>small modulus. + +%%% cut %%% test.tex %%% cut %%% +\def\floatsplit#1{\dofloatsplit#1e\END} +\def\dofloatsplit#1e#2\END{% + \ifx\\#2\\% + \ReturnAfterElseFi{% + \b{#1}% + }% + \else + \ReturnAfterFi{% + \RemoveE{#1}#2\END + }% + \fi +} +\def\RemoveE#1#2e\END{\a{#1}{#2}} +\long\def\ReturnAfterFi#1\fi{\fi#1} +\long\def\ReturnAfterElseFi#1\else#2\fi{\fi#1} + +\def\a#1#2{$#1\cdot10^{#2}$} +\def\b#1{$#1$} +[\floatsplit{123e456}][\floatsplit{1}] +\bye +%%% cut %%% test.tex %%% cut %%% + +Yours sincerely + Heiko + +========================================================= + +From: Norman Gray +Subject: Re: TeX Macros +Newsgroups: comp.text.tex +Date: 3 Nov 1999 12:01:02 -0000 +Organization: University of Glasgow + +Greetings, + +john green writes: + +>The macro \split should take one argument which +>may or may not contain an "e". If the argument +>contains an e, say 123e45, then \split should expand +>to \a{123}{45}, and if not, say 12345, then \split +>should expand to \b{12345}. + +How's about: + +\documentclass{article} + +\def\a#1#2{(A #1 #2)} +\def\b#1{(B #1)} + +\makeatletter +\def\@split#1e#2e#3\end@split{% + \xdef\@gtempa{#2}% + \ifx\@gtempa\@empty + \b{#1}% + \else + \a{#1}{#2}% + \fi} +\def\split#1{\@split#1ee\end@split} + +\begin{document} + +\tracingmacros=2 +\split{123e45} +\split{12345} +\tracingmacros=0 + +\end{document} + +Norman + +------------------------------------------------------------------ +Norman Gray http://www.astro.gla.ac.uk/users/norman/ + +========================================================= + +From: Michael Downes +Subject: Re: TeX Macros +Newsgroups: comp.text.tex +Date: 04 Nov 1999 12:40:21 -0500 +Organization: American Mathematical Society + +john green writes: + +> I used a modifed version of Heikos solution in the end +> +> \def\frealsplit#1e#2e#3 {% +> \xdef\fgtempa{#2}% +> \ifx\fgtempa\empty +> \fdecimal{#1}% +> \else +> \fexp{#1}{#2}% +> \fi} +> \def\freal#1{\frealsplit#1ee } + +If you change your definition of \fdecimal slightly so that it takes two +arguments, but discards the second one, then you could let TeX's +argument scanning handle the branching and do without \fgtempa and \ifx: + +\def\freal#1{\frealsplit#1ee\fexp\fdecimal\empty} +\def\frealsplit#1e#2e#3#4#5{#4{#1}{#2}} + +E.g.: + +\def\fdecimal#1#2{Decimal #1} +\def\fexp#1#2{Exponential #1 E #2} + +Regards, Michael Downes + +========================================================= + +From: oberdiek@ruf.uni-freiburg.de (Heiko Oberdiek) +Subject: Re: TeX Macros +Newsgroups: comp.text.tex +Date: Fri, 05 Nov 1999 04:04:43 GMT +Organization: Rechenzentrum der Universitaet Freiburg, Germany + +On 04 Nov 1999 12:40:21 -0500, Michael Downes +wrote: + +>john green writes: +> +>> \def\frealsplit#1e#2e#3 {% +>> \xdef\fgtempa{#2}% +>> \ifx\fgtempa\empty +>> \fdecimal{#1}% +>> \else +>> \fexp{#1}{#2}% +>> \fi} +>> \def\freal#1{\frealsplit#1ee } +> +>If you change your definition of \fdecimal slightly so that it takes two +>arguments, but discards the second one, then you could let TeX's +>argument scanning handle the branching and do without \fgtempa and \ifx: +> +>\def\freal#1{\frealsplit#1ee\fexp\fdecimal\empty} +>\def\frealsplit#1e#2e#3#4#5{#4{#1}{#2}} + +Beautiful! + +>E.g.: +> +>\def\fdecimal#1#2{Decimal #1} +>\def\fexp#1#2{Exponential #1 E #2} + +The second argument of \fdecimal can easily be removed: + +\def\freal#1{\frealsplit#1ee\fexp\frealdecimal\empty} +\def\frealsplit#1e#2e#3#4#5{#4{#1}{#2}} +\def\frealdecimal#1#2{\fdecimal{#1}} + +\def\fdecimal#1{Decimal #1} +\def\fexp#1#2{Exponential #1 E #2} + +Best regards + Heiko + +========================================================= + +From: asnd@erich.triumf.ca (Donald Arseneau) +Subject: Re: formatting numbers +Newsgroups: comp.text.tex +Date: 10 Nov 1999 16:55 PST +Organization: TRIUMF: Canada's National Meson Facility + +In article , john green + writes... +>I've almost finished doing just this + + That brings to mind your earlier question about splitting text at + an "e" (or E). There's no real need, and it may not be the best way. + Let me put on my \mathcode"8000 hat... + + \newcommand\sn[1]{\ensuremath{\bgroup + % \mathcode`e="8000 \mathcode`E="8000 % Avoid characters ` and " + \mathcode 69=32768 \mathcode 101=32768 + #1\egroup}} + + \def\SciNotate{\egroup \times 10^\bgroup} + { + \def\\#1{\global\let#1\SciNotate} + \catcode 69=13 \catcode 101=13 + \\e \\E + } + + + (I din't use one of the "nice" ways to define active characters, + such as \actively\let e=\SciNotate.) + + Maybe you also have niceties like converting E+07 to \times 10^{7}, + but that too could be added here. + + I think there is a general benefit form not parsing the text of the + argument, but the benefit is small here, as I expect it is intended + for automatically typesetting computer output. + + Another thing to look for is the dcolumn package, using "e" as the + "decimal" character. This will align numbers on the exponent in a + table. + + Donald Arseneau asnd@triumf.ca + +End of returned message + + + + + + diff --git a/macros/latex/contrib/fancynum/dbltable.tex b/macros/latex/contrib/fancynum/dbltable.tex new file mode 100644 index 0000000000..dd46482854 --- /dev/null +++ b/macros/latex/contrib/fancynum/dbltable.tex @@ -0,0 +1,17 @@ +% automatically generated by tables.c +\begin{table}[tbh] +\begin{center} +\begin{tabular}{|c|c|c|} +\hline +Format & Output & Typeset \\ \hline +\verb|%f| & \verb|3.141593| & $\fnum{3.141593}$ \\ +\verb|%e| & \verb|3.141593e+00| & $\fnum{3.141593e+00}$ \\ +\verb|%g| & \verb|3.14159| & $\fnum{3.14159}$ \\ +\verb|%.9f| & \verb|3.141592654| & $\fnum{3.141592654}$ \\ +\verb|%.9e| & \verb|3.141592654e+00| & $\fnum{3.141592654e+00}$ \\ +\verb|%.9g| & \verb|3.14159265| & $\fnum{3.14159265}$ \\ +\hline +\end{tabular} +\end{center} +\caption{Double conversions for $\pi$\label{dbltable}} +\end{table} diff --git a/macros/latex/contrib/fancynum/examples.tex b/macros/latex/contrib/fancynum/examples.tex new file mode 100644 index 0000000000..3909c04c2c --- /dev/null +++ b/macros/latex/contrib/fancynum/examples.tex @@ -0,0 +1,58 @@ +% Examples for the fancynum package +% J.J.Green 1999 +% $Id: examples.tex,v 1.7 2000/08/08 22:29:25 jjg Exp $ + +\documentclass[a4paper]{article} +\usepackage[english,tight]{fancynum} +\usepackage{xspace} +\title{Example \texttt{fancynum} output} +\date{17th March 2000} +\author{J. J. Green} + +\begin{document} +\maketitle + +This file contains some of examples of the use of the package. +Table~\ref{dbltable} shows some examples of the setting +of a number ($\pi$) for different \emph{printf} format strings. +The table was generated entirely automatically by the C program +\texttt{tables.c} include in the distribution. The group symbol used is +the thinspace. +\setfnumgsym{\,} +\input{dbltable} + +The figures in Table~\ref{factorial} are also set by the package. +This table shows some values of the factorial squared, and is +included to give an example of a real table with integers of +widely varying magnitude. The group symbol used here is the comma. +\begin{table}[tbh] +\begin{center} +\setfnumgsym{{,}} +\begin{tabular}{|c|r|} +\hline +$n$ & $(n!)^2$ \\ +\hline +$1$ & $\fnum{1}$ \\ +$2$ & $\fnum{4}$ \\ +$3$ & $\fnum{36}$ \\ +$4$ & $\fnum{576}$ \\ +$5$ & $\fnum{14400}$ \\ +$6$ & $\fnum{518400}$ \\ +$7$ & $\fnum{25401600}$ \\ +$8$ & $\fnum{1625702400}$ \\ +$9$ & $\fnum{131681894400}$ \\ +\hline +\end{tabular} +\end{center} +\caption{Some values of $(n!)^2$\label{factorial}} +\end{table} + +\newcommand{\fntest}[1]{\texttt{#1} ($\fnum{#1}$)\xspace} +An earlier version of the package had a bug which +mis-set the examples \fntest{3.14e1}, \fntest{3.14e-1} +and \fntest{3.14e000001}, but these problems are now +fixed. + +\end{document} + + diff --git a/macros/latex/contrib/fancynum/fancynum.dtx b/macros/latex/contrib/fancynum/fancynum.dtx new file mode 100644 index 0000000000..a049dad5d2 --- /dev/null +++ b/macros/latex/contrib/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} +% +%\NeedsTeXFormat{LaTeX2e}[1995/12/01] +%\ProvidesPackage{fancynum} +% \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} +% +% \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} +% +% \end{macrocode} +% +% \Finale + + + + + diff --git a/macros/latex/contrib/fancynum/fancynum.ins b/macros/latex/contrib/fancynum/fancynum.ins new file mode 100644 index 0000000000..c9c2600787 --- /dev/null +++ b/macros/latex/contrib/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/macros/latex/contrib/fancynum/fancynum.pdf b/macros/latex/contrib/fancynum/fancynum.pdf new file mode 100644 index 0000000000..2fc923d4f6 Binary files /dev/null and b/macros/latex/contrib/fancynum/fancynum.pdf differ diff --git a/macros/latex/contrib/fancynum/tables.c b/macros/latex/contrib/fancynum/tables.c new file mode 100644 index 0000000000..049f092e11 --- /dev/null +++ b/macros/latex/contrib/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 +#include + +/* + 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"); +} + + + + + + + + + -- cgit v1.2.3