Is there a bug during pagination of external figures?
Hi all! Processing a large document containing the following lines:
>>>>start \externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_1.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_2.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_3.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_4.png]
<<<<<<<<<<
>>>>start \externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_1.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_2.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_3.png]
\page
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_4.png]
<<<<<<<<<<
Stefan Wachter wrote:
Processing a large document containing the following lines:
>>>>>start \externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_1.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_2.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_3.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_4.png]
<<<<<<<<<<
is for some reason the _ an active character ? In supp-fil you may try the following (add the \_ definition) \bgroup \catcode`\/=\@@active \catcode`\:=\@@active \catcode`\~=\@@active \catcode`\_=\@@active \gdef\sanitizefilename#1\to#2% {\bgroup \edef/{\string/}% \edef:{\string:}% \edef~{\string~}% \edef_{\string_}% \expanded{\xdef\noexpand\sanitizedfilename{#1}}% \egroup % maybe \convertcommand\sanitizedfilename\to#2% \let#2\sanitizedfilename} \egroup untested -) Hans
Hans Hagen wrote:
Stefan Wachter wrote:
Processing a large document containing the following lines:
>>>>>>start \externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_1.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_2.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_3.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_4.png]
<<<<<<<<<<
is for some reason the _ an active character ?
In supp-fil you may try the following (add the \_ definition)
\bgroup
\catcode`\/=\@@active \catcode`\:=\@@active \catcode`\~=\@@active \catcode`\_=\@@active
\gdef\sanitizefilename#1\to#2% {\bgroup \edef/{\string/}% \edef:{\string:}% \edef~{\string~}% \edef_{\string_}% \expanded{\xdef\noexpand\sanitizedfilename{#1}}% \egroup % maybe \convertcommand\sanitizedfilename\to#2% \let#2\sanitizedfilename}
\egroup
untested -)
Hans Hi Hans,
thanks for the quick reply. I made the proposed changes in the supp-fil.tex file. Unfortunately the reported error is still there. I also executed "texexec --make ..." and tried again. But it did not help. Do you have another idea to solve the problem? Thanks, --Stefan
Hans Hagen wrote:
Stefan Wachter wrote:
Processing a large document containing the following lines:
>>>>>>start \externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_1.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_2.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_3.png]
\externalfigure[/home/swachter/projekte/infotakt/vdp/export/bu/bu.ilboo/ziffer8.ilboo/bu8-3_refkom.ilboo/graphics.ilfdr/bu8-3_241-242_4.png]
<<<<<<<<<<
is for some reason the _ an active character ?
In supp-fil you may try the following (add the \_ definition)
\bgroup
\catcode`\/=\@@active \catcode`\:=\@@active \catcode`\~=\@@active \catcode`\_=\@@active
\gdef\sanitizefilename#1\to#2% {\bgroup \edef/{\string/}% \edef:{\string:}% \edef~{\string~}% \edef_{\string_}% \expanded{\xdef\noexpand\sanitizedfilename{#1}}% \egroup % maybe \convertcommand\sanitizedfilename\to#2% \let#2\sanitizedfilename}
\egroup
untested -)
Hans Hi Hans,
thanks for the quick reply. I made the proposed changes but the error is still there. (I also run "texexec --make ..." and tried again.) Do you have another idea that could solve the problem? Thanks, --Stefan
Stefan Wachter wrote:
thanks for the quick reply. I made the proposed changes but the error is still there. (I also run "texexec --make ..." and tried again.)
Do you have another idea that could solve the problem?
can you make a small example file? looks like some strange interference with _ being active (Normally not the case); is some module loaded? 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 -----------------------------------------------------------------
Stefan Wachter wrote: Could you make a minimal example that fails? \starttext \externalfigure[x_x.png] \stoptext works ok here, so there must be something else interfering 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 -----------------------------------------------------------------
Hi Hans, I attach an example Context file and the included graphics. Unfortunately the example is by far not minimal. Can you look at the example anyway? If the length of the example causes problems then I may try to prune it. --Stefan Hans Hagen wrote:
Stefan Wachter wrote:
Could you make a minimal example that fails?
\starttext \externalfigure[x_x.png] \stoptext
works ok here, so there must be something else interfering
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 -----------------------------------------------------------------
Stefan Wachter
Hi Hans,
I attach an example Context file and the included graphics. Unfortunately the example is by far not minimal.
The file is just a few bytes, no need to mention... Just looking at the error message, I bet your problem is at: \setupheadertexts[text][{\tfc 8}{\tfb-3\_refkom}][] \setupheadertexts[margin][{\tfc bu}][\ifnum\pageno = 1\NamedExternalLink{../../../../bu/8/8_3_refkom/1/inhalt.pdf}{last}{\symbol[PfeilNachLinks]{} §}\else\PrevOrNextPage{/PrevPage}{\symbol[PfeilNachLinks]{} §}\fi\hskip.5em\ifnum\pageno = \lastpage{§ \symbol[PfeilNachRechts]}\else\PrevOrNextPage{/NextPage}{§ \symbol[PfeilNachRechts]}\fi] Patrick -- ConTeXt wiki: http://contextgarden.net texshow-web: http://texshow.contextgarden.net List archive: http://archive.contextgarden.net
Patrick Gundlach wrote:
Stefan Wachter
writes: Hi Hans,
I attach an example Context file and the included graphics. Unfortunately the example is by far not minimal.
The file is just a few bytes, no need to mention...
Just looking at the error message, I bet your problem is at:
\setupheadertexts[text][{\tfc 8}{\tfb-3\_refkom}][] \setupheadertexts[margin][{\tfc bu}][\ifnum\pageno = 1\NamedExternalLink{../../../../bu/8/8_3_refkom/1/inhalt.pdf}{last}{\symbol[PfeilNachLinks]{} §}\else\PrevOrNextPage{/PrevPage}{\symbol[PfeilNachLinks]{} §}\fi\hskip.5em\ifnum\pageno = \lastpage{§ \symbol[PfeilNachRechts]}\else\PrevOrNextPage{/NextPage}{§ \symbol[PfeilNachRechts]}\fi]
Patrick Hi Patrick,
i do not think that the problem is caused by the header texts. The same header text definition is used during all the document but the problem is encountered only at a page with several external figures. In addition, if I insert a new page in between the figures then the problem disappears (cf. original bug report). --Stefan
\setupheadertexts[margin][{\tfc bu}][\ifnum\pageno = 1\NamedExternalLink{../../../../bu/8/8_3_refkom/1/inhalt.pdf}{last}{\symbol[PfeilNachLinks]{} §}\else\PrevOrNextPage{/PrevPage}{\symbol[PfeilNachLinks]{} §}\fi\hskip.5em\ifnum\pageno = \lastpage{§ \symbol[PfeilNachRechts]}\else\PrevOrNextPage{/NextPage}{§ \symbol[PfeilNachRechts]}\fi]
i do not think that the problem is caused by the header texts.
Well, but removing the header texts gives me a working pdf file. So it might be a strange interaction between the header text and figure names. You should definitely try to reduce the file size to a minimum, otherwise it is hard to track the problem down. Patrick -- ConTeXt wiki: http://contextgarden.net texshow-web: http://texshow.contextgarden.net List archive: http://archive.contextgarden.net
Hi Patrick, you are right. If I change the header text such that there is no underbar in there then the error disappears. I prunned the example to investigate the situation further. Now I have only two pages. If you "texexec" the file then you get the error. If you uncomment the \page command at the end then the error disappears. BUT NOW THE SITUATION REALLY BECOMES STRANGE! If you delete all *.png files except the one that is included by the \externalfigure command then the error also disappears! It seems that the behaviour of Context is influenced by the content of the directory! --Stefan
Hello Stefan,
I prunned the example to investigate the situation further. Now I have only two pages.
Well, how do you think anybody should be able to debug what you have done with all the stuff in your document?
You should definitely try to reduce the file size to a minimum, otherwise it is hard to track the problem down.
minimum is far from 150 kb. And please avoid external figures if possible (there is cow.pdf hacker.jpg and mill.png for download, so we can all have the same figures to experiment with). Please do your homework yourself next time: -------------------------------------------------- \setupoutput[pdftex] \usetypescript[adobekb][texnansi] \usetypescript[postscript][texnansi] \setupbodyfont[postscript,ss,13pt] \setupheadertexts[text][\_][] \starttext \dorecurse{10}{\input tufte \par} \externalfigure[cow][scale=1424] \externalfigure[cow][scale=1424] \stoptext -------------------------------------------------- Is the minimal test file I've come up with. Perhaps now it is easier for Hans to track down the problem. The error message is: ---------------------------------------- ! Missing $ inserted. <inserted text> $ <to be read again> _ \_...fmmode \mathunderscore \else \textunderscore \fi <argument> \_ {}{}{} \firstoftwoarguments #1#2->#1 \doattributes ...sname #1#2\@EA \endcsname \fi {#4 }\dostopattributes ... l.15 -------------------------------------------------- btw: with the error related to other files in the directory: did you run texutil --purgeall for testing? Patrick -- ConTeXt wiki: http://contextgarden.net texshow-web: http://texshow.contextgarden.net List archive: http://archive.contextgarden.net
Patrick Gundlach wrote:
minimum is far from 150 kb. And please avoid external figures if possible (there is cow.pdf hacker.jpg and mill.png for download, so we can all have the same figures to experiment with).
nice.. where are them? Maybe it'd be nice to have them in tex/context/sample
Eros Albertazzi wrote:
Patrick Gundlach wrote:
minimum is far from 150 kb. And please avoid external figures if possible (there is cow.pdf hacker.jpg and mill.png for download, so we can all have the same figures to experiment with).
nice.. where are them? Maybe it'd be nice to have them in tex/context/sample
http://www.pragma-ade.com/context/cont-img.zip ----------------------------------------------------------------- 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 -----------------------------------------------------------------
Hi Patrick, first I want to say that I already spent several hours on that problem and was happy to reduce the file size to 5215 Bytes. Of course I could have done further but I thought that the file is now handy enough for debugging. (I do not know how TeX code is debugged and what tools are available for that task.)
btw: with the error related to other files in the directory: did you run texutil --purgeall for testing?
Yes, I removed all temporary files. But the strange behaviour remains: when all images except that of the used external figure are removed then the error disappears. --Stefan Patrick Gundlach wrote:
Hello Stefan,
I prunned the example to investigate the situation further. Now I have only two pages.
Well, how do you think anybody should be able to debug what you have done with all the stuff in your document?
You should definitely try to reduce the file size to a minimum, otherwise it is hard to track the problem down.
minimum is far from 150 kb. And please avoid external figures if possible (there is cow.pdf hacker.jpg and mill.png for download, so we can all have the same figures to experiment with).
Please do your homework yourself next time:
-------------------------------------------------- \setupoutput[pdftex]
\usetypescript[adobekb][texnansi] \usetypescript[postscript][texnansi] \setupbodyfont[postscript,ss,13pt]
\setupheadertexts[text][\_][]
\starttext \dorecurse{10}{\input tufte \par}
\externalfigure[cow][scale=1424]
\externalfigure[cow][scale=1424]
\stoptext --------------------------------------------------
Is the minimal test file I've come up with. Perhaps now it is easier for Hans to track down the problem. The error message is:
---------------------------------------- ! Missing $ inserted. <inserted text> $ <to be read again> _ \_...fmmode \mathunderscore \else \textunderscore \fi <argument> \_ {}{}{} \firstoftwoarguments #1#2->#1
\doattributes ...sname #1#2\@EA \endcsname \fi {#4 }\dostopattributes ... l.15
--------------------------------------------------
btw: with the error related to other files in the directory: did you run texutil --purgeall for testing?
Patrick
Hi, [...]
(I do not know how TeX code is debugged and what tools are available for that task.)
There are no tools for problems like yours. So it is very important to have a minimum (non-) working file file.
btw: with the error related to other files in the directory: did you run texutil --purgeall for testing?
Yes, I removed all temporary files. But the strange behaviour remains: when all images except that of the used external figure are removed then the error disappears.
This is strange, I cannot reproduce the bug here. But let us wait to see if Hans has anything to say about the error file. Patrick -- ConTeXt wiki: http://contextgarden.net texshow-web: http://texshow.contextgarden.net List archive: http://archive.contextgarden.net
Patrick Gundlach wrote:
-------------------------------------------------- \setupoutput[pdftex]
\usetypescript[adobekb][texnansi] \usetypescript[postscript][texnansi] \setupbodyfont[postscript,ss,13pt]
\setupheadertexts[text][\_][]
\starttext \dorecurse{10}{\input tufte \par}
\externalfigure[cow][scale=1424]
\externalfigure[cow][scale=1424]
\stoptext --------------------------------------------------
This file processes ok here; also, your bug is not so much related to headers but more to some kind of \_ expansion In what path are your graphics? 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 -----------------------------------------------------------------
Hello,
-------------------------------------------------- \setupoutput[pdftex]
\usetypescript[adobekb][texnansi] \usetypescript[postscript][texnansi] \setupbodyfont[postscript,ss,13pt]
\setupheadertexts[text][\_][]
\starttext \dorecurse{10}{\input tufte \par}
\externalfigure[cow][scale=1424]
\externalfigure[cow][scale=1424]
\stoptext --------------------------------------------------
This file processes ok here; also, your bug is not so much related to headers but more to some kind of \_ expansion In what path are your graphics?
it breaks on 2004.8.14 as well on live.contextgarden.net Graphics (cow.pdf) is in /opt/local/texmf/tex/context/sample If the two graphics are not on the same page, the error dissapears. The reproduction of the error is very sensitive to layout changes. Patrick -- ConTeXt wiki: http://contextgarden.net texshow-web: http://texshow.contextgarden.net List archive: http://archive.contextgarden.net
Patrick Gundlach wrote:
Hello,
-------------------------------------------------- \setupoutput[pdftex]
\usetypescript[adobekb][texnansi] \usetypescript[postscript][texnansi] \setupbodyfont[postscript,ss,13pt]
\setupheadertexts[text][\_][]
\starttext \dorecurse{10}{\input tufte \par}
\externalfigure[cow][scale=1424]
\externalfigure[cow][scale=1424]
\stoptext --------------------------------------------------
This file processes ok here; also, your bug is not so much related to headers but more to some kind of \_ expansion In what path are your graphics?
it breaks on 2004.8.14 as well on live.contextgarden.net
Graphics (cow.pdf) is in /opt/local/texmf/tex/context/sample
If the two graphics are not on the same page, the error dissapears. The reproduction of the error is very sensitive to layout changes.
the problem occurs in the output routine (when the page is built); some tracing all learns that while flushing the fig box takes place, the meaning of textunderscore is changed; so we need to restore this before hand; actually this problem should be solved differently, i.e. no redefinition at all; the problem is that findinf good solutions is not that easy because of "moments of expansion" fix (in core-fig.tex:) \def\dodoplaceexternalfigure[#1][#2][#3][#4][#5][#6]% {\doifsomething{#3}% catches \defineexternalfigure dummies {\bgroup \pushmacro\textunderscore \edef\textunderscore{\string_}% brrr, temp hack, still needed? \calculateexternalfigure[#1][#2][#3][#4][#5][#6]% \calculateexternalscreenfigure[#1][#2][#3][#4][#5][#6]% \popmacro\textunderscore \box\foundexternalfigure \egroup}} ----------------------------------------------------------------- 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 -----------------------------------------------------------------
Hello Hans, [...]
fix (in core-fig.tex:)
solves the problem here. Patrick -- ConTeXt wiki: http://contextgarden.net texshow-web: http://texshow.contextgarden.net List archive: http://archive.contextgarden.net
Hi Hans, thanks for your fix. It solves the problem. Will this fix be included in future Context releases? I am still confused why the content of the document directory had an impact on the output routine. (The problem disappeared after I had removed additional *.png files in the document directory. When I copied the superflous images into there again the problem reappeard.) I accept that computing in general and Context in special is kind of an empirical secret science. ;-) Thanks again, --Stefan
Stefan Wachter wrote:
I am still confused why the content of the document directory had an impact on the output routine. (The problem disappeared after I had removed additional *.png files in the document directory. When I copied the superflous images into there again the problem reappeard.) I accept that computing in general and Context in special is kind of an empirical secret science. ;-)
catcodes are -) ----------------------------------------------------------------- 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 -----------------------------------------------------------------
Stefan Wachter wrote:
thanks for your fix. It solves the problem. Will this fix be included in future Context releases?
it's in my source file so ... 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 -----------------------------------------------------------------
Patrick Gundlach wrote:
\setupheadertexts[margin][{\tfc bu}][\ifnum\pageno = 1\NamedExternalLink{../../../../bu/8/8_3_refkom/1/inhalt.pdf}{last}{\symbol[PfeilNachLinks]{} §}\else\PrevOrNextPage{/PrevPage}{\symbol[PfeilNachLinks]{} §}\fi\hskip.5em\ifnum\pageno = \lastpage{§ \symbol[PfeilNachRechts]}\else\PrevOrNextPage{/NextPage}{§ \symbol[PfeilNachRechts]}\fi]
why not use
\goto[PreviousPage]{\symbol[...]} \goto[NextPage]{\symbol...]} or \goto [forward]{\symbol[...] \goto [backward]{...} etc (firstpage, lastpage, nextpage, previouspage, etc) 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 -----------------------------------------------------------------
Hi Hans, thanks for the tip, --Stefan
why not use \goto[PreviousPage]{\symbol[...]} \goto[NextPage]{\symbol...]}
or \goto [forward]{\symbol[...] \goto [backward]{...}
etc (firstpage, lastpage, nextpage, previouspage, etc) Hans
Stefan Wachter wrote: a few tips: - your \AllowHyphens ... \AllowHyphens can be replaced by |-| (vertical bars); - 69\kern.1em\relax{}a Abs. 2 Nr. 6\blank[small] no need for {} here, just \relax followed by a space is enough - alternative for calculating your width: \def\determinecommalistwidth[#1]% {\scratchdimen\zeropoint \def\docommand##1% {\setbox\scratchbox\hbox{##1}% \ifdim\wd\scratchbox>\scratchdimen \scratchdimen\wd\scratchbox \fi}% \processcommalist[#1]\docommand} \determinecommalistwidth[a),b),c)] \the\scratchdimen (or use \charwd cum suis) 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 -----------------------------------------------------------------
Hi Hans, thanks for the additional hints. The width calculation method is very instructive. Yet, I think I can not use it, because I do not know in advance what kind of text is used as item labels. Maybe a label text contains already a comma. Is there another \processXXX-Makro for example \processampersandlist that can be used (because ampersands can not appear unescaped in normal text)? --Stefan PS: I found nowhere a description of \charwd
\def\determinecommalistwidth[#1]% {\scratchdimen\zeropoint \def\docommand##1% {\setbox\scratchbox\hbox{##1}% \ifdim\wd\scratchbox>\scratchdimen \scratchdimen\wd\scratchbox \fi}% \processcommalist[#1]\docommand}
\determinecommalistwidth[a),b),c)]
\the\scratchdimen
(or use \charwd cum suis)
Stefan Wachter wrote:
Hi Hans,
thanks for the additional hints. The width calculation method is very instructive. Yet, I think I can not use it, because I do not know in advance what kind of text is used as item labels. Maybe a label text contains already a comma. Is there another \processXXX-Makro for example \processampersandlist that can be used (because ampersands can not appear unescaped in normal text)?
--Stefan
PS: I found nowhere a description of \charwd
\def\determinecommalistwidth[#1]% {\scratchdimen\zeropoint \def\docommand##1% {\setbox\scratchbox\hbox{##1}% \ifdim\wd\scratchbox>\scratchdimen \scratchdimen\wd\scratchbox \fi}% \processcommalist[#1]\docommand}
\determinecommalistwidth[a),b),c)]
\the\scratchdimen
(or use \charwd cum suis)
\processseparatedlist may be of help of course you can do: \determine...[{a},{b\&c},{d\_e},{f,g,h}] 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 -----------------------------------------------------------------
it seems that metafun has difficulty understanding the example using the vardef self@# expr p = construct. ! Illegal parameter number in definition of \@MPG@dummy2. <to be read again> <argument> ... p of p enddef; \par vardef self@## expr p = cuta(@##,@##) @##... \dostartuseMPgraphic ...leuseMPgraphic {#1}{#2}{#3 }}\elabelgroup l.41 \stopuseMPgraphic why? i copied the sample of the mp manual: % interface=english output=pdftex \starttext \startuseMPgraphic{dummy2} vardef cuta(suffix a,b) expr p = drawarrow p cutbefore bpath.a cutafter bpath.b; point .5*length p of p enddef; vardef self@# expr p = cuta(@#,@#) @#.c{curl0}..@#.c+p..{curl0}@#.c enddef; beginfig(52); verbatimtex \def\stk#1#2{$\displaystyle{\matrix{#1\cr#2\cr}}$} etex circleit.aa(btex\strut Start etex); aa.dx=aa.dy; circleit.bb(btex \stk B{(a|b)^*a} etex); circleit.cc(btex \stk C{b^*} etex); circleit.dd(btex \stk D{(a|b)^*ab} etex); circleit.ee(btex\strut Stop etex); ee.dx=ee.dy; numeric hsep; bb.c-aa.c = dd.c-bb.c = ee.c-dd.c = (hsep,0); cc.c-bb.c = (0,.8hsep); xpart(ee.e - aa.w) = 3.8in; drawboxed(aa,bb,cc,dd,ee); label.ulft(btex$b$etex, cuta(aa,cc) aa.c{dir50}..cc.c); label.top(btex$b$etex, self.cc(0,30pt)); label.rt(btex$a$etex, cuta(cc,bb) cc.c..bb.c); label.top(btex$a$etex, cuta(aa,bb) aa.c..bb.c); label.llft(btex$a$etex, self.bb(-20pt,-35pt)); label.top(btex$b$etex, cuta(bb,dd) bb.c..dd.c); label.top(btex$b$etex, cuta(dd,ee) dd.c..ee.c); label.lrt(btex$a$etex, cuta(dd,bb) dd.c..{dir140}bb.c); label.bot(btex$a$etex, cuta(ee,bb) ee.c..tension1.3 ..{dir115}bb.c); label.urt(btex$b$etex, cuta(ee,cc) ee.c{(cc.c-ee.c)rotated-15}..cc.c); endfig; \stopuseMPgraphic \useMPgraphic{dummy2} \stoptext //floris
Floris van Manen wrote:
it seems that metafun has difficulty understanding the example using
no, it's tex playing tricks (# is kin dof special to tex)
the vardef self@# expr p = construct.
use \# instead 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 i define a path q := (w0,w0)--(w0,ww0)--(w2,ww1)--(w3,ww2)--(w3,w0)--cycle ; and then pass this path as a parameter to a function test( q ) ; then within that function i can step through the 'list of points'. def test( expr a ) = for i = 1 upto (length(a)-2): dotlabel.bot ("" , (point i of a) ); endfor ; enddef; but how could i extract from each point the X and the Y value to construct the lines like this. for i = 1 upto (length(a)-2): z1 = (point i of a) ; draw (0,y1)--(100,y1) ; endfor; thanks! % floris
Floris van Manen wrote:
if i define a path
q := (w0,w0)--(w0,ww0)--(w2,ww1)--(w3,ww2)--(w3,w0)--cycle ;
and then pass this path as a parameter to a function
test( q ) ;
then within that function i can step through the 'list of points'.
def test( expr a ) = for i = 1 upto (length(a)-2): dotlabel.bot ("" , (point i of a) ); endfor ; enddef;
but how could i extract from each point the X and the Y value to construct the lines like this.
for i = 1 upto (length(a)-2): z1 = (point i of a) ; draw (0,y1)--(100,y1) ; endfor;
xpart point i of a ; ypart point i of a ; 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 -----------------------------------------------------------------
participants (6)
-
Eros Albertazzi
-
Floris van Manen
-
Hans Hagen
-
Patrick Gundlach
-
Stefan Wachter
-
Stefan Wachter