Weird behavior about metafun
Hi Hans and Wolfgang, I'm just trying to make some illustrations about the Chinese typesetting features. So I choose the way which is described in Chapter 5 of the metafun manual. And I wanna draw a line from the text I wanna comment on to the marginal notes which my comments lay on. To highlight them, I drew an underline below the contexts which is to be commented and put a square around the comments. Everything is under control except I put \fpos and \tpos around the comments, the framed box is not exactly what I want. It seems that metafun still thought it's in the main text so it drew the bounding around the body. I found the mpos:par was defined in core-pgr.tex and it used show_par or draw_par which are defined in mp-core.mp. I don't think it's a good way to define another MPpositiongraphic called like mpos:marginpar to match my case. Do you think it's possible to change some of the core codes to make metafun recognize where she is. -- Best Regards Chen ---------------------------------------------------------------- Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn ----------------------------------------------------------------
Oh, by the way, if I put \fpos at the beginning of a paragraph,
it adds an extra blank line. I have to force it to the
horizontal mode like:
\leavevmode\fpos{A-1} . . . \tpos{A-1}
So is it safe to change the definition of \fpos to add
\leavevmode at the beginning of the macro?
On Jan 7, 2008 10:45 AM, Zhichu Chen
Hi Hans and Wolfgang,
I'm just trying to make some illustrations about the Chinese typesetting features. So I choose the way which is described in Chapter 5 of the metafun manual. And I wanna draw a line from the text I wanna comment on to the marginal notes which my comments lay on.
To highlight them, I drew an underline below the contexts which is to be commented and put a square around the comments. Everything is under control except I put \fpos and \tpos around the comments, the framed box is not exactly what I want. It seems that metafun still thought it's in the main text so it drew the bounding around the body.
I found the mpos:par was defined in core-pgr.tex and it used show_par or draw_par which are defined in mp-core.mp. I don't think it's a good way to define another MPpositiongraphic called like mpos:marginpar to match my case. Do you think it's possible to change some of the core codes to make metafun recognize where she is.
-- Best Regards Chen ----------------------------------------------------------------
Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn ----------------------------------------------------------------
-- Best Regards Chen ---------------------------------------------------------------- Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn ----------------------------------------------------------------
Zhichu Chen wrote:
Oh, by the way, if I put \fpos at the beginning of a paragraph, it adds an extra blank line. I have to force it to the horizontal mode like: \leavevmode\fpos{A-1} . . . \tpos{A-1}
\dontleavehmode \fpos ...
So is it safe to change the definition of \fpos to add \leavevmode at the beginning of the macro?
no, that could happen in the macro that uses \fpos, not in \fpos itself Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Jan 7, 2008 9:41 PM, Hans Hagen
Zhichu Chen wrote:
Oh, by the way, if I put \fpos at the beginning of a paragraph, it adds an extra blank line. I have to force it to the horizontal mode like: \leavevmode\fpos{A-1} . . . \tpos{A-1}
\dontleavehmode \fpos ...
So is it safe to change the definition of \fpos to add \leavevmode at the beginning of the macro?
no, that could happen in the macro that uses \fpos, not in \fpos itself
Cool, then I'll define my own macro to do that. Thanks.
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net
___________________________________________________________________________________
-- Best Regards Chen ---------------------------------------------------------------- Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn ----------------------------------------------------------------
On Mon, 7 Jan 2008, Zhichu Chen wrote:
Hi Hans and Wolfgang,
I'm just trying to make some illustrations about the Chinese typesetting features. So I choose the way which is described in Chapter 5 of the metafun manual. And I wanna draw a line from the text I wanna comment on to the marginal notes which my comments lay on.
Something like this: http://www.fauskes.net/media/pgftikzexamples/PDF/todo-notes.pdf It will be nice to have a ConTeXt module that can do this. Aditya
On Jan 7, 2008 11:52 PM, Aditya Mahajan
On Mon, 7 Jan 2008, Zhichu Chen wrote:
Hi Hans and Wolfgang,
I'm just trying to make some illustrations about the Chinese typesetting features. So I choose the way which is described in Chapter 5 of the metafun manual. And I wanna draw a line from the text I wanna comment on to the marginal notes which my comments lay on.
Something like this: http://www.fauskes.net/media/pgftikzexamples/PDF/todo-notes.pdf
Yes! That's what I'm trying to do. I think there's a chance to implement that with few modifications on the existing core-pgr.tex and mp-core.mp.
http://www.fauskes.net/media/pgftikzexamples/PDF/todo-notes.pdf
It will be nice to have a ConTeXt module that can do this.
Aditya
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net
___________________________________________________________________________________
-- Best Regards Chen ---------------------------------------------------------------- Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn ----------------------------------------------------------------
Hi,
On Jan 7, 2008 11:52 PM, Aditya Mahajan
Something like this: http://www.fauskes.net/media/pgftikzexamples/PDF/todo-notes.pdf
It will be nice to have a ConTeXt module that can do this.
I've made a test file which is somewhat like what it shows, but I still have many problems so it's far from perfect.
Aditya
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net
___________________________________________________________________________________
-- Best Regards Chen ---------------------------------------------------------------- Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn ----------------------------------------------------------------
Zhichu Chen wrote:
Hi,
On Jan 7, 2008 11:52 PM, Aditya Mahajan
wrote: Something like this: http://www.fauskes.net/media/pgftikzexamples/PDF/todo-notes.pdf
It will be nice to have a ConTeXt module that can do this.
I've made a test file which is somewhat like what it shows, but I still have many problems so it's far from perfect.
stacking is already present \setupcolors [state=start] \definecolor [marginback] [darkcyan] \startMPpositiongraphic{mypos:underline} initialize_box(\MPpos{\MPvar{self}}) ; path p ; p := (llxy--lrxy) shifted (0,dxy) ; pickup pencircle scaled 1pt ; draw p withcolor .75red ; anchor_box(\MPanchor{\MPvar{self}}) ; \stopMPpositiongraphic \startMPpositiongraphic{mypos:ulcorner} initialize_box(\MPpos{\MPvar{self}}) ; path p ; p := llxy--ulxy--urxy ; pickup pencircle scaled 1pt ; draw p withcolor .75red ; anchor_box(\MPanchor{\MPvar{self}}) ; \stopMPpositiongraphic \startMPpositiongraphic{mypos:torightmargin} path pa, pb, pab ; numeric na, nb ; pair bxya, lxyb ; initialize_box(\MPpos{\MPvar{from}}) ; na := nxy ; pa := (llxy--lrxy) shifted (0,dxy) ; bxya := (center pa) - (0 , \the\baselineskip/4) ; initialize_box(\MPpos{\MPvar{to}}) ; nb := nxy ; lxyb := .5[llxy , ulxy] - (\the\rightmargindistance/2 , 0) ; pb := llxy--ulxy ; if na=nb : pab := center pa -- bxya -- (xpart lxyb , ypart bxya) -- lxyb -- center pb; pickup pencircle scaled 1pt ; draw pab withcolor transparent(1,.5,.625yellow) ; anchor_box(\MPanchor{\MPvar{from}}) ; fi ; \stopMPpositiongraphic \defineoverlay [margingraphics] [\positionoverlay{margingraphics}] \setupbackgrounds [page] [background=margingraphics] \starttext \setupinmargin[stack=yes] \defineframedtext [marginframe] [background=color, % backgroundcolor=marginback, offset=.25ex, frame=off, width=\the\rightmarginwidth, foregroundstyle=\bfx] \def\marginstuff#1#2% {\doglobal\increment\currentmarginstuff \startpositionoverlay{margingraphics}% % can be drawn in one graphic which is more efficient \setMPpositiongraphic{mstuff:t\currentmarginstuff}{mypos:underline}% \setMPpositiongraphic{mstuff:m\currentmarginstuff}{mypos:ulcorner}% \expanded{\setMPpositiongraphic{mstuff:t\currentmarginstuff}{mypos:torightmargin}{to=mstuff:m\currentmarginstuff}}% \stoppositionoverlay \hpos{mstuff:t\currentmarginstuff}{#1}\inright{\hpos{mstuff:m\currentmarginstuff}{\marginframe{#2}}}} First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do. The previous paragraph was typeset by saying: First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do. The previous paragraph was typeset by saying: First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do. The previous paragraph was typeset by saying: First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do. The previous paragraph was typeset by saying: \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Pretty cool! I knew ConTeXt can do it and thank you Hans
for teaching me so much.
Hi Arthur, I'm suffering a network problem so sometimes
mails may no be delivered correctly. But ignore my test
file and get Hans' one.
On Jan 9, 2008 1:04 AM, Hans Hagen
Zhichu Chen wrote:
Hi,
On Jan 7, 2008 11:52 PM, Aditya Mahajan
wrote: Something like this: http://www.fauskes.net/media/pgftikzexamples/PDF/todo-notes.pdf
It will be nice to have a ConTeXt module that can do this.
I've made a test file which is somewhat like what it shows, but I still have many problems so it's far from perfect.
stacking is already present
\setupcolors [state=start] \definecolor [marginback] [darkcyan]
\startMPpositiongraphic{mypos:underline} initialize_box(\MPpos{\MPvar{self}}) ; path p ; p := (llxy--lrxy) shifted (0,dxy) ; pickup pencircle scaled 1pt ; draw p withcolor .75red ; anchor_box(\MPanchor{\MPvar{self}}) ; \stopMPpositiongraphic
\startMPpositiongraphic{mypos:ulcorner} initialize_box(\MPpos{\MPvar{self}}) ; path p ; p := llxy--ulxy--urxy ; pickup pencircle scaled 1pt ; draw p withcolor .75red ; anchor_box(\MPanchor{\MPvar{self}}) ; \stopMPpositiongraphic
\startMPpositiongraphic{mypos:torightmargin} path pa, pb, pab ; numeric na, nb ; pair bxya, lxyb ; initialize_box(\MPpos{\MPvar{from}}) ; na := nxy ; pa := (llxy--lrxy) shifted (0,dxy) ; bxya := (center pa) - (0 , \the\baselineskip/4) ; initialize_box(\MPpos{\MPvar{to}}) ; nb := nxy ; lxyb := .5[llxy , ulxy] - (\the\rightmargindistance/2 , 0) ; pb := llxy--ulxy ; if na=nb : pab := center pa -- bxya -- (xpart lxyb , ypart bxya) -- lxyb -- center pb; pickup pencircle scaled 1pt ; draw pab withcolor transparent(1,.5,.625yellow) ; anchor_box(\MPanchor{\MPvar{from}}) ; fi ; \stopMPpositiongraphic
\defineoverlay [margingraphics] [\positionoverlay{margingraphics}]
\setupbackgrounds [page] [background=margingraphics]
\starttext
\setupinmargin[stack=yes]
\defineframedtext [marginframe] [background=color, % backgroundcolor=marginback, offset=.25ex, frame=off, width=\the\rightmarginwidth, foregroundstyle=\bfx]
\def\marginstuff#1#2% {\doglobal\increment\currentmarginstuff \startpositionoverlay{margingraphics}% % can be drawn in one graphic which is more efficient \setMPpositiongraphic{mstuff:t\currentmarginstuff}{mypos:underline}% \setMPpositiongraphic{mstuff:m\currentmarginstuff}{mypos:ulcorner}%
\expanded{\setMPpositiongraphic{mstuff:t\currentmarginstuff}{mypos:torightmargin}{to=mstuff:m\currentmarginstuff}}% \stoppositionoverlay
\hpos{mstuff:t\currentmarginstuff}{#1}\inright{\hpos{mstuff:m\currentmarginstuff}{\marginframe{#2}}}}
First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do. The previous paragraph was typeset by saying:
First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do. The previous paragraph was typeset by saying:
First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do.
The previous paragraph was typeset by saying: First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do. The previous paragraph was typeset by saying:
\stoptext
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net
___________________________________________________________________________________
-- Best Regards Chen ---------------------------------------------------------------- Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn ----------------------------------------------------------------
On Jan 8, 2008 6:04 PM, Hans Hagen
Zhichu Chen wrote:
Hi,
On Jan 7, 2008 11:52 PM, Aditya Mahajan
wrote: Something like this: http://www.fauskes.net/media/pgftikzexamples/PDF/todo-notes.pdf
It will be nice to have a ConTeXt module that can do this.
I've made a test file which is somewhat like what it shows, but I still have many problems so it's far from perfect.
stacking is already present
\setupcolors [state=start] \definecolor [marginback] [darkcyan]
\startMPpositiongraphic{mypos:underline} initialize_box(\MPpos{\MPvar{self}}) ; path p ; p := (llxy--lrxy) shifted (0,dxy) ; pickup pencircle scaled 1pt ; draw p withcolor .75red ; anchor_box(\MPanchor{\MPvar{self}}) ; \stopMPpositiongraphic
\startMPpositiongraphic{mypos:ulcorner} initialize_box(\MPpos{\MPvar{self}}) ; path p ; p := llxy--ulxy--urxy ; pickup pencircle scaled 1pt ; draw p withcolor .75red ; anchor_box(\MPanchor{\MPvar{self}}) ; \stopMPpositiongraphic
\startMPpositiongraphic{mypos:torightmargin} path pa, pb, pab ; numeric na, nb ; pair bxya, lxyb ; initialize_box(\MPpos{\MPvar{from}}) ; na := nxy ; pa := (llxy--lrxy) shifted (0,dxy) ; bxya := (center pa) - (0 , \the\baselineskip/4) ; initialize_box(\MPpos{\MPvar{to}}) ; nb := nxy ; lxyb := .5[llxy , ulxy] - (\the\rightmargindistance/2 , 0) ; pb := llxy--ulxy ; if na=nb : pab := center pa -- bxya -- (xpart lxyb , ypart bxya) -- lxyb -- center pb; pickup pencircle scaled 1pt ; draw pab withcolor transparent(1,.5,.625yellow) ; anchor_box(\MPanchor{\MPvar{from}}) ; fi ; \stopMPpositiongraphic
\defineoverlay [margingraphics] [\positionoverlay{margingraphics}]
\setupbackgrounds [page] [background=margingraphics]
\starttext
\setupinmargin[stack=yes]
\defineframedtext [marginframe] [background=color, % backgroundcolor=marginback, offset=.25ex, frame=off, width=\the\rightmarginwidth, foregroundstyle=\bfx]
\def\marginstuff#1#2% {\doglobal\increment\currentmarginstuff \startpositionoverlay{margingraphics}% % can be drawn in one graphic which is more efficient \setMPpositiongraphic{mstuff:t\currentmarginstuff}{mypos:underline}% \setMPpositiongraphic{mstuff:m\currentmarginstuff}{mypos:ulcorner}%
\expanded{\setMPpositiongraphic{mstuff:t\currentmarginstuff}{mypos:torightmargin}{to=mstuff:m\currentmarginstuff}}% \stoppositionoverlay
\hpos{mstuff:t\currentmarginstuff}{#1}\inright{\hpos{mstuff:m\currentmarginstuff}{\marginframe{#2}}}}
First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do. The previous paragraph was typeset by saying:
First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do. The previous paragraph was typeset by saying:
First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do.
The previous paragraph was typeset by saying: First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. First we have defined an \marginstuff {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do. The previous paragraph was typeset by saying:
\stoptext
Hi Hans, could you wrap this into a macro to define different commands for marginstuff, could be usefull to write margintexts for more users in different colors etc. For example: \definecomment[chen][color=blue,frame=on|off,...] \definecomment[hans][color=red,frame=on|off,...] \starttext The previous paragraph was typeset by saying: First we have defined an \chen {overlay} {Just a test in a margin that could be multiple lines.}. First we have defined an \hans {overlay} {Just a test in a margin that could be multiple lines.}. This overlay can be attached to some overlay layer, like, in our case, the page. We define four small circles. These are drawn as soon as the page overlay is typeset. Because they are located in the background, they don't cover the text, while the lines do. \stoptext Wolfgang
participants (5)
-
Aditya Mahajan
-
Arthur Reutenauer
-
Hans Hagen
-
Wolfgang Schuster
-
Zhichu Chen