4

I have an itemized list. On several lines there are some boxes, drawn in MetaPost. I used \inframed[location=line] to make them vertically centered on the line. The problem is, they are overlapping each other:

\define[1]\drawbox{%
    \scale[width=.1\textwidth]{%
        \startMPcode        
            draw (0,0)--(100,0)--(100,100)--(0,100)--(0,0);
        \stopMPcode%
    }%
}

\define[3]\showfacts{%
    \inframed[frame=off, location=line]{%
        \drawbox{#1}%
    }%
    {\it #2}\ #3%
}%

\starttext
    This is some text.
    \startitemize[n]
        \item \showfacts{a}{x}{3}
        \item \showfacts{b}{y}{4}
    \stopitemize
\stoptext

Is there a way to make it so the next item (item #2) appears lower, so that the MetaPost art don't overlap? Additionally, so it isn't so close to "This is some text".? The appearance should be more like this:

This is some text.
    _____
   |     |
1. |     | x 3
   |_____|
    _____
   |     |
2. |     | y 4
   |_____|

How can I give a greater space automatically when the line has a MetaPost object?

4

Use location=middle. The option location=line just sets both height and depth of the enclosed object to .5\lineheight.

N.B.: \inframed is just a shortcut for \framed[location=low], so by overriding the location you defeat this shortcut. Might as well use plain \framed then.

\define[1]\drawbox{%
    \scale[width=.1\textwidth]{%
        \startMPcode        
            draw (0,0)--(100,0)--(100,100)--(0,100)--(0,0);
        \stopMPcode%
    }%
}

\define[3]\showfacts{%
    \framed[frame=off,location=middle]{%
        \drawbox{#1}%
    }%
    {\it #2}\ #3%
}%

\starttext
    This is some text.
    \startitemize[n]
        \item \showfacts{a}{x}{3}
        \item \showfacts{b}{y}{4}
    \stopitemize
\stoptext

enter image description here

  • 1
    I must say that this is the first time I have encountered normalMPboxdepth. Would you mind adding an explanation for that as well? – Aditya Apr 26 at 11:30
  • 1
    @Aditya Oops, that was a leftover of an earlier experiment. It is not needed here. To see what it does, check meta-ini.mkiv. – Henri Menke Apr 26 at 21:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.