Metapost 图形未在 ConTeXt TABLE 中对齐

Metapost 图形未在 ConTeXt TABLE 中对齐

我正在使用 TABLE 设计地图图例。符号应居中对齐。如标题所述,用作符号的 metapost 图形在我的 TABLE 环境中未对齐(第 1 列和第 3 列),而文本则按应有的方式对齐(第 3 行中的“cas”)。

\startreusableMPgraphic{tourisme}
pickup pencircle scaled 2 ;
path p ;
 p:= unitsquare xscaled 30 yscaled 15 ;
draw p withcolor red ;
\stopreusableMPgraphic

\startreusableMPgraphic{ballon}
path p ;
 p:= (10,0) -- (0,15) .. (10,30) .. (20,15) -- cycle ;
 fill p withcolor red ;
\stopreusableMPgraphic

\starttext
\setupTABLE[column][1,3][width=4em,align={middle,lohi}]
\setupTABLE[column][2,4][width=0.42 \textwidth,align=lohi]
%\setupTABLE[][]
\bTABLE
\bTR \bTH \eTH \bTH I. My first part\eTH \bTH \eTH \bTH II. My second part \eTH \eTR
\bTR \bTD \reuseMPgraphic{tourisme} \eTD \bTD forêts \eTD  \bTD \reuseMPgraphic{tourisme} \eTD \bTD some very long text to make sure that alignment works as I want\eTD\eTR
\bTR \bTD \reuseMPgraphic{tourisme} \eTD \bTD some very long text to make sure that alignment works as I want \eTD \bTD cas \eTD \bTD a nice castle \eTD \eTR
\bTR \bTD \eTD \bTD \eTD \bTD \reuseMPgraphic{ballon} \eTD \bTD montgolfière (tourisme vert) \eTD \eTR
%\bTR \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \eTR
\eTABLE

\stoptext

未对齐的元贴 我怎样才能解决这个问题?

答案1

当您在这样的表格中包含图形时,您需要确保 TeX 处于水平模式,以便将文本对齐应用于包含的图形(显然)。您可以使用\leavevmode原始命令强制单元格进入此模式。

在这种情况下,我猜你会使用很多符号,所以你可以考虑制作一个宏来为你完成工作,就像我在这里所做的那样:

\startreusableMPgraphic{tourisme}
pickup pencircle scaled 2 ;
path p ;
 p:= unitsquare xscaled 30 yscaled 15 ;
draw p withcolor red ;
\stopreusableMPgraphic
\def\ttour{\leavevmode\reuseMPgraphic{tourisme}}

\startreusableMPgraphic{ballon}
path p ;
 p:= origin -- (-10,15) .. (0,30) .. (10,15) -- cycle ;
 fill p withcolor red ;
\stopreusableMPgraphic
\def\tball{\leavevmode\reuseMPgraphic{ballon}}

\starttext
\setupTABLE[column][1,3][width=4em,align={middle,lohi}]
\setupTABLE[column][2,4][width=0.42 \textwidth,align=lohi]
\bTABLE
\bTR 
\bTH \eTH 
\bTH I. My first part\eTH 
\bTH \eTH 
\bTH II. My second part\eTH 
\eTR
\bTR 
\bTD \ttour\eTD 
\bTD forêts\eTD  
\bTD \ttour\eTD 
\bTD some very long text to make sure that alignment works as I want\eTD
\eTR
\bTR 
\bTD \ttour \eTD 
\bTD some very long text to make sure that alignment works as I want\eTD 
\bTD cas\eTD 
\bTD a nice castle\eTD 
\eTR
\bTR 
\bTD \eTD 
\bTD \eTD 
\bTD \tball\eTD 
\bTD montgolfière (tourisme vert)\eTD 
\eTR
\eTABLE

\stoptext

在此处输入图片描述

相关内容