Skip to Content.
Sympa Menu

texmacs-users - Re: [TeXmacs] Cancellation of terms

Subject: mailing-list for TeXmacs Users

List archive

Re: [TeXmacs] Cancellation of terms


Chronological Thread 
  • From: Miguel de Benito Delgado <address@hidden>
  • To: "address@hidden" <address@hidden>
  • Subject: Re: [TeXmacs] Cancellation of terms
  • Date: Fri, 20 Mar 2015 00:17:45 +0100

I've actually wanted this for some time and never found the motivation to try it.

On Wed, Mar 18, 2015 at 5:34 PM, Martial Tarizzo <address@hidden> wrote:
It would be great to compute these coordinates (i.e the position, width
and height of the box), but I didn't find a way to get them .

AFAIK box length units like "1l", "1w" are only available within some specific macros like resize, move, etc. Search the doc for more info.

I see three possible venues for implementing this:

1. Try something with virtual fonts. Some single characters are indeed negated this way, but I wouldn't know how to extend this to arbitrary content. Come to think of it, it doesn't make much sense.

2. Try to coerce the box dimensions of the content to be cancelled out of the macros I mentioned above, somehow storing its value for later use. Out of the top of my head I don't see how this would work, though.

3. Implement a new wide_box in C++ (see e.g. wide_bar_box, wide_vect_box, etc.) I've attached a proof-of-concept patch for those willing to hack around a bit. Apply it and then, with some selection made in your document, run the scheme command (make-wide "<cancelled>"), e.g. by clicking Tools->Execute->Evaluate scheme _expression_

If someone finds the time to properly adjust the margins, and this turns out to be the best solution we can think of committing it. Of course, the other cancellations would be cool as well, or maybe a more general mechanism which would allow for easy user customization (different/multiple arrows, etc.). Replacement of the super/lower indices would be nice too...

But it's late...

Best,
--
Miguel de  Benito.
Index: src/src/Typeset/Boxes/Basic/stretch_boxes.cpp
===================================================================
--- src/src/Typeset/Boxes/Basic/stretch_boxes.cpp (revision 9031)
+++ src/src/Typeset/Boxes/Basic/stretch_boxes.cpp (working copy)
@@ -67,6 +67,15 @@
}

box
+wide_cancelled_box (path ip, SI x1, SI y1, SI x2, SI y2, pencil pen) {
+ SI penw= pen->get_width();
+ SI width= max (penw, x2-x1);
+ SI height= max (penw, y2-y1);
+ SI margin= 2*penw;
+ return line_box (ip, -1*margin, -1*(height + margin), width+margin,
margin, pen);
+}
+
+box
wide_vect_box (path ip, SI x1, SI x2, pencil pen) {
SI penw= pen->get_width ();
SI width, height, arrow= 2*penw, delta=penw/2;
Index: src/src/Typeset/Boxes/Composite/math_boxes.cpp
===================================================================
--- src/src/Typeset/Boxes/Composite/math_boxes.cpp (revision 9031)
+++ src/src/Typeset/Boxes/Composite/math_boxes.cpp (working copy)
@@ -324,6 +324,8 @@
wideb= wide_tilda_box (decorate_middle (ip), b->x1, b->x2, wpen);
else if (s == "<bar>")
wideb= wide_bar_box (decorate_middle (ip), b->x1, b->x2, wpen);
+ else if (s == "<cancelled>")
+ wideb= wide_cancelled_box (decorate_middle (ip), b->x1, b->y1, b->x2,
b->y2, wpen);
else if (s == "<vect>")
wideb= wide_vect_box (decorate_middle (ip), b->x1, b->x2, wpen);
else if (s == "<check>")
Index: src/src/Typeset/Boxes/construct.hpp
===================================================================
--- src/src/Typeset/Boxes/construct.hpp (revision 9031)
+++ src/src/Typeset/Boxes/construct.hpp (working copy)
@@ -91,6 +91,7 @@
box wide_hat_box (path ip, SI x1, SI x2, pencil pen);
box wide_tilda_box (path ip, SI x1, SI x2, pencil pen);
box wide_bar_box (path ip, SI x1, SI x2, pencil pen);
+box wide_cancelled_box (path ip, SI x1, SI y1, SI x2, SI y2, pencil pen);
box wide_vect_box (path ip, SI x1, SI x2, pencil pen);
box wide_check_box (path ip, SI x1, SI x2, pencil pen);
box wide_breve_box (path ip, SI x1, SI x2, pencil pen);



Archive powered by MHonArc 2.6.19.

Top of Page