Forum archive 2000-2006

Matthew Lynn - PDFLatex problem with certain characters

Matthew Lynn - PDFLatex problem with certain characters

by Arnold Pizer -
Number of replies: 0
inactiveTopicPDFLatex problem with certain characters topic started 8/31/2006; 6:23:25 PM
last post 9/11/2006; 7:54:44 AM
userMatthew Lynn - PDFLatex problem with certain characters  blueArrow
8/31/2006; 6:23:25 PM (reads: 407, responses: 3)
We're getting errors when generating hardcopies of certain problem sets, namely those that contain a special character such as a carat (^) in the question. The errors are of the form:

First error in TeX log is:

! Missing $ inserted. <inserted text> $ l.291 mbox{parbox[t]{5ex}{hrulefill}} x 10^ mbox{parbox[t]{3ex}{hrulefi... I've inserted a begin-math/end-math symbol since I think you left one out. Proceed, with fingers crossed.

Is there a way to express the ^ symbol differently to get it to pass through pdflatex and still have the problem appear with the carat in Webwork?

Thanks, Matt

<| Post or View Comments |>


userDavide P. Cervone - Re: PDFLatex problem with certain characters  blueArrow
8/31/2006; 11:11:20 PM (reads: 468, responses: 0)
You want to use $CARET if you are using ^ outside of math mode (that is, if you plan to have a literal ^ in the output). You need to be careful about any of the characters that TeX considers as special characters, namely #, %, ^, &, _, ~, {, }, and \, and any that HTML uses as special characters, namely &, < and >, if you are wanting them to appear in the text of your problem. Some of these have macros (like $CARET and $PERCENT) defined for them already, but others don't. In those cases, you can define your own, such as
    $POUND = MODES(TeX=>'\#', HTML=>'#");
You can put these into your own .pl file in your course's templates/macros file and use loadMacros() to call them up when you need them. You may need to be tricky to get some of the characters to appear properly in TeX. For example,
    $TILDE = MODES(TeX=>'{\tt\char`\~}', HTML=>'~');
should do. (Note that you can't use just \~, since that means put a tilde accent on the character that follows).

If you need to have letter or number follow one of these references with no space in between, you need to use ${CARET} instead, as in "10${CARET}n".

If you really want to do things right, you would also do things like

    $LQ = MODES(TeX=>"``", HTML=>'"');
$RQ = MODES(TeX=>"''", HTML=>'"');
$LQS = MODES(TeX=>"`", HTML=>"'");
$RQS = MODES(TeX=>"'", HTML=>"'");
and then use ${LQ}Hello world!${RQ} rather than "Hello world!" (which would have the wrong kinds of open quotes in TeX output), but few problem authors are that careful.

If you are concerned about making things work in plain text mode (in addition to images, formatted text and jsMath modes), then there are even MORE characters macros you should be using (for example, $GE rather than ge), but VERY few authors write with plain text mode in mind (and I don't blame them, in fact, I've disabled it on our site entirely).

Hope that helps.

Davide

<| Post or View Comments |>


userchristelle scharff - Re: PDFLatex problem with certain characters  blueArrow
9/10/2006; 11:55:26 PM (reads: 411, responses: 0)
On the same topic:

- I have a \ in my PG code that appears well in the browser but the PDF cannot be generated. How can I get around this?

Thanks,

Christelle

<| Post or View Comments |>


userDavide P. Cervone - Re: PDFLatex problem with certain characters  blueArrow
9/11/2006; 7:54:44 AM (reads: 400, responses: 0)
This is one of the characters I mentioned in my previous message as being a special character in TeX, so you have to treat it specially if you plan to use it outside of math mode. Try:
    $BACKSLASH = MODES(TeX=>'{\tt\char92}', HTML=>chr(92));
and then use $BACKSLASH when you need one.

Davide

<| Post or View Comments |>