mailing-list for TeXmacs Users

Text archives Help


Re: Numbered lines


Chronological Thread 
  • From: address@hidden
  • To: address@hidden
  • Subject: Re: Numbered lines
  • Date: Tue, 18 Feb 2003 14:56:30 +0100

On Sat, Feb 15, 2003 at 09:07:47PM +0100, Patrick CARDONA wrote:
> On Thu, Feb 13, 2003 at 12:30:09PM +0100, Joris van der Hoeven wrote:
> >
> > > > This is my second question :
> > > > I need to write number lines - a five increment - in the margin of
> > > > some
> > > > paragraph to make it easier for related questions. Do you now a
> > > > function
> > > > to make it in TexMacs ?
> > >
> > > You can use undocumented primitives decorate-atoms and decorate-lines
> > > for this. Decorate-atoms applies a macro on every soft (hyphenated)
> > > line and (I suppose) decorate-lines applies a macro on ever hard
> > > (paragraph) line.
> >
> > I am not sure that this is the easiest way to do this.
> > I have the impression that it suffices to create
> > some kind of modified enumeration macro; am I right?
>
> Well, I found something like this in automatic.ts (toc-dots, index-dots and
> glossary-dots) but I dont understand how I should modify the things to
> obtain
> numbered lines. I'm really a beginer in all this... Can you explain a little
> more how things work or where they are much explained ?

Well 'how things work' in TeXmacs is a vast topic...

'Where they are much explained', on the other hand is an easy
question: nowhere. That mean you have to make make experiments and
sometimes read the source.

> And you, Joris, may you please give us an example of such a modified macro ?

Joris seems busy, but since numbered lines is a common requirement I
made a package to this effect. In attachement.

I could not figure a way to have the line numbers and the line text
vertically centered, but I think that is already not too bad.

--
David Allouche | GNU TeXmacs -- Writing is a pleasure
Free software engineer | http://www.texmacs.org
http://ddaa.net | http://alqua.com/tmresources
address@hidden | address@hidden
TeXmacs is NOT a LaTeX front-end and is unrelated to emacs.
<TeXmacs|1.0.1.4>

<\body>
  <with|font series|bold|Library utilities>

  Evaluate an expression and return a null string.

  <assign|hide|<func|x|<if|<equal|<apply|x>|<quote|>>||>>>

  Physical value of a length in a modified context

  May be extended later to support any number of context changes.

  <assign|length-with|<func|len|var|val|<apply|<func|result|<merge|<apply|hide|<with|<apply|var>|<apply|val>|<assign|result|<plus|0unit|<apply|len>>>>>|<apply|result>>>|none>>>

  <assign|thin-tabular|<macro|x|<tformat|<cwith|1|-1|1|-1|cell
  lsep|0fn>|<cwith|1|-1|1|-1|cell rsep|0fn>|<cwith|1|-1|1|-1|cell
  bsep|0fn>|<cwith|1|-1|1|-1|cell tsep|0fn>|<arg|x>>>>

  \;

  <with|font series|bold|Low-level numbered lines>

  Define a numbered-lines macro.

  name: name of the macro to define.

  compute: function producing a line number

  display: macro displaying the decorated line, its argument is the line
  number, it must apply the function 'theline' to compute the line number.

  margin: macro setting the surrounding environment

  <assign|new-numlines|<func|name|compute|display|margin|<eval|<hold|<assign|<release|<value|name>>|<macro|x|<expand|<release|<value|margin>>|<with|linenr|0|theline|<func|<apply|<release|<value|compute>>>>|<datoms|<macro|y|<assign|linenr|<plus|<apply|linenr>|1>><expand|<release|<value|display>>|<apply|theline>|<arg|y>>>|<arg|x>>>>>>>>>>

  \;

  <with|font series|bold|High-level numbered lines>

  Define numbered-lines macros

  <assign|new-numlines-aligned|<func|name|compute|size|width|space|<apply|new-numlines|<apply|name>|<value|compute>|<eval|<hold|<macro|deco|body|<expand|thin-tabular|<tformat|<cwith|1|1|1|1|cell
  width|<release|<apply|length-with|<apply|width>|font
  size|<apply|size>>>>|<cwith|1|1|1|1|cell halign|r>|<twith|table
  valign|b>|<cwith|1|-1|1|-1|cell vcorrect|n>|<table|<row|<cell|<with|font
  size|<release|<apply|size>>|<arg|deco>>>>>>><with|font
  size|1|<space|<release|<apply|space>>>><arg|body>>>>|<eval|<hold|<macro|x|<with|right
  margin|<plus|<apply|right margin>|<plus|<apply|length-with|<release|<apply|space>>|font
  size|1>|<apply|length-with|<release|<apply|width>>|font
  size|<release|<apply|size>>>>>|old font size|<apply|font
  size>|<arg|x>>>>>>>>

  \;

  <with|font series|bold|Numbered lines environments>

  <apply|new-numlines-aligned|numbered-lines|<func|<apply|linenr>>|0.71|1.5fn|2spc>

  <apply|new-numlines-aligned|numbered-5-lines|<func|<if|<equal|<mod|<apply|linenr>|5>|0>|<apply|linenr>>>|0.71|1.5fn|2spc>
</body>

<\initial>
  <\collection>
    <associate|preamble|true>
    <associate|page right margin|5mm>
    <associate|dpi|600>
    <associate|paragraph mode|left>
    <associate|reduction page left margin|25mm>
    <associate|language|english>
    <associate|page width|996352unit>
    <associate|odd page margin|5mm>
    <associate|paragraph width|150mm>
    <associate|page medium|automatic>
    <associate|shrinking factor|7>
    <associate|page top margin|5mm>
    <associate|reduction page right margin|25mm>
    <associate|reduction page bottom margin|15mm>
    <associate|page type|a4>
    <associate|even page margin|5mm>
    <associate|page bottom margin|5mm>
    <associate|page height|1256192unit>
    <associate|reduction page top margin|15mm>
  </collection>
</initial>



Archive powered by MHonArc 2.6.19.

Top of page