WeBWorK Problems

Changing font to Courier

Re: Changing font to Courier

by Davide Cervone -
Number of replies: 2
Your first approach was better than the second. The reason that you get red, a box, and smaller is that there are CSS rules in your theme that style the <code> element. (I object to having such styles in the theme CSS, indicating that it would cause problems like this. I think some have been removed, but not all.)

You could change the theme CSS, or could use PGcourse.pl to insert (into every problem that includes PGcourse.pl) some CSS that overrides the styles for <code> elements.

Paul's idea is the one I recommend as well. Here are some definitions that implement in-line and multi-line code segments:

    $BCODE = MODES(HTML=>'<code style="font-family: Courier"&gtl',TeX=>'\verb'.chr(0x85));
    $ECODE = MODES(HTML=>'</code>',TeX=>chr(0x85));
    
    $BPRE = MODES(HTML=>'<pre style="font-family: Courier">',TeX=>'\begin{verbatim}');
    $EPRE = MODES(HTML=>'</pre>',TeX=>'\end{verbatim}');
which you use as
    BEGIN_TEXT
    This is in-line code: ${BCODE}findZeros()${ECODE} finds the zeros of the function.
    $PAR
    Here is multi-line code:
    $BPRE
         Line1 of code
           Line1.1
         Line2
    $EPRE
    That's it.
    END_TEXT
The theme styling may affect these as well, so you might need to specify more style rules, such as
    $BCODE = MODES(
        HTML=>'<code style="font-family: Courier; font-size:inherit; background:transparent; border:0; padding:0">',
        TeX=>'\verb'.chr(0x85)
    );
to override the ones set in the theme. It would also be possible to use <tt> rather than <code> tags, which might not be styled by the theme (I didn't check).

Davide

In reply to Davide Cervone

Re: Changing font to Courier

by John Jones -
These seem like commands which should go in PGbasicmacros where other styling macros are found.

John

In reply to John Jones

Re: Changing font to Courier

by Davide Cervone -
I think you could do a generic one (that uses <code> and <pre> tags) in PGbasicmacros, but I would not do the Courier-specific ones there. I'm also not sure that the CSS to override the theme should go there, either. (I would rather see the themes not modify the styles used within the problem itself, but that's a different argument.)