How to prevent \reference[myrefA]{myrefA} from creating vertical emptiness?

Here is my minimum working example: \startuseMPgraphic{FunnyFrame} picture p ; numeric w, h, o ; p := textext.rt(\MPstring{FunnyFrame}) ; w := OverlayWidth ; h := OverlayHeight ; o := BodyFontSize ; p := p shifted (2o,h-ypart center p) ; draw p ; drawoptions (withpen pencircle scaled 1pt withcolor black) ; draw (2o,h)--(0,h)--(0,0)--(w,0)--(w,h)--(xpart urcorner p,h) ; %draw boundingbox p ; setbounds currentpicture to unitsquare xyscaled(w,h) ; \stopuseMPgraphic \defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}] \defineframedtext[FunnyText][frame=off,background=FunnyFrame, width=\textwidth] \def\StartFrame{\startFunnyText} \def\StopFrame {\stopFunnyText } \def\FrameTitle#1% {\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut#1\hss}}} \setMPtext{FunnyFrame}{} \define\sidebarA{% \placefigure[none]{}{% \FrameTitle{\strut \bf Title}% \StartFrame% Text \StopFrame% }% }% \starttext \startparagraph \input knuth \stopparagraph\reference[myrefA]{myrefA} \sidebarA \startparagraph \input knuth \stopparagraph \stoptext I need to make a reference to the box, which I call a sidebar. I've put \reference[myrefA]{myrefA} near it, so a cross-reference will say "See the sidebar on p. 2". The problem is, its creating a strange vertical space. If I put it anywhere in front of \sidebarA, it makes a gap above the sidebar. And if I put it anywhere after \sidebarA, it puts the gap after. And if I put it inside, it causes some error and it lists as ?? instead of showing the page number. Note that this also happens with floats I have for pictures. The same problem is appearing! How do I get rid of the extra vertical gap that is appearing where I put my reference? --Joel

On 3/6/25 01:49, Joel via ntg-context wrote:
[...] How do I get rid of the extra vertical gap that is appearing where I put my reference?
Hi Joel, this is just a trick. Instead of \stopparagraph\reference[myrefA]{myrefA} \sidebarA you may achieve it with \stopparagraph \inmargin{\reference[myrefA]{myrefA}}% \sidebarA BTW, add the reference just before sidebar (and not just after the paragraph). This way you won’t have issues if there is a page break just between the previous paragraph and the sidebar. I hope it helps, Pablo

Am 06.03.2025 um 01:49 schrieb Joel via ntg-context:
Here is my minimum working example:
\startuseMPgraphic{FunnyFrame} picture p ; numeric w, h, o ; p := textext.rt(\MPstring{FunnyFrame}) ; w := OverlayWidth ; h := OverlayHeight ; o := BodyFontSize ; p := p shifted (2o,h-ypart center p) ; draw p ; drawoptions (withpen pencircle scaled 1pt withcolor black) ; draw (2o,h)--(0,h)--(0,0)--(w,0)--(w,h)--(xpart urcorner p,h) ; %draw boundingbox p ; setbounds currentpicture to unitsquare xyscaled(w,h) ; \stopuseMPgraphic \defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}] \defineframedtext[FunnyText][frame=off,background=FunnyFrame, width=\textwidth] \def\StartFrame{\startFunnyText} \def\StopFrame {\stopFunnyText } \def\FrameTitle#1% {\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut#1\hss}}} \setMPtext{FunnyFrame}{}
\define\sidebarA{% \placefigure[none]{}{% \FrameTitle{\strut \bf Title}% \StartFrame% Text \StopFrame% }% }%
1. Add a optional argument to \sidebarA. \starttexdefinition tolerant protected sidebarA [#1] \startplacefigure[location=none] \FrameTitle{\strut \bf Title}% \StartFrame\relax \ifparameter#1\or\pagereference[#1]\fi Text \StopFrame \stopplacefigure \stoptexdefinition
\starttext
\startparagraph \input knuth \stopparagraph\reference[myrefA]{myrefA}
\sidebarA
2. Set the reference with the optional argument. \sidebarA[myrefA] Wolfgang

On 3/6/25 17:55, Wolfgang Schuster wrote:
1. Add a optional argument to \sidebarA.
\ifparameter#1\or\pagereference[#1]\fi
Many thanks for your reply, Wolfgang. I didn’t know \ifparameter existed. I have a question, would this possible? \ifparameter#1\pagereference[#1]\else\fi If it were, which would be the difference? Many thanks for your help, Pablo

Am 06.03.2025 um 19:37 schrieb Pablo Rodriguez via ntg-context:
On 3/6/25 17:55, Wolfgang Schuster wrote:
1. Add a optional argument to \sidebarA.
\ifparameter#1\or\pagereference[#1]\fi
Many thanks for your reply, Wolfgang.
I didn’t know \ifparameter existed.
I have a question, would this possible?
\ifparameter#1\pagereference[#1]\else\fi
If it were, which would be the difference?
With \ifparameter you can check if the given parameter has content or not and everything goes after the \or, not before it. The check itself is similar to \doifelsesomething or \ifempty because you only care whether the argument is empty or not. %%%% begin example \tolerant\def\Test[#1][#2]% {\ifparameter#1\or Optional argument! \else Empty or no argument! \fi} \starttext \Test \Test[xxx] \Test[] \stoptext %%%% end example More information can be found in lowlevel-macros.pdf. Wolfgang

On 3/6/25 20:35, Wolfgang Schuster wrote:
Am 06.03.2025 um 19:37 schrieb Pablo Rodriguez via ntg-context:
[...] If it were, which would be the difference?
With \ifparameter you can check if the given parameter has content or not and everything goes after the \or, not before it.
The check itself is similar to \doifelsesomething or \ifempty because you only care whether the argument is empty or not.
Many thanks for your explanation, Wolfgang. This is clearer to me now. Many thanks for your help, Pablo
participants (3)
-
Joel
-
Pablo Rodriguez
-
Wolfgang Schuster