MetaPost backgrounds
Hi everybody! I had some problems with backgrounds in a table. I wanted just a horizontal line, but in different heights. The problem is that the line will always be in the middle of the cell if I don't add more graphics. See the example file below. Regards, Micke P \setupoutput[pdftex] \enableregime[utf] \setupbodyfont[7pt] % This works, but is not nice. \startuniqueMPgraphic{splittop} draw (0,0)--(OverlayWidth,OverlayHeight) withcolor white;%should not be necessary draw (0,0.725*OverlayHeight)--(OverlayWidth,0.725*OverlayHeight); \stopuniqueMPgraphic \defineoverlay[splittop][\uniqueMPgraphic{splittop}] \startuniqueMPgraphic{splitmid} draw (0,0)--(OverlayWidth,OverlayHeight) withcolor white;%should not be necessary draw (0,0.5*OverlayHeight)--(OverlayWidth,0.5*OverlayHeight); \stopuniqueMPgraphic \defineoverlay[splitmid][\uniqueMPgraphic{splitmid}] % This does not work, but I think it should \startuniqueMPgraphic{topsplit} draw (0,0.725*OverlayHeight)--(OverlayWidth,0.725*OverlayHeight); \stopuniqueMPgraphic \defineoverlay[topsplit][\uniqueMPgraphic{topsplit}] \startuniqueMPgraphic{midsplit} draw (0,0.5*OverlayHeight)--(OverlayWidth,0.5*OverlayHeight); \stopuniqueMPgraphic \defineoverlay[midsplit][\uniqueMPgraphic{midsplit}] \starttext % A working table \setupTABLE[width=2cm,height=2cm] \bTABLE[align={middle,lohi}] \bTR\bTD[background=splittop] Some text\par And some more text that will apear below the other text\eTD\bTD[background=splitmid] Some text above\par Some text below \eTD\eTR \eTABLE % A non-working table \setupTABLE[width=2cm,height=2cm] \bTABLE[align={middle,lohi}] \bTR\bTD[background=topsplit] Some text\par And some more text that will apear below the other text\eTD\bTD[background=midsplit] Some text above\par Some text below \eTD\eTR \eTABLE \stoptext
Micke, What is your definition of "works?" At this end, the code compiled fine and did just what you asked, at least as far as I can see. I formatted your code a bit and entered a "big blank" between tables and compiled this: \runMPgraphicstrue \setupoutput[pdftex] \enableregime[utf] \setupbodyfont[7pt] % This works, but is not nice. \startuniqueMPgraphic{splittop} draw (0,0)--(OverlayWidth,OverlayHeight) withcolor white;%should not be necessary draw (0,0.725*OverlayHeight)--(OverlayWidth,0.725*OverlayHeight); \stopuniqueMPgraphic \defineoverlay[splittop][\uniqueMPgraphic{splittop}] \startuniqueMPgraphic{splitmid} draw (0,0)--(OverlayWidth,OverlayHeight) withcolor white;%should not be necessary draw (0,0.5*OverlayHeight)--(OverlayWidth,0.5*OverlayHeight); \stopuniqueMPgraphic \defineoverlay[splitmid][\uniqueMPgraphic{splitmid}] % This does not work, but I think it should \startuniqueMPgraphic{topsplit} draw (0,0.725*OverlayHeight)--(OverlayWidth,0.725*OverlayHeight); \stopuniqueMPgraphic \defineoverlay[topsplit][\uniqueMPgraphic{topsplit}] \startuniqueMPgraphic{midsplit} draw (0,0.5*OverlayHeight)--(OverlayWidth,0.5*OverlayHeight); \stopuniqueMPgraphic \defineoverlay[midsplit][\uniqueMPgraphic{midsplit}] \starttext % A working table \setupTABLE[width=2cm,height=2cm] \bTABLE[align={middle,lohi}] \bTR\bTD[background=splittop] Some text\par And some more text that will apear below the other text\eTD\bTD[background=splitmid] Some text above\par Some text below \eTD\eTR \eTABLE \blank[big] % A non-working table \setupTABLE[width=2cm,height=2cm] \bTABLE[align={middle,lohi}] \bTR\bTD[background=topsplit] Some text\par And some more text that will apear below the other text\eTD\bTD[background=midsplit] Some text above\par Some text below \eTD\eTR \eTABLE \stoptext Result is attached. However, this is a problem that would seem to be best attacked by learning a bit more about tables. At 09:30 AM 8/10/03 +0200, you wrote:
Hi everybody!
I had some problems with backgrounds in a table. I wanted just a horizontal line, but in different heights. The problem is that the line will always be in the middle of the cell if I don't add more graphics. See the example file below.
Regards, Micke P
\setupoutput[pdftex] \enableregime[utf] \setupbodyfont[7pt]
% This works, but is not nice.
\startuniqueMPgraphic{splittop} draw (0,0)--(OverlayWidth,OverlayHeight) withcolor white;%should not be necessary draw (0,0.725*OverlayHeight)--(OverlayWidth,0.725*OverlayHeight); \stopuniqueMPgraphic \defineoverlay[splittop][\uniqueMPgraphic{splittop}]
\startuniqueMPgraphic{splitmid} draw (0,0)--(OverlayWidth,OverlayHeight) withcolor white;%should not be necessary draw (0,0.5*OverlayHeight)--(OverlayWidth,0.5*OverlayHeight); \stopuniqueMPgraphic \defineoverlay[splitmid][\uniqueMPgraphic{splitmid}]
% This does not work, but I think it should
\startuniqueMPgraphic{topsplit} draw (0,0.725*OverlayHeight)--(OverlayWidth,0.725*OverlayHeight); \stopuniqueMPgraphic \defineoverlay[topsplit][\uniqueMPgraphic{topsplit}]
\startuniqueMPgraphic{midsplit} draw (0,0.5*OverlayHeight)--(OverlayWidth,0.5*OverlayHeight); \stopuniqueMPgraphic \defineoverlay[midsplit][\uniqueMPgraphic{midsplit}]
\starttext
% A working table \setupTABLE[width=2cm,height=2cm] \bTABLE[align={middle,lohi}] \bTR\bTD[background=splittop] Some text\par And some more text that will apear below the other text\eTD\bTD[background=splitmid] Some text above\par Some text below \eTD\eTR \eTABLE
% A non-working table \setupTABLE[width=2cm,height=2cm] \bTABLE[align={middle,lohi}] \bTR\bTD[background=topsplit] Some text\par And some more text that will apear below the other text\eTD\bTD[background=midsplit] Some text above\par Some text below \eTD\eTR \eTABLE
\stoptext _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
On Sun, 10 Aug 2003 09:30:48 +0200
Mikael Persson
I had some problems with backgrounds in a table. I wanted just a horizontal line, but in different heights. The problem is that the line will always be in the middle of the cell if I don't add more graphics. See the example file below.
the graphics are always centered in the cell. therefore you have to set the bounding box of the graphic to the cell size
% This works, but is not nice.
\startuniqueMPgraphic{splittop} draw (0,0)--(OverlayWidth,OverlayHeight) withcolor white;%should not be necessary draw (0,0.725*OverlayHeight)--(OverlayWidth,0.725*OverlayHeight); \stopuniqueMPgraphic
the following should give what you want (untested) \startuniqueMPgraphic{splittop} draw (0,0.725*OverlayHeight)--(OverlayWidth,0.725*OverlayHeight); setbounds currentpicture to (unitsquare xyscaled (OverlayWidth,OverlayHeight)) ; \stopuniqueMPgraphic in order to save some typing you could define a macro \startMPinclusions def FitToOverlay = setbounds currentpicture to (unitsquare xyscaled (OverlayWidth,OverlayHeight)) ; enddef; \stopMPinclusions \startuniqueMPgraphic{splittop} draw (0,0.725*OverlayHeight)--(OverlayWidth,0.725*OverlayHeight); FitToOverlay ; \stopuniqueMPgraphic Jens
On Sun, 10 Aug 2003 20:50:58 +0200
Jens-Uwe Morawski
On Sun, 10 Aug 2003 09:30:48 +0200 Mikael Persson
wrote: I had some problems with backgrounds in a table. I wanted just a horizontal line, but in different heights. The problem is that the > line will always be in the middle of the cell if I don't add more >
graphics. See the example file below.
the graphics are always centered in the cell. therefore you have to > set the bounding box of the graphic to the cell size
% This works, but is not nice.
\startuniqueMPgraphic{splittop} draw (0,0)--(OverlayWidth,OverlayHeight) withcolor white;%should not be necessary draw (0,0.725*OverlayHeight)--(OverlayWidth,0.725*OverlayHeight); \stopuniqueMPgraphic
the following should give what you want (untested)
\startuniqueMPgraphic{splittop} draw (0,0.725*OverlayHeight)--(OverlayWidth,0.725*OverlayHeight); setbounds currentpicture to (unitsquare xyscaled > > (OverlayWidth,OverlayHeight)) ;\stopuniqueMPgraphic
in order to save some typing you could define a macro
\startMPinclusions def FitToOverlay = setbounds currentpicture to (unitsquare xyscaled > > (OverlayWidth,OverlayHeight)) ; enddef; \stopMPinclusions
\startuniqueMPgraphic{splittop} draw (0,0.725*OverlayHeight)--(OverlayWidth,0.725*OverlayHeight); FitToOverlay ; \stopuniqueMPgraphic
Jens
Jens, Thanks a lot! I did not know that the graphics are centered in the cell. Now this mystery (to me) is not a mystery no more :) Regards, Micke P
At 09:30 10/08/2003 +0200, you wrote:
Hi everybody!
I had some problems with backgrounds in a table. I wanted just a horizontal line, but in different heights. The problem is that the line will always be in the middle of the cell if I don't add more graphics. See the example file below.
well, it's just framed what is in charge there, so you can use \setupTABLE[width=2cm,height=2cm] \bTABLE[align={middle,lohi}] \bTR\bTD Some text\hairline And some more text that will apear below the other text\eTD\bTD Some text above\hairline Some text below \eTD\eTR \eTABLE now, since spacing for a multiliner is suboptimal, you may put this in cont-new.tex: \def\vboxedhairline {\bgroup \dimen2=\ifboxhasoffset \localoffset \else \zeropoint \fi \dimen4=\dimen2 \advance\dimen4 \ruledlinewidth \setbox0\vbox {\advance\hsize 2\dimen4 \vskip\dimen2 \hrule \!!height\ruledlinewidth \!!depth\zeropoint \!!width\hsize \vskip\dimen2}% \endgraf\obeydepth\nointerlineskip \moveleft\dimen4\box0 \endgraf\nointerlineskip\localbegstrut \egroup}
\startuniqueMPgraphic{splittop}
beware: unique graphics are reused, unless the mechanism is able to determine that something is different, see metafun Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
participants (4)
-
David Arnold
-
Hans Hagen
-
Jens-Uwe Morawski
-
Mikael Persson