mailing-list for TeXmacs Users

Text archives Help


Re: [Q] how to display text of a label??


Chronological Thread 
  • From: address@hidden
  • To: Leo Razoumov <address@hidden>
  • Cc: address@hidden
  • Subject: Re: [Q] how to display text of a label??
  • Date: Mon, 27 Jan 2003 13:03:51 +0100

On Thu, Jan 23, 2003 at 07:08:39PM -0500, Leo Razoumov wrote:
> Hi TeXmacs Experts,
>
> For a class I am teaching I write lecture notes with TeXmacs.
> The notes have lots of numbered equations which are extensively
> cross-referenced in the text. Everything works fine except for one
> annoying thing. I am constantly keeping forgetting exactly what label
> text I assigned to what equation. And TeXmacs does not show label
> text in the normal mode. I keep switching to "Preamble mode" and back
> but it is very inconvenient.
>
> [Q] Are there any magic macros which would display label text?
>
> In LaTeX one achieves this behavior by \usepackage{showkeys} in the
> document preamble.

Actually there is a way to do it until the new features come.

You can get the idea by looking at
http://ddaa.net/texmacs/style/tags-0.1.tar.gz

What you need is:

1. A package which defines typesetter function label-func which is a
wrapper over label

2. A conversion program which convert label primitives to label-func
applications.

3. label-func must display its contents when some document variable is
set.

4. optionnaly you may want to set the document variable from the menu.

The package is attached to this mail (it require the tags package
which you can find at the address above, and which is also attached).

Additionnaly, you need to put this to your .TeXmacs/progs/my-init-texmacs.scm

(exec-file "$TEXMACS_PATH/progs" "init-texmacs.scm")
(exec-file "$TEXMACS_HOME_PATH/progs" "showlabel.scm")

The file showlabel.scm is also attached and should be saved in .TeXmacs/progs.

PS: conversion back to normal labels is left as an exercise for the reader.

--
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.1>

<style|tags>

<\body>
  <assign|showlabel-dtd|1.0>

  \;

  <assign|label|<func|x|<if|<equal|<apply|show
  label>|<quote|true>>|<apply|tag|label: <apply|x>>><label|<value|x>>>>

  \;
</body>

<\initial>
  <\collection>
    <associate|preamble|true>
    <associate|page right margin|5mm>
    <associate|dpi|600>
    <associate|reduction page left margin|25mm>
    <associate|language|english>
    <associate|page width|599040unit>
    <associate|odd page margin|5mm>
    <associate|paragraph width|150mm>
    <associate|page medium|automatic>
    <associate|shrinking factor|3>
    <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 height|460800unit>
    <associate|page bottom margin|5mm>
    <associate|reduction page top margin|15mm>
  </collection>
</initial>
<TeXmacs|1.0.0.1>

<\body>
  <with|font series|bold|The basic tag building block>

  <assign|tag*|<macro|x|<tformat|<cwith|1|-1|1|-1|cell
  rborder|0>|<cwith|1|-1|1|-1|cell bborder|1ln>|<cwith|1|1|1|-1|cell
  tborder|1ln>|<cwith|1|-1|1|1|cell lborder|0>|<cwith|1|1|1|1|cell
  rsep|1spc>|<cwith|1|1|1|1|cell lsep|1spc>|<arg|x>>>>

  <with|font series|bold|Empty tag>

  <assign|tag|<func|name|<with|mode|math|color|blue|<left|langle><space|-0.4s\
  pc><with|mode|text|<expand|tag*|<tformat|<table|<row|<cell|<value|name>>>>>\
  >><space|-0.4spc><right|rangle>>>>

  <with|font series|bold|Right hand side tag>

  <assign|rtag|<func|name|<with|mode|math|color|blue|<left|\|><space|-0.4spc>\
  <with|mode|text|<expand|tag*|<tformat|<table|<row|<cell|<value|name>>>>>>><\
  space|-0.4spc><right|rangle>>>>

  <with|font series|bold|Left hand side tag>

  <assign|ltag|<func|name|<with|mode|math|color|blue|<left|langle><space|-0.4\
  spc><with|mode|text|<expand|tag*|<tformat|<table|<row|<cell|<value|name>>>>\
  >>><space|-0.4spc><right|\|>>>>

  \;

  <with|font series|bold|Tagging macros>

  <assign|tag unary macro|<macro|_name|_value|<assign|<arg|_name>|<hold|<macr\
  o|_param|<surround|<release|<apply|ltag|<arg|_name>>>|<release|<apply|rtag|\
  <arg|_name>>>|<expand|<release|<arg|_value>>|<arg|_param>>>>>>>>

  <assign|tag binary macro|<macro|_name|_value|<assign|<arg|_name>|<hold|<mac\
  ro|_param1|_param2|<surround|<release|<apply|ltag|<arg|_name>>>|<release|<a\
  pply|rtag|<arg|_name>>>|<expand|<release|<arg|_value>>|<arg|_param1>|<arg|_\
  param2>>>>>>>>

  <with|font series|bold|Tagging fragile inline macros (e.g. abbrv)>

  <assign|tag fragile unary macro|<macro|_name|_value|<assign|<arg|_name>|<ho\
  ld|<macro|_param|<release|<apply|ltag|<arg|_name>>><expand|<release|<arg|_v\
  alue>>|<arg|_param>><release|<apply|rtag|<arg|_name>>>>>>>>

  \;

  <with|font series|bold|Tagging functions with a visible expansion>

  <assign|tag function 1|<macro|_name|_value|<assign|<arg|_name>|<hold|<func|\
  _param|<surround|<release|<apply|ltag|<arg|_name>>>|<release|<apply|rtag|<a\
  rg|_name>>>|<apply|<release|<arg|_value>>|<value|_param>>>>>>>>

  \;

  <with|font series|bold|Tagging functions whose expansion is invisible>

  <assign|tag invisible function 1|<macro|_name|_value|<assign|<arg|_name>|<h\
  old|<func|_param|<surround|<release|<apply|tag|<arg|_name>>>||<apply|<relea\
  se|<arg|_value>>|<value|_param>>>>>>>>

  <assign|tag invisible function 2|<macro|_name|_value|<assign|<arg|_name>|<h\
  old|<func|_param1|_param2|<surround|<release|<apply|tag|<arg|_name>>>||<app\
  ly|<release|<arg|_value>>|<value|_param1>|<value|_param2>>>>>>>>

  <assign|tag invisible function 3|<macro|_name|_value|<assign|<arg|_name>|<h\
  old|<func|_param1|_param2|_param3|<surround|<release|<apply|tag|<arg|_name>\
  >>||<apply|<release|<arg|_value>>|<value|_param1>|<value|_param2>|<value|_p\
  aram3>>>>>>>>

  <assign|tag invisible function 4|<macro|_name|_value|<assign|<arg|_name>|<h\
  old|<func|_param1|_param2|_param3|_param4|<surround|<release|<apply|tag|<ar\
  g|_name>>>||<apply|<release|<arg|_value>>|<value|_param1>|<value|_param2>|<\
  value|_param3>|<value|_param4>>>>>>>>
</body>

<\initial>
  <\collection>
    <associate|preamble|true>
    <associate|page right margin|5mm>
    <associate|reduction page left margin|25mm>
    <associate|paragraph mode|left>
    <associate|language|english>
    <associate|page width|998400unit>
    <associate|odd page margin|5mm>
    <associate|paragraph width|150mm>
    <associate|page medium|automatic>
    <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 height|985600unit>
    <associate|page bottom margin|5mm>
    <associate|reduction page top margin|15mm>
  </collection>
</initial>

<\references>
  <\collection>
    <associate|toc-1|<tuple|<uninit>|?>>
    <associate|toc-2|<tuple|<uninit>|?>>
  </collection>
</references>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; showlabel
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(set! texmacs-extra-menu (menu-merge texmacs-extra-menu
'((if (style-has? "showlabel-dtd")
(=> "Showlabel" (link showlabel-menu))))))

(define showlabel-menu
'(("Visible" (toggle-init-env "show label"))
---
("Convert to showlabels" (convert-to-showlabels))))

(define (check-init-env? var)
(equal? (get-init-env var) "true"))

(define (toggle-init-env var)
(if (check-init-env? var)
(init-env var "false")
(init-env var "true")))

(set-check-mark! toggle-init-env "v" check-init-env?)

(define (convert-to-showlabels)
(tm-assign '() (object->tree
(labels->showlabels
(tree->object (the-buffer))))))

(define (labels->showlabels t)
(cond ((string? t) t)
((func? t 'label 1) `(apply "label" ,(cadr t)))
(else (cons (car t) (map labels->showlabels (cdr t))))))


Archive powered by MHonArc 2.6.19.

Top of page