3

I would like to have a custom frame for a textbackground section. I found code for how to use an overlay background for a framedtext section, but it doesn't seem to work for textbackground. Am I missing something or do the two environments require different approaches?

Minimal example with a simple dotted frame:

\startuseMPgraphic{dashed}
  path p; p := (0,0) -- 
               (OverlayWidth,0) -- 
               (OverlayWidth, OverlayHeight) -- 
               (0, OverlayHeight) -- (0,0);
  draw p withpen pencircle scaled 1.5pt dashed withdots;
\stopuseMPgraphic

\defineoverlay[Dashed][\useMPgraphic{dashed}]

\definetextbackground
  [withframe]
  [frame=on, location=paragraph]
\definetextbackground
  [withbackground]
  [frame=off, location=paragraph, background=Dashed]

\starttext

\startframedtext[frame=on]
This is framedtext with frame
\stopframedtext

\startwithframe
This is textbackground with frame
\stopwithframe

\startframedtext[frame=off, background=Dashed]
This is framedtext with background
\stopframedtext

\startwithbackground
This is textbackground with background
\stopwithbackground

\stoptext
ssokolen
  • 1,718
  • 6
  • 13

1 Answers1

3

The "Similar Questions" list had a link that ended up solving my problem, but I figured I'd leave the question up in case someone else approaches this issue from the same angle as I did.

Essentially, it seems like textbackground uses mp as opposed to background and you can't use the same type of overlay code as with a single frame. This answer deals with drawing a frame around a whole section.

Minimal working example (taken largely from the link above):

% Dashed MPgraphic for framedtext
\startuseMPgraphic{dashedframe}
  begingroup;
  path p; p := (0,0) -- 
               (OverlayWidth,0) -- 
               (OverlayWidth, OverlayHeight) -- 
               (0, OverlayHeight) -- (0,0);
  draw p withpen pencircle scaled 1.5pt dashed withdots;
  endgroup;
\stopuseMPgraphic

\defineoverlay[DashedFrame][\useMPgraphic{dashedframe}]

% Dashed MPgraphic for textbackground 
\startuseMPgraphic{dashedbackground}
    begingroup;
        for i=1 upto nofmultipars :
            draw ( llcorner multipars[i]
                -- lrcorner multipars[i]
                -- urcorner multipars[i]
                -- ulcorner multipars[i]
                -- cycle )
            enlarged (EmWidth,EmWidth)
            withpen pencircle scaled 1.5pt dashed withdots;
        endfor ;
    endgroup;
\stopuseMPgraphic

\definetextbackground
  [framedbackground]
  [frame=off, mp=dashedbackground]

\starttext

\startframedtext[frame=off, background=DashedFrame]
This is framedtext with background
\stopframedtext

\startframedbackground
This is textbackground with mp 
\stopframedbackground

\stoptext
ssokolen
  • 1,718
  • 6
  • 13