ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Wolfgang Schuster" <schuster.wolfgang@googlemail.com>
To: "mailing list for ConTeXt users" <ntg-context@ntg.nl>
Subject: Re: Equivalent of LaTeX \cancel? and Thanks!
Date: Tue, 14 Oct 2008 10:10:47 +0200	[thread overview]
Message-ID: <115224fb0810140110g20615db6i6ed3955aaa93b6fd@mail.gmail.com> (raw)
In-Reply-To: <48F206FF.8090007@wxs.nl>

On Sun, Oct 12, 2008 at 4:17 PM, Hans Hagen <pragma@wxs.nl> wrote:
> Benjamin R. Haskell wrote:
>> Hi all,
>>
>> I recently transitioned from LaTeX to ConTeXt. There was some particular
>> thing I needed to do (which escapes me at the moment) that was far, far
>> easier to do in ConTeXt than in LaTeX. And, as I've learned, I've found
>> that that's quite often the case. So, a huge thank you to everyone
>> involved.
>>
>> A couple hours ago I was annoyed that I couldn't find an equivalent for
>> the LaTeX 'cancel' environment/command/style(?)[1]. Now, I'm truly amazed
>> that 'cancel' required a whole package.
>>
>> After discovering that 'underline' and 'strikethrough' were implemented as
>> overlays, I quickly coded up the following:
>>
>> \startuseMPgraphic{MyCancel}
>>      draw (0,.2*\overlayheight)--(\overlaywidth,\overlayheight);
>> \stopuseMPgraphic
>> \defineoverlay[mycancel][\useMPgraphic{MyCancel}]
>>
>> \def\cancel#1{\framed[background=mycancel,frame=off]{#1}}
>>
>>
>> Now, I'm sure this is not *quite* the right way to do it. The 'cancel'ed
>> items end up being placed too high on the line, and other spacings are
>> slightly off. But, taking a cue from underlining, I kept the MyCancel
>> graphic and tried:
>>
>> \definetextbackground
>>     [cancel]
>>     [location=text,
>>      alternative=1,
>>      background=mycancel]
>> % plus boilerplate for setting up \startcancel\stopcancel
>>
>> ....But, while composing this email, I found what I wanted, which still
>> isn't ``right'' in some sense:
>>
>> \def\cancel#1{\framed[background=mycancel,frame=off,width=fit,height=fit,strut=no]{#1}}
>>
>> I found the parameters for \framed. I'm still learning to Read The
>> Fantastic Manuals, but sent this anyway since I wanted to say thanks.
>
>
> \startuseMPgraphic{mpos:par:cancel}
>     for i=1 upto nofmultipars :
>         draw
>             .2[llcorner multipars[i],ulcorner multipars[i]] --
>             .2[urcorner multipars[i],lrcorner multipars[i]] ;
>     endfor ;
> \stopuseMPgraphic
>
> \definetextbackground[cancel][location=text,mp=mpos:par:cancel]
>
> \def\startcancel{\starttextbackground[cancel]}
> \def\stopcancel {\stoptextbackground}
> \def\cancel     {\groupedcommand\startcancel\stopcancel}
>
> however, this is kind of fuzzy when you cross lines
>
> an alternative is to use:
>
> \definetextbackground[cancel][location=text,alternative=4,background=,frame=off]
>
> \definestartstop
>   [cancel]
>   [before={\starttextbackground[cancel]},
>    after=\stoptextbackground]

\definestartstop is not neccessary because \definetextbackground defines
\start/\stopcancel and \cancel as shortcuts ;-)

> however, there is a glitch in the drawing so you need a patch
>
> \startMPinclusions
> def draw_multi_pars  =
>   for i=1 upto nofmultipars :
>     do_draw_par(multipars[i]) ;
>         if boxgridtype= 1 :
>       draw baseline_grid (multipars[i],if multilocs[i]=1: down else: up
> fi,true) ; % withcolor boxgridcolor ;
>     elseif boxgridtype= 2 :
>       draw baseline_grid (multipars[i],if multilocs[i]=1: down else: up
> fi,false) ; % withcolor boxgridcolor ;
>     elseif boxgridtype= 3 :
>       draw baseline_grid (multipars[i],if multilocs[i]=1: down else: up
> fi,true) ; % withcolor boxgridcolor ;
>       draw baseline_grid (multipars[i],if multilocs[i]=1: down else: up
> fi,true) shifted (0,ExHeight) ; % withcolor boxgridcolor ;
>     elseif boxgridtype= 4 :
>       draw baseline_grid (multipars[i],if multilocs[i]=1: down else: up
> fi,true) shifted (0,ExHeight/2) ; % withcolor boxgridcolor ;
>     elseif boxgridtype=11 :
>       draw
> graphic_grid(multipars[i],boxgriddistance,boxgriddistance,boxgriddistance/2,boxgriddistance/2)
> ;
>     elseif boxgridtype=12 :
>       draw graphic_grid(multipars[i],boxgriddistance,boxgriddistance,0,0) ;
>     fi ;
>   endfor ;
> enddef ;
> \stopMPinclusions
>
> (will be fixed in the next release)

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


      reply	other threads:[~2008-10-14  8:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-11 19:17 Benjamin R. Haskell
2008-10-12 14:17 ` Hans Hagen
2008-10-14  8:10   ` Wolfgang Schuster [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=115224fb0810140110g20615db6i6ed3955aaa93b6fd@mail.gmail.com \
    --to=schuster.wolfgang@googlemail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).