2

I am trying to define a framed environment (if that's the right term) that is essentially a box with some space before and after it. I can't to figure out an idiomatic way to automatically add space before and after it.

This is a skeleton of what I have:

%&context

\defineframed
  [Callout]
  [offset=1em]

\starttext

I want an automatic space after this paragraph.

\Callout{There is no space above or below the frame}

I want an automatic space before this paragraph.

\stoptext

I found the top and bottom options, but these add space within the frame, rather than around it. I might be missing something, but can't find something like before and after on the wiki (setupframed).

I've been able to add some space using \prependvalue{Callout}{\blank[big]}, but this does not seem idiomatic.

1 Answer 1

5

Judging from your short example I assume that you are looking for framedtext rather than framed. That one supports before and after.

\defineframedtext
  [Callout]
  [offset=1em,
   width=fit,
   before={\blank[big]},
   after={\blank[2*big]}]

\starttext

I want an automatic space after this paragraph.

\startCallout
  There is no space above or below the frame
\stopCallout

I want an automatic space before this paragraph.

\stoptext

enter image description here


If you, for whatever reason, don't like the \start...\stopCallout variant and rather want to use \Callout{...} and keep the space before and after, just overwrite the definition of \Callout.

\starttexdefinition unexpanded singleempty Callout [#1]#2
  \startCallout[#1]#2\stopCallout
\stoptexdefinition
2
  • In case anyone else runs into the same issue as I had, note the use of \startCallout and \stopCallout with the \defineframedtext. I had initially tried to use \Callout{} with \defineframedtext, the same way as with \defineframed and the before/after arguments did not behave as expected.
    – ssokolen
    Aug 19, 2017 at 21:46
  • 1
    @ssokolen This is because they use different mechanisms. \startCallout invokes \pack_framed_text_start whereas \Callout uses \pack_framed_text_direct. The direct version has \blank[disable] inside of it. Aug 20, 2017 at 2:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .