[LON-CAPA-users] subscript/superscript in randomlabel

Raeburn, Stuart raeburn at msu.edu
Fri Jan 18 19:55:52 EST 2019

Hi HK,

As a work-around you could create an image file for each text label you wish to display, and include subscripts and superscripts when you create each image file.  You would then upload each file to your Authoring Space and publish.

Within the labelgroup inside the randomlabel item in the problem you would set the type attribute to image, and use something similar to:

<labelgroup name="EMF" TeXsize="\normalsize" type="image">
<location x="124" y="21" />
    <label description="E1">/res/fsu/hkng/path_to_images/e1label.png</label>  
<location x="124" y="225" />
    <label description="E2">/res/fsu/hkng/path_to_images/e2label.png</label>

where /res/fsu/hkng/path_to_images/e1label.png and /res/fsu/hkng/path_to_images/e2label.png would be the locations of the published label images.

1. randomlylabel.pm uses the GD library to create the labeled image, and a call to image->stringFT() was added to the LON-CAPA code in randomlylabel.pm rev. 1.19 (2004).  The comment logged with that commit is: "- added font support (I can't get ttf to work)"

2. The call to $image->stringFT() to use a TrueType Font (ttf) for a text label available in randomlylabel.pm is not currently used because randomlabel.pm currently only supports specification of the first three arguments (x, y, text) of the six arguments which the perldoc for randomlylabel.pm indicates would be possible for the LABEL item. The other three (unsupported by randomlabel.pm) are: font, color, direction.

3. The CPAN documentation for the GD library documents that the text label can contain UTF-8, as long as libgd has been compiled with TrueType support, and the appropriate TrueType font is installed on the system. In that case a superscript 1 could be included as ¹ and a superscript 2 could be included as ²

Stuart Raeburn
LON-CAPA Academic Consortium

From: LON-CAPA-users <lon-capa-users-bounces at mail.lon-capa.org> on behalf of H.K.Ng <hkng at fsu.edu>
Sent: Friday, January 18, 2019 9:22 AM
To: Discussion list for LON-CAPA users
Subject: [LON-CAPA-users] subscript/superscript in randomlabel

 Is there a way to display subscript/superscript in randomlabel? Tried a few things but none works. Thanks.

<randomlabel width="306" height="269" TeXwidth="75" bgimg="Graphics/21_25.png">
<labelgroup name="EMF" TeXsize="\normalsize" type="text">
<location x="124" y="21" />
<location x="124" y="225" />


More information about the LON-CAPA-users mailing list