FW: [Aimmath-developers] aim/Latex package
Brought to you by:
gustav_delius,
npstrick
From: Ken M. <mo...@pt...> - 2003-09-13 01:38:13
|
I sent this message last night at 12:44am and it is almost 21 hours later and I still have not received a copy back from the SourceForge developers list, but I already received a copy of the message I sent today about the What's New file, so I will assume that the message below was never delivered. So I am attempting to send it a second time. Sorry if you get two copies of this eventually once SourceForge finds and distributes the original. -----Original Message----- From: Ken Monks [mailto:mo...@pt...] Sent: Friday, September 12, 2003 12:44 AM To: Aim Developers Subject: RE: [Aimmath-developers] aim/Latex package I just committed a batch of changes that should help with some of the problems you raise below. In particular, 1. The default for formatting e is now italics, and not boldmath. I originally made it boldmath because TtH doesn't italicize math mode variables and the plain non-italicized e looked really bad, and I wanted to emphasize to the students that it was exp(1) and not the variable e. But with italics it actually looks pretty good on screen now, it is easy to distinguish it from the other variables and it look closer to what you see in textbooks. It should also look fine in your pdf documents now. It is a definite improvement, and now looking back, I realize that I should have tried italics instead of boldface in the first place. 2. I fixed the problem with @sin(x)@, it now produces \sin \left( x \right). Same for the other functions too. 3. I found the cause of the original "ln in italics" bug. For some reason `latex/ln` and `latex/log` were being unassigned in AliceServer.mpl, but no replacement for those routines was in LaTeX.mpl. I changed AliceServer.mpl so it no longer unassigns them. However, I'm a little concerned about why they might have been unassigned in the first place. Hopefully it was just some problem with older versions of Maple and TtH. Does anyone know why they were originally unassigned? 4. The routine `latex/latex/symbol` is no longer modified by AIM. (Neil deleted it a while ago, then I put it back to fix the ln bug, now we are back to not needing it again. :)). I also checked the routine in LaTeX.mpl for `latex/latex/function` against the code for the same function in Maple 7 and they seemed almost identical, so I also removed that routine from LaTeX.mpl. I also don't know why we were overriding that routine. Perhaps it was originally added to add a feature that wasn't present in an older version? Anyway, I only commented out both of these routines, so if some texing bugs reappear we only need to uncomment them to get them back. I tested it as much as I could on my machine, but my questions don't test everything, so it would be helpful if everyone would test their own questions to see if there are any new formatting quirks introduced. 5. We still override `latex/latex/*` and `latex/latex/**` (for reasons discussed below) but I replaced both routines with modified versions of the same routine from Maple 7, so that it is more up to date. In particular, this was the original source of the (I+1)(a-b) bug which is (still) fixed. I didn't touch the `latex/latex/matrix` in LaTeX.mpl routine since I know nothing about that. I also changed the behavior so that the default formatting for n^(1/2) is \sqrt{n} if n is a one digit integer (see more discussion on radicals below). So they are the changes I just committed. Let me now reply to your original message: > -----Original Message----- > From: Gustav W Delius > Sent: Wednesday, September 10, 2003 6:11 PM > To: AIM developers > Subject: [Aimmath-developers] aim/Latex package > > > As you know, I am passing the AiM latex output through pdflatex to obtain > nicely typeset problem and solution sheets. Unfortunately it turns out that > the latex that AiM produces has some shortcomings. I need help from people > who understand the aim/Latex package to overcome these problems. > > As far as I understand the aim/Latex package has 3 goals: > > 1) remove shortcomings in Maple's Latex, > > 2) avoid some of the simplifications that Maple would do automatically that > the Inert package doesn't want, Let me clarify this a bit. One main purpose of the Inert package is to override the latex formatting that AIM and Maple produce for a given expression. An InertExpr object carries around its own latex formatting internally, so it doesn't depend on what AIM or Maple decides is the latex string for a given expression. So in that sense, whatever changes we make to the default latex formatting for Maple expressions, it will have no effect on the way InertExpr objects display. However, there are several situations where you can't override the default latex formatting with the Inert package. The most obvious one is the when AIM echo's back the student's answer to the student. Since the students are entering ordinary Maple expressions and not inert expressions the formatting of their answer is determined by Maple's latex package and the modifications to it that we incorporate into AIM. Another place where the default formatting is important is when printing the value of an InertExpr, since that is an ordinary Maple expression. This comes up quite often when showing a solution, where you might start with the unevaluated expression and simplify it in a few steps with the last step being the inert expression's value. The bottom line is that what we choose for the default latex formatting of Maple expressions is important, but it doesn't affect the display of inert expressions, so we can choose it to be whatever we like without affect that package per se. > 3) change the latex so that it looks good after conversion by tth. > > Now I think 1) and 2) are a good idea. Obviously I am not so excited about > 3) because what makes tth look good doesn't necessarily look good when > typeset. Clearly I would want to switch off this tth conditioning to produce > good latex output. That would be easy to do if only I knew which parts of > aim/Latex served which goal. I can tell you about the parts I know about. Currently aim/LaTeX.mpl overrides the following built-in Maple functions from Maple's latex package: 1. `latex/latex/*` The only reason this is overridden is to prevent it from resetting the value of _LatexSmallFractionConstant to 50 when formatting a product with a numerical first factor. Maple has the default for this constant set to 50, but I changed the default to 5000 in AliceServer.mpl. The motivation for doing this is that Maple latex formats any numerical fraction n/m vertically, i.e. \frac{n}{m}, whenever the value of abs(n*m) is greater than _LatexSmallFractionConstant, but horizontally as n/m otherwise. However, TtH is very bad at formatting fractions vertically in inline math mode (it basically can't) so this causes a headache in questions where randomization might choose 2/3 for the fraction in one question instance and 7/8 in another instance. With the original default value of _LatexSmallFractionConstant=50, 2/3 would format horizontally, but the 7/8 would be formatted vertically, resulting in (a) an ugly inline display because of TtH and (b) inconsistent formatting in the question even in display math mode depending on the particular randomization. 2. `latex/latex/**` The main modification to this routine is to prevent Maple from producing radical's, since TtH is terrible at producing anything but the simplest expression using radicals. Even in display math mode, it can't connect the leading root symbol to the overbar on a big expression. The only thing that looks half decent is something like \sqrt{x} or \sqrt(2) where there is only one character after the root sign, since then it doesn't try to put the overbar above the character. So I just tweaked it so @n^(1/2)@ becomes \sqrt{n} if n is a single digit integer. It would be easy enough to change it so it would work for single character variables too, but I don't think we should do that. It is better to let all of the expressions that have rational exponents format in a consistent manner, and it is usually more useable to have them in exponential form than radical form when writing solutions to questions. The only other tweak to this routine is to prevent it from putting parentheses around the e when formatting @exp(1)^2@. Maple doesn't automatically simplify this expression to exp(2), so if a student enters e^2 for his answer, then since we have defined e:=exp(1), this is the actual expression that AIM tries to format. The default is (e)^2 instead of just e^2, so this tweak prevents the parentheses in that case. 3. `latex/exp` This is overridden so it formats exp(1) as {\it e} and exp(x) as {\it e}^{x}. 4. `latex/latex/float` I rewrote almost all of this routine to improve the default latex formatting for Maple floats in AIM questions. In particular, the default for Maple is to latex format a float using all of the digits determined by the global variable Digits. This is almost always way too many digits for a reasonable question involving floats. This routine now uses a new global variable 'LaTeXDigits' to determine how many digits it should use by default when displaying a float. Thus we can specify the number of digits displayed in the latex output of a float without affecting the accuracy of the internal computation (as it would be if we reset Digits instead). The default is three digits. So that is the complete list of the modifications I have made to the latex code. Aside from whatever is going on in `latex/latex/matrix`, they are the only variations from what Maple produces by default. > Some things are obvious, for example typesetting $e^x$ with a bold e is good > for on-screen display but something I would want to switch off for > conventional mathematical typesetting. I changed this to italics now, so it should be good for both. > Another thing that I certainly want > to switch off is the typesetting of $\sqrt{2}$ as $2^{1/2}$. This is changed now too, but only for single digit integers. I think it will be a bad idea to do this for other expressions. > But there already I have difficulties finding where it is done. Can you help? > > Finally there is the matter of the missing \ in front of \cos and similar > things. I don't know if that is a bug or part of 3) This is fixed now. One final philosophical comment about this topic... I think we really should try to keep the pdf and on screen versions of an AIM quiz as identical as possible. In particular, if TtH cannot display radicals like $$\sqrt[3]{\frac{x+1}{x}}$$ and so we have it print as $${\frac{x+1}{x}}^(1/3)$$ instead, then we should not use the radical notation in the pdf quiz and the exponential notation on the onscreen version. Otherwise we will have angry mobs of students pounding down our office doors saying "When I saw the question on the screen it had a 1/3 power but when I printed the quiz it changed to a different question with roots and stuff! So I just skipped that one because I didn't know which question you wanted me to answer?" :) KEN |