Forum archive 2000-2006

Michal Charemza - Bold Vectors

Michal Charemza - Bold Vectors

by Arnold Pizer -
Number of replies: 0
inactiveTopicBold Vectors topic started 9/6/2006; 5:27:25 PM
last post 9/22/2006; 12:19:30 PM
userMichal Charemza - Bold Vectors  blueArrow
9/6/2006; 5:27:25 PM (reads: 433, responses: 7)
Hi,

I'm trying to create a question where the variables are vectors (I set them to type 'Vector2D' or 'Vector3D'. I would like them to be displayed in Bold (or underlined, I don't mind). This is what I am doing:

$context=Context("Vector"); $context->variables->add('a'=>'Vector3D', 'b'=>'Vector3D');

$A = Formula("a"); $B = Formula("b"); $C = Formula("1 a + 2 b");

If I display any of $A, $B or $C in the question, then the vectors are not shown in bold either in the question or the students answer preview. Is is possible to have the vectors shown as bold?

Michal.

<| Post or View Comments |>


userDavide P. Cervone - Re: Bold Vectors  blueArrow
9/6/2006; 9:26:29 PM (reads: 493, responses: 0)
There wasn't an easy way to do this, so I modified the parser to automatically typeset vector-valued variables in bold face. It is also possible now to override the standard TeX output on a variable-by-variable basis. For example:
    Context("Vector")->variables->add(a => 'Vector3D');
Context()->variables->set(a => {TeX => 'vec a'});
would cause the variable 'a' to have a vector arrow on top rather than be in bold.

You will need to get the updated version of pg/lib/Parser/Variable.pm for these to work. If you don't want to update (and I would understand if you didn't want to in the middle of a term, but this is such a minor change, I think it would be OK), then I can show you another (harder) way of doing it.

<| Post or View Comments |>


userMichal Charemza - Re: Bold Vectors  blueArrow
9/8/2006; 3:25:13 PM (reads: 492, responses: 0)
Thanks - the term hasn't started here yet, so I will use the updated file.

<| Post or View Comments |>


userMichal Charemza - Re: Bold Vectors  blueArrow
9/22/2006; 5:54:36 AM (reads: 363, responses: 1)
Hi,

I have updated the file, and the custom variable tex output works great. However, it doesn't work with i, j or k. Is there a way to customise the output for i, j or k? (Specifically I would like them bold with hats on, i.e. mathbf{imath}, mathbf{jmath} and mathbf{k}).

Thanks,

Michal.

<| Post or View Comments |>


userDavide P. Cervone - Re: Bold Vectors  blueArrow
9/22/2006; 7:05:53 AM (reads: 421, responses: 0)
The TeX output fir i, j and k should be showing up as bold characters (they use \boldsymbol to produce their output, so perhaps this is not available and is being ignored when the images are produced).

You can set the TeX to be used for i, j, and k using the following:

  Context("Vector")->constants->set(
i => {TeX => "\mathbf{\hat\imath}"},
j => {TeX => "\mathbf{\hat\jmath}"},
k => {TeX => "\mathbf{\hat k}"},
);
but note that I have added \hat since you indicated that you wanted those (though you didn't include it in your code). Note also that the "k" will be a roman (not italic) k, and so will look different from the i and j.

Davide

<| Post or View Comments |>


userMichal Charemza - Re: Bold Vectors  blueArrow
9/22/2006; 10:14:19 AM (reads: 354, responses: 1)
> Note also that the "k" will be a roman (not italic) k, and so will look different from the i and j.

I am having some problems getting a roman bold dotless i and j. I think this is more LaTeX's fault, so i can live with having dots on them with the hat.

I have set the TeX output for the constants. However, they only appear to work in the Students Answer preview, and not in the text of the questions. (Even if the expressions are changed to something they have never been, I get the old, bold italic letters (with no hat), so it appears that the old images are not geting reused from a cache... not that I really understand how WeBWorK's cache's work).

Is it possible to change the appearance of i, j and k in the text of the question? If so - how?

Thanks,

Michal.

<| Post or View Comments |>


userSam Hathaway - Re: Bold Vectors  blueArrow
9/22/2006; 12:19:30 PM (reads: 344, responses: 0)
Even if the expressions are changed to something they have never been, I get the old, bold italic letters (with no hat), so it appears that the old images are not geting reused from a cache... not that I really understand how WeBWorK's cache's work

WeBWorK's equation image cache is keyed on individual TeX strings. If the TeX string changes (for example, to add a \hat), a new image will be generated and used. So you should not have to change the expressions to get a new image.
-sam

<| Post or View Comments |>


userDavide P. Cervone - Re: Bold Vectors  blueArrow
9/22/2006; 12:48:14 PM (reads: 406, responses: 0)
It turns out the the Vector class was using it's own table for the TeX strings for i, j, and k rather than the values set in the Context. I have modified pg/lib/Value/Vector.pm so that it will take the values from the Context first, if they are defined, and only fall back on its table if they aren't defined in the Context. That should clear up your problem.

Also, to get roman dotless i and j try

    Context("Vector")->constants->set(
i => {TeX => '\mathbf{\hat{\mathchar"7010}}',
j => {TeX => '\mathbf{\hat{\mathchar"7011}}',
k => {TeX => '\mathbf{\hat k}'},
);

Davide

<| Post or View Comments |>