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

H.K.Ng hkng at fsu.edu
Mon Jan 21 11:23:40 EST 2019

Hi Stuart,

Thanks for the tip. I eventually did the following:
1. Create the picture with E's (& R's) in the right places.
2. The randomization is for the number, so it comes out as E_1 etc. Same for resistance.
Which brings the following question? Is there a way to specify the font type and size?


On Fri, Jan 18, 2019 at 7:56 PM Raeburn, Stuart <raeburn at msu.edu<mailto:raeburn at msu.edu>> wrote:
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<http://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<http://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<http://randomlylabel.pm> is not currently used because randomlabel.pm<http://randomlabel.pm> currently only supports specification of the first three arguments (x, y, text) of the six arguments which the perldoc for randomlylabel.pm<http://randomlylabel.pm> indicates would be possible for the LABEL item. The other three (unsupported by randomlabel.pm<http://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<mailto:lon-capa-users-bounces at mail.lon-capa.org>> on behalf of H.K.Ng<http://H.K.Ng> <hkng at fsu.edu<mailto: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" />


LON-CAPA-users mailing list
LON-CAPA-users at mail.lon-capa.org<mailto:LON-CAPA-users at mail.lon-capa.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.lon-capa.org/pipermail/lon-capa-users/attachments/20190121/45429e8f/attachment-0001.html>

More information about the LON-CAPA-users mailing list