2

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
2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.