lout-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing math layout / microtypography


From: Valery Ushakov
Subject: Re: Changing math layout / microtypography
Date: Thu, 31 Mar 2016 21:07:31 +0300
User-agent: Mutt/1.5.24 (2015-08-30)

On Thu, Mar 31, 2016 at 19:07:01 +0300, Valery Ushakov wrote:

> On Thu, Mar 31, 2016 at 17:10:34 +0200, Oliver Bandel wrote:
> 
> > I want to have a different layout/typography
> > for the integral symbol.
> > I want the limits to be directly below and above the Integral-symbol,
> > not right-sided.
> > The Sum-symbol seems to have both options, but the integral it seems,
> > only has the limits shifted to the right of the integral-symbol.
> 
> Actually "int" does have an option to set limits above/below, it's
> just it defaults directly to "No", so you can override it on
> individual invocations, but not globally.
> 
>     int limits { Yes } ... 
> 
> 
> You can either use that explicitly or you can define

Ok, my Lout is very rusty, but come to think of it you can probably
also do something like the following.

XXX: I'm not sure how else you can pick up default values from the
definition of @Math since they are not exported.  The renaming from
"dftfoo" back to "foo" is just for cosmetics.

The trick is that you cannot re-define a symbol in the same scope, so 

  extend @Math def int ... 

doesn't work.  But you can define a shadowing symbol with the same
name in a new scope where the old one is (was) also visible.  The
cosmetic renaming in @MathDefaults below uses that trick too.

Another factor that makes this work is that import on a named
parameter is more magical than import on a definition.  Import on a
definition will let you use exported symbols inside the definition
body, but in the body paramter of the definition you will be able to
use only things you yourself export.  OTOH, import on the named
parameter blesses the parameter value at the point of invocation to
see the exported values, kinda like body parameter does.  See Expert's
Guide for details.


extend @Math
export
  symbolfont
  basefont
  initialstyle
  initiallycramped
  initialspace
def @MathDefaults
{
  def dftsymbolfont { symbolfont    }
  def symbolfont    { dftsymbolfont }

  def dftbasefont { basefont    }
  def basefont    { dftbasefont }

  def dftinitialstyle { initialstyle    }
  def initialstyle    { dftinitialstyle }

  def dftinitiallycramped { initiallycramped    }
  def initiallycramped    { dftinitiallycramped }

  def dftinitialspace { initialspace    }
  def initialspace    { dftinitialspace }
}

import @Math
export int
def @MyMath
  import @MathDefaults named symbolfont       { symbolfont }
  import @MathDefaults named basefont         { basefont   }
  import @MathDefaults named initialstyle     { initialstyle }
  import @MathDefaults named initiallycramped { initiallycramped }
  import @MathDefaults named initialspace     { initialspace }

  # NB: pseudo-body where both @Math and the new "int" are visible
  # "@" is sufficiently unobtrusive name for when you need a "named"
  # parameter but don't want a real word
  import @Math @MyMath named @ { }
@Begin

  def int # define a new one, shadowing the one in @Math
    named limits { "dft" }
    named from   { }
    named to     { }
  {
    { @Math {} } @Open {
      int limits { limits } from { from } to { to }
    }
  }

  @Math
    symbolfont { symbolfont }
    basefont { basefont }
    initialstyle { initialstyle }
    initiallycramped { initiallycramped }
    initialspace { initialspace }
  { @ }
@End @MyMath

macro @MM { @HContract @VContract @MyMath initialstyle { "text" } }


And then you can use @MyMath @{ ... } - note the extra @ - instead of
@Math { ... } and use the same "int" name instead of inventing a new
one like "lint".  Ditto for @MM @{ ... } vs. @M { ... }.

And you can specify pararmeters like with @Math, e.g.

    @MyMath basefont { Courier Base } @{ ... }


My very old posts about scoping that might help clarify the above
definitions can be found at:

  http://www.stderr.spb.ru/~uwe/lout/essays/496.scoping.txt
  http://www.stderr.spb.ru/~uwe/lout/essays/636.scoping.txt

-uwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]