Why is only the first frame protruding into the margin?
Hi, I used some code from the meta-fun manual to recreate a labelled frame around my sections. But the first framedtext protrudes a couple of mm into the margin. Only the first one in the page. I intentionaly added other sections and the frames aline to the margin ok. I tried to put something before the first frame (noindentation, dontleavehmode) because I sometimes read it solves problems, but not the case here. so Why is the first frame protruding and only the first? \definepapersize[vertical][A4, portrait] \definepapersize[horizontal][A4, landscape] \setuppapersize[vertical] \setuplayout[location=middle, marking=off, topspace=1cm, topdistance=0cm, backspace=2.5cm, height=fit, width=fit, rightedge=5mm, rightedgedistance=0cm, rightmargin=20mm, rightmargindistance=7mm, leftmargin=1.5cm, header=1cm, headerdistance=.5cm, bottomspace=.5cm, bottomdistance=0mm, footer=.8cm, footerdistance=.2cm, setup=strict,] \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 .25pt withcolor blue) ; draw (2o,h)--(0,h)--(0,0)--(w,0)--(w,h)--(xpart urcorner p,h) ; %draw boundingbox p ; %%%quitamos el frame pequeño setbounds currentpicture to unitsquare xyscaled(w,h) ; \stopuseMPgraphic \defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}] \defineframedtext[FunnyText][width=.85\textwidth, height=20mm, frame=off, background=FunnyFrame, align=flushright,location=right, after={\blank[2*big]}]%foregroundsytel amplía la palabra Apartado \def\FrameTitle#1% {\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut \color[blue]{\tfx Apartado #1}\hss}}} \setMPtext{FunnyFrame}{} % initialize the text variable \define[2]\firstHeadings{% \dontleavehmode \switchtobodyfont[miCorm] \FrameTitle#1% \dontleavehmode \startFunnyText {\switchtobodyfont[miCorm,20.7pt] #2} \stopFunnyText } \setuphead [section] [color=blue, command=\firstHeadings, indentnext=no] \starttext \noindentation \dontleavehmode \startsection[title=Aspectos generales] Esta guía contiene toda la documentación necesaria para administrar la prueba unificada de certificación que ha diseñado la comisión de alemán. Se ruega al profesorado\footnote{Todas las alusiones a la forma del masculino genérico que se recogen en este documento deberán entenderse referidas a la condición masculina o femenina de cada persona según corresponda.} que se familiarice con las secciones del documento a través del índice y acuda a ellas según vaya siendo necesario, de manera que se pueda administrar y corregir la prueba de la manera más satisfactoria posible. \stopsection \startsection[title=another section] Las carpetas con las pruebas aparecen nombradas por idioma, nivel y set de pruebas, no apareciendo ninguna referencia a convocatorias anuales ni tampoco fechas. Sí aparece la referencia a la convocatoria en cada una de las guías de administración para los diferentes niveles. \stopsection \startsection[title=another section] La carpeta correspondiente a cada nivel contiene las distintas actividades de lengua, los audios para CTO y el audio/vídeo base para la mediación escrita. Además contiene esta guía con la información necesaria para tener una visión global de la prueba: los solucionarios, transcripciones, tablas de corrección, tablas de conversión y la rúbrica para la mediación escrita. Igualmente se incorporarán o enlazarán subcarpetas con los archivos necesarios para las pruebas orales: monólogos, diálogos y mediaciones orales. \stopsection \stoptext
it seems to work with no protruding on https://context-on-web.eu could you confirm ?
buahhh, I'm on context-on-web too, but I get this protruding... I even tried to put something before the section (letter k in the pdf) to see if the reason was being the frame the first thing on the page, but persists... ...mmmm I can't atach my pdf! here the link https://drive.google.com/file/d/1pICcD3EY7q1CVP7Q5tJSDJzRTh-uorzj/view?usp=s... thanks for comparing...
madiazm.eoicc@gmail.com schrieb am 17.05.2024 um 00:05:
Hi, I used some code from the meta-fun manual to recreate a labelled frame around my sections. But the first framedtext protrudes a couple of mm into the margin. Only the first one in the page. I intentionaly added other sections and the frames aline to the margin ok. I tried to put something before the first frame (noindentation, dontleavehmode) because I sometimes read it solves problems, but not the case here. so Why is the first frame protruding and only the first?
[...]
Include only setups in your examples which are necessary to show the problem, the custom layout isn't necessary and can be left out.
\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 .25pt withcolor blue) ; draw (2o,h)--(0,h)--(0,0)--(w,0)--(w,h)--(xpart urcorner p,h) ; %draw boundingbox p ; %%%quitamos el frame pequeño setbounds currentpicture to unitsquare xyscaled(w,h) ; \stopuseMPgraphic
\defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}] \defineframedtext[FunnyText][width=.85\textwidth, height=20mm, frame=off, background=FunnyFrame, align=flushright,location=right, after={\blank[2*big]}]%foregroundsytel amplía la palabra Apartado
\def\FrameTitle#1% {\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut \color[blue]{\tfx Apartado #1}\hss}}}
\setMPtext{FunnyFrame}{} % initialize the text variable
\define[2]\firstHeadings{% \dontleavehmode \switchtobodyfont[miCorm] \FrameTitle#1%
\dontleavehmode \startFunnyText {\switchtobodyfont[miCorm,20.7pt] #2} \stopFunnyText }
\setuphead [section] [color=blue, command=\firstHeadings, indentnext=no]
Get rid of \dontleavehmode in your custom section layout, avoid blank lines in definitions and move the font changes to \setuphead. \define[2]\firstHeadings {\FrameTitle{#1}% \startFunnyText #2% \stopFunnyText} \setuphead [section] [color=blue, style={\switchtobodyfont[miCorm]}, textstyle={\switchtobodyfont[20.7pt]}, command=\firstHeadings, indentnext=no]
\startsection[title=Aspectos generales] Esta guía contiene toda la documentación necesaria para administrar la prueba unificada de certificación que ha diseñado la comisión de alemán. Se ruega al profesorado\footnote{Todas las alusiones a la forma del masculino genérico que se recogen en este documento deberán entenderse referidas a la condición masculina o femenina de cada persona según corresponda.} que se familiarice con las secciones del documento a través del índice y acuda a ellas según vaya siendo necesario, de manera que se pueda administrar y corregir la prueba de la manera más satisfactoria posible. \stopsection
Use dummy text when it possible to keep the example short and clean. \startsection[title=Aspectos generales] \samplefile{lorem} \stopsection Wolfgang
thanks Wolfgang for your advice and sorry for being so verbose, but since the margins are "included" in the problem I decided to put my layout there too. I made your suggested changes and unfortunately it doesnt work, but being a bit surprised by the margins I printed a copy of the page and.... still worse... It semms that the first frame is good aligned to the specified margin, and it is the rest of the text that gets more than 5mm extra space at the right margin and about 2 mm less in the left margin. I think the printer is a bit involved too, but since in the pdf we can see this protruding I think there must be something strange to get this outcome. The papers are for my fellows, so it is not critical if it stays so, but since I'm trying to learn a bit more to use context, it annoys me that I don't get to understand some problems... thanks again for taking time
I finally found showframe (so difficult to remember things...) to see and indeed the first frame is ignoring the margin-distance (apart from the issues of printed margins in paper, that I should persue too... page with frames: https://drive.google.com/file/d/1684nQRH_Cgm2P_5dW1JbODJjdscrj3tB/view?usp=s...
On 5/17/24 11:02, madiazm.eoicc@gmail.com wrote:
thanks Wolfgang for your advice and sorry for being so verbose, but since the margins are "included" in the problem I decided to put my layout there too.
I made your suggested changes and unfortunately it doesnt work, but being a bit surprised by the margins I printed a copy of the page and.... still worse... Hi Miguel,
this should work (also in the sense of a minimal sample): \showframe\showgrid \defineframedtext[FunnyText] [frame=on, align=flushright,location=right] \def\FrameTitle#1% {\setMPtext{FunnyFrame} {\hbox spread 1em{\hss\strut \color[blue]{\tfx Apartado #1}\hss}}} \define[2]\firstHeadings{% \dontleavehmode \switchtobodyfont[miCorm]% \FrameTitle#1% \startFunnyText {\switchtobodyfont[miCorm,20.7pt] #2} \stopFunnyText} \setuphead [section] [command=\firstHeadings, indentnext=no] \starttext \startsection[title=a] b \stopsection \startsection[title=a] b \stopsection \startsection[title=a] b \stopsection \stoptext BTW, you inadvertely introduce the space here: \define[2]\firstHeadings{% \dontleavehmode \switchtobodyfont[miCorm]% \FrameTitle#1% Unless you comment the space after the right bracket, it will be included in your definition of first headings. As for external downloads, better avoid unless required. In any case, the minimal code should be part of your message. Just in case it helps, Pablo
thanks Pablo, but this is strange If I reproduce your code in a new file I see the perfect alignment of the frames. But I had changed the code in my original file as suggested by Wolfgang and I additionally commented all lines in the "firstHeadings" definitions following your advice and after compiling... the same result. The strange thing is that it is only the first section that protrudes, the other sections are right (as seen in the link). Therefore it must not be the code definition, since in that case all sections should protrude... Over the weekend I will slowly move my code to a new file with your code adding a bit everytime to try to spot the moment when I get this strange behaviour and then I will write again. ps. I included the link because there is no attach option here in the online-mailing-list. Sorry if it not ok. thanks
here again... incredibly the protruding comes after creating the second script. If I only use the libertinus fonts every thing is ok. the code definitions don't find the cormorant font and use libertinus. But after adding the second typescript and compiling... there comes the protruding of the first frame!! I deleted all spaces in the definitions for the case, but no. Definitively I can't get it right and I don't find a logical explanation. here is the last part of my script (the prior definitions are not problematic, since they worked when only using "miFuente". It seems to be something in "miCorm" that produces the protruding \starttypescript[miFuente] \definetypeface [miFuente] [rm] [serif] [libertinus] [default] \definetypeface [miFuente] [ss] [sans] [libertinussans] [default] \definetypeface [miFuente] [tt] [mono] [libertinusmono] [default] \stoptypescript \starttypescript[miCorm] \definetypeface[miCorm][rm][serif][cormorant][default] \stoptypescript
On 5/17/24 20:46, madiazm.eoicc@gmail.com wrote:
[...] here is the last part of my script (the prior definitions are not problematic, since they worked when only using "miFuente". It seems to be something in "miCorm" that produces the protruding
Just a comment about typescripts. At least in how I use ConTeXt, I live happily without having to use them. See the following sample: \definefontfamily[libertin][rm][Libertinus Serif] \definefontfamily[libertin][ss][Libertinus Sans] \definefontfamily[libertin][tt][Libertinus Mono] \definefontfamily[cormora][rm][Cormorant] \setupbodyfont[cormora] \starttext \input zapf\par \switchtobodyfont[libertin] \doloopoverlist{\rm,\ss,\tt} {\recursestring\input zapf\par} \stoptext You may define font families (which are actually typeface families). I think they may be easier to use than typefaces. Just in case it might help, Pablo
On 5/17/2024 8:22 PM, madiazm.eoicc@gmail.com wrote:
thanks Pablo, but this is strange
If I reproduce your code in a new file I see the perfect alignment of the frames. But I had changed the code in my original file as suggested by Wolfgang and I additionally commented all lines in the "firstHeadings" definitions following your advice and after compiling... the same result.
The strange thing is that it is only the first section that protrudes, the other sections are right (as seen in the link). Therefore it must not be the code definition, since in that case all sections should protrude...
Over the weekend I will slowly move my code to a new file with your code adding a bit everytime to try to spot the moment when I get this strange behaviour and then I will write again.
ps. I included the link because there is no attach option here in the online-mailing-list. Sorry if it not ok. thanks if you do something \switchtobodyfont without ever having loaded it (before starttext) spaces can creep in depending on what files are loaded for that font
also, in order to avoid grouping issues / side effects you can do this before \starttext: \usebodyfont[foo] when you use multiple bodyfont sets Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
yeeessss that's it. adding the command after the scripts solved the protruding. thanks to all of you who took time to look into the thing... and to you Hans. It would be imposible that I had thought of this as the source of my problem!!!
On 5/17/24 20:22, madiazm.eoicc@gmail.com wrote:
thanks Pablo, but this is strange [...] The strange thing is that it is only the first section that protrudes, the other sections are right (as seen in the link). Therefore it must not be the code definition, since in that case all sections should protrude... It might be a buggy code definition, but it may be only triggered by (yet unknown) special conditions.
Over the weekend I will slowly move my code to a new file with your code adding a bit everytime to try to spot the moment when I get this strange behaviour and then I will write again.
I hope you have already solved the issue, but I’m afraid this is the way testing for new bugs introduced in code works.
ps. I included the link because there is no attach option here in the online-mailing-list. Sorry if it not ok. Sorry, I no Google fan. But it is essential to provide problematic code (reduced to a minimal sample) in the messages to the list, not just the output.
Having the sample code, others can confirm that they are able to reproduce your issue. It wouldn’t be the first time for issues only arising in only on a single installation, on a single computer or on a single OS. The mailing list (at least when sending from a real email address) allows attachments up to 100kb. This may be enough for most minimal samples. I hope it helps, Pablo
participants (5)
-
garulfo@azules.eu
-
Hans Hagen
-
madiazm.eoicc@gmail.com
-
Pablo Rodriguez
-
Wolfgang Schuster