On Fri, 26 Jan 2007, Taco Hoekwater wrote:

> Hubertus wrote:
>> Hi all again,
>> I try to do something like 1/2 with an upper 1 and a lower 2. The code below
>> still doesn't quite work.
>>
>> \def\nfrac#1#2{\leavevmode\kern.1em%
>>   \raise.5ex\hbox{\scriptsize #1}%
>>   \kern-.1em/\kern-.15em%
>>   \lower.25ex\hbox{\scriptsize #2}}
>>
>
> Such a macro is already present. The command's name is \vulgarfraction,
> and even is configurable (3 is the default rendering);-)
>
> Best, taco
>
> % example taken from core-mis.tex
>
> \starttext
>  \starttabulate
>  \HL
>  \NC \bf method \NC \bf visualization \NC\NR
>  \HL
>  \NC 0 \NC \chardef\vulgarfractionmethod0\vulgarfraction{1}{2} \NC\NR
>  \NC 1 \NC \chardef\vulgarfractionmethod1\vulgarfraction{1}{2} \NC\NR
>  \NC 2 \NC \chardef\vulgarfractionmethod2\vulgarfraction{1}{2} \NC\NR
>  \NC 3 \NC \chardef\vulgarfractionmethod3\vulgarfraction{1}{2} \NC\NR
>  \HL
>  \stoptabulate
> \stoptext

Be careful. This method does not work correctly inside math mode. I 
do not know if it is a good idea to use such a construct inside math 
mode. I am mentioning this because someone added an example on the 
wiki where \vfrac is used in math mode.

Look at the output of

$\vulgarfraction{a}{b} (a+b)$

The a and b of the fraction is in text mode rather than math mode. On 
the LaTeX end, there are two packages that provide such a feature: 
nicefrac and xfrac.

Nicefrac ensures that the height of the fraction is not greater than 
`M'. It is somewhat cleaver, and works "correctly" in displaystyle, 
textstyle, scriptstyle and scriptscriptstyle. See units.dtx for its 
implementation

http://www.ctan.org/tex-archive/macros/latex/contrib/units/

On the other hand, if you want to read what is wrong with nicefrac, 
read the documentation of xfrac by Morton Høgholm
ftp://tug.ctan.org/pub/tex-archive/macros/latex/exptl/xfrac/doc/xfrac.pdf

His main objection is that nicefrac uses virglue instead of a solidus to
separate fractions --- since a solidus is absent from CM fonts. (What are
these things? Is a solidus present in LM?) Another thing is that nicefrac does
not work with old style figures. xfrac allows you to configure the font for
the numerator, solidus and the denominator, amongst other things.

The vulgarfrac in ConTeXt suffers from most of the problems of nicefrac. The
best option is for the font to provide more symbols like \onehalf
\threequarter etc. Failing that we need to have a macro \vulgarfrac 
where \vulgrarfrac 12 is same as \onehalf.

Aditya

_______________________________________________
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context

Reply via email to