2

I am trying to insert a blank in a frame in ConTeXt ; below are the options I tried to use :

\defineframedtext[experiment]
                 [frame=on,
                   rulethickness=1pt,
                   offset=0pt,
                   width=fit,
                   height=broad,
                   strut=no,
                   location=middle]

\starttext
\startexperiment
  Plop \\
  \blank[3cm]
\stopexperiment
\stoptext

However, the frame is always just below the text, and the blank is ignored. How can I achieve this blank space ?

  • 2
    The framedtext environment removes vertical space at the bottom of the box, to retain the space you can use \startframed to frame your text. – Wolfgang Schuster Aug 16 '16 at 13:51
3

If you don't want to or simply can't switch to a framed environment, just don't zero out \lastskip after the blank.

\defineframedtext
  [experiment]
  [
    frame=on,
    rulethickness=1pt,
    offset=0pt,
    width=fit,
    height=broad,
    strut=no,
    location=middle,
  ]

\starttexdefinition zerolastskip
  \ifvmode
    \scratchdimen=\prevdepth
    \hrule height \zeropoint
    \prevdepth=\scratchdimen
  \fi
\stoptexdefinition

\starttext

\startexperiment
  Plop \\
  \blank[3cm]\zerolastskip
\stopexperiment
\stoptext

You can add this to every experiment by introducing extra wrapping.

\defineframedtext
  [doexperiment]
  [
    frame=on,
    rulethickness=1pt,
    offset=0pt,
    width=fit,
    height=broad,
    strut=no,
    location=middle,
  ]

\definestartstop
  [experiment]
  [
    before={\startdoexperiment},
    after={\zerolastskip\stopdoexperiment},
  ]

\starttexdefinition zerolastskip
  \ifvmode
    \scratchdimen=\prevdepth
    \hrule height \zeropoint
    \prevdepth=\scratchdimen
  \fi
\stoptexdefinition

\starttext
\startexperiment
  Plop \\
  \blank[3cm]
\stopexperiment
\stoptext
  • A alternative to \blank which works in a framedtext environment without being removed is \godown[<NUMBER>] which insert a given number of empty lines. – Wolfgang Schuster Aug 18 '16 at 15:31
  • Be aware that \dontleavehmode adds a extra line to the frame and you end up with 3cm + 1 line of vertical space. – Wolfgang Schuster Aug 18 '16 at 15:34
  • This is a good solution for me. Could someone explain me when I can know if I need \dontleavehmode ? It's the second time I use it to solve a problem (thanks to people here), and it seems like a magical thing to me right now... – A. Licari Aug 19 '16 at 8:49
  • @A.Licari Well, I looked in pack-rul.mkiv where \start...\stopframedtext is defined and found that \stopframedtext executes \removelastskip. That means that one has to somehow clear \lastskip and because this is a read only register one has to insert something in vertical mode. I also revised my answer according to Metafox' comment. – Henri Menke Aug 19 '16 at 9:23
  • 1
    @A.Licari: I would appreciate if you can elaborate, either here or somewhere else, what difficulties you had with ConTeXt as a beginner. I occasionally write short articles in TUGboat targeted at begibners, but it is always difficult to guess what difficulties beginners face because I am no longer a beginner. – Aditya Aug 20 '16 at 17:40
1

ConTeXt removes a vertical skip at the end of a framedtext environment.

Missing skip at the end of framedtext

There are two ways to get around this, the first way is to add a extra skip with a value of 0pt.

\starttext

\startframedtext
Plop
\blank[3cm]
\blank[0pt]
\stopframedtext

\stoptext

Extra skip at the end of framedtext

The second way is to set a penalty after the skip which prevents ConTeXt from removing the skip, this can be done with the samepage keyword for the \blank command.

\starttext

\startframedtext
Plop
\blank[3cm,samepage]
\stopframedtext

\stoptext

Extra penalty at the end of framedtext

  • I'm not sure about this, but it seems to me that the @Henri Menke's solution is more usable to a user-defined environment than yours, which is more of a general way to prevent a blank skip in an environment, am I right ? – A. Licari Aug 20 '16 at 21:59
  • @A.Licari Creating another environment to use framedtext at the cost of losing \startframedtext’s optional argument and defining a command which prevents ConTeXt from removing the skip at the end of the environment isn’t more usable than adding samepage to \blank. – Wolfgang Schuster Aug 21 '16 at 7:40

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.