You might try using typewriter text via ${BTT}findZeros()${ETT}. For small bits of code, you might also try \( \verb+findZeros()+ \). Another alternative might some custom commands such as
$BCODE = MODES( TeX => '\begin{verbatim}', HTML => '<code>' );
$ECODE = MODES( TeX=> '\end{verbatim}', HTML => '</code>' );
that could be used via ${BCODE}findZeros()${ECODE}. I encourage you to write custom commands, like the one above, so that the pdf hardcopy is usable (TeX mode sometimes gets forgotten). You could also put the custom commands into a macro file.
People with more font expertise are encouraged to chime in with better answers that will actually provide Courier font.
Take care,
Paul Pearson
<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">l',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_TEXTThe 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
<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.)
BEGIN_PGML
: Here is some code
: Here is some code
END_PGML
Of course, in my experience "preformatted" has always meant monospaced font. I'm sure it actually means something different and more involved, so it is recommended to understand what preformatted text is better than I do.
Thanks for the suggestions, I tried them all and found the one that seemed to work the best is a somewhat modified version:
$BCOURIER = MODES(
HTML=>'<code style="font-family: Courier; font-size:inherit; background:transparent; border:0; padding:0; word-wrap:break-word; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; display: inline; ">',
TeX=>'\verb'.chr(0x85)
);
$ECOURIER = MODES(HTML=>'</code>',TeX=>chr(0x85));
My collegue, Dave Rosoff, added the "extra" options in hopes of making it compatible with multiple browsers. It wraps lines and the text scales nicely. The text shows up on the screen in red in Chrome and IE, but I kind of like it. I suppose there is an option to add that would make it black all the time. I've put it in a file in my macros folder and load it when I need it so it is easy to modify for all of the problems using it. I'll be interested to know if a courier font gets added to the PGbasicmacros in the future.
Thanks, again--rac
color:black
or color:inherit
if you want to control the color. I had meant to include that, but forgot it.Glad you got it to work as you would like.