teTex and lt;, gt; symbols

teTex and lt;, gt; symbols

by Artem Andreev -
Number of replies: 12
I try install teTex and use its instead of mimetex. I have one problem: lt; and gt; symbols in tex formula didn't replaced on < and >... I saw source code (string 64,65):
$texexp = str_replace('<','<',$texexp);
$texexp = str_replace('>','>',$texexp);
used only for mimetex. Why don't used it for teTex?
Average of ratings: -
In reply to Artem Andreev

Re: teTex and lt;, gt; symbols

by Victor Alejandro Merchan -
I'm having the same problem. Has anyone found a solution? Is there any way that users write ">" and "<" on their formels, and that these are well shown (not as gt; and lt;)?.

I know this works well on mimetex, but I wanted to use teTex because of the better picture quality. I'm Sorry if this question has been answered before. I have searched a lot in the older forums but did not find anything.

Victor Alejandro



In reply to Victor Alejandro Merchan

Re: teTex and lt;, gt; symbols

by Frederic Udina -
Hi,

Yes, I'm having the same problem, any suggestion out there?

Frederic
In reply to Frederic Udina

Re: teTex and lt;, gt; symbols

by Victor Alejandro Merchan -
Hi,

I have a solution. You only have to edit your (yourmoodle/filter/tex/latex.php) a little.

Add the blue lines to your latex.php.

//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
$doc .= "$formula\n";

} else {
$doc .= "$ {$formula} $\n";
}
///////////////////////////////////////////
$doc = str_replace('&gt;','>',$doc);
$doc = str_replace('&lt;','<',$doc);
$doc = str_replace('&amp;','&',$doc);
$doc = str_replace('&nbsp;',' ',$doc); //////////////////////////////////////////////
$doc .= "\\end{document}\n";
return $doc;

////////////////////////////////////////////

not only the symbols <, > will be good rendered but also &, which you always need to enter matrices and which can also cause problems if you don't edit your latex.php in the way shown above.

Alejandro
Average of ratings: Useful (1)
In reply to Victor Alejandro Merchan

Re: teTex and lt;, gt; symbols

by Damon Blanchette -
Hello Alejandro, I tried your solution for an ampersand problem we're having, and it didn't work. I also deleted the entries from the mdl_cache_filters table (in order to sort of reset it), but that didn't work either.

Here's the LaTeX code copied straight from the faculty's post (double dollar signs removed):

\begin{tabular}{c|c|c|c|c|c|c|c}
1-dim &2-dim &3-dim &4-dim &5-dim &\dots &n-dim\\\hline
1 slice &2&2&2&2&2&\dots&2\\
2 slices&3&4&4&4&4&\dots&4\\
3 slices&4&7&8&8&8&\dots&8\\
4 slices&5&11&15&16&16&\dots&16\\
5 slices&6&16&?&31&32&\dots&32\\
\dots&&&&&&\dots&\\
k slices&(k+1)&?&?&?&?&\dots&?\\
\end{tabular}

All of the & show up as amp;. So, the top row looks like 1-dim | amp;2-dim | amp;3-dim etc......

Any ideas?
In reply to Damon Blanchette

Re: teTex and lt;, gt; symbols

by Victor Alejandro Merchan -
Hi Damon,

I copied and pasted your LaTeX-Code in my System and I got the picture you can see below. As you can see, it works.

I've not done any other changes to my php-files, but the mentioned above. I don't know where the problem can be. Which LaTeX-distribution are yo using? I'm using teTeX and it's been working fine.

Or Maybe your distribution does not have the LaTeX-packages that are required to show tables or Matrixes.

Alejandro
Attachment 2007-02-13_212305.jpg
In reply to Victor Alejandro Merchan

Re: teTex and lt;, gt; symbols

by Damon Blanchette -
Thank you Alejandro! The faculty seems to think that it's not our distribution, but I'm not sure. We're checking into it right now. We have these packages installed:
tetex-fonts
tetex-dvips
tetex-latex
and tetex-latex version 2.0.2-22.

Perhaps I put your lines into the wrong place? I added them around line 61 in the latex.php file (after the "if" statement, and before this line: $doc .= "\\end{document}\n" ), is that correct?
Damon
In reply to Damon Blanchette

Re: teTex and lt;, gt; symbols

by Victor Alejandro Merchan -
Hi Damon!

it seems to be you have the right LaTeX-packages installed. Did you put the right paths to the latex binaries on your admin page (yourmoodle/admin/filters.php)?

In the tex settings in moodle you should have following paths

/usr/bin/latex
/usr/bin/dvips
/usr/bin/convert

I guess you put my lines in the right place. I put hier my latex.php if you want to compare.

Alejandro


In reply to Victor Alejandro Merchan

Re: teTex and lt;, gt; symbols

by Atsuhito Kohda -
Hi all, which version of moodle are you using? I use moodle 1.7.1 and Alejandro's patch seemed not to work but my colleague who uses moodle 1.6.4 can fix the problem with Alejandro's patch. Thanks.
In reply to Atsuhito Kohda

Re: teTex and lt;, gt; symbols

by Damon Blanchette -
I'm using Moodle 1.7+, and it didn't work for me. They must have changed the code somewhere in this version of moodle. I can do some searching around and maybe I can figure out where it is we need to add something (or take something away).
In reply to Damon Blanchette

Re: teTex and lt;, gt; symbols

by Atsuhito Kohda -
Sorry but my previous information might be wrong. I couldn't have tested TeX filter these days because of some problem but today I can fix the problem. I test TeX filter again and find that Alejandro's patch works fine with moodle 1.7.1.
Damon, have you tried a new page with new contents to remove cash problem?

Thanks.
In reply to Atsuhito Kohda

Re: teTex and lt;, gt; symbols

by Damon Blanchette -
Hi Alejandro, I have tried that, and also tried clearing the database table that held the links for the images created by the TeX filter. I tried a few other things as well, and found that putting a space before slashes helps to fix some problems (and probably some of the other things I tried). Here's an email I received from the professor with the &amp problem:

---
Just for fun, I tried doing a tabular post again, and it's still got the amp; problem. Interestingly, I found related problem which could help shed light on that issue... if we give it
$$\begin{tabular}{c|c} 1 & 1 \\ 2 & 2 \\\end{tabular}$$
it correctly typesets the table with the addition of the amp;s. But if we give it
$$\begin{pmatrix} 1 & 1 \\ 2 & 2 \\\end{pmatrix}$$
then it ignores all matrix input past the first entry and puts the parens around just that entry rather than the whole matrix.
---

EDIT: here are the equations above without the $$:
\begin{tabular}{c|c} 1 & 1 \\ 2 & 2 \\\end{tabular}
and
\begin{pmatrix} 1 & 1 \\ 2 & 2 \\\end{pmatrix}


I don't know much about TeX, but perhaps this will help someone who does to figure out the problem! Is it that we have a version that doesn't understand pmatrix? I can't tell what's going on.
Thanks,
Damon
In reply to Damon Blanchette

Re: teTex and lt;, gt; symbols

by Sebastián Espinosa -

I have solve this problem.

We render a text with latex using the comand line and it looks fine, so probably it was a problem in the comunication between moodle and my operating system, espicifically in the scape character.

So after googling a lite bit I solved. Everytime that you write some latex code betwenn $$ symbols, the first time thah you use de symbol '&' you need to add before it the symbol '^' so at the ends will looke like '^&'.

You need to do this only with the first & symbol that appers, if you doit twice new render problems will apper and its really tedius to get read of them. I will post here the two different version of the code (without the $$
symbols) so you can see the diference:

ORIGINAL TEXT:

\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline \bf{x} &-1 & 0 & 1 & 2 & 3 \\ \hline \bf{y}& 2 & -1 & -4 & -25 & -82 \\ \hline \end{tabular} \\

CORRECTED TEXT:

\begin{tabular}{|c|c|c|c|c|c|c|c|} \hline \bf{x} ^&-1 & 0 & 1 & 2 & 3 \\ \hline \bf{y}& 2 & -1 & -4 & -25 & -82 \\ \hline \end{tabular} \\


I have put in red, bold and in big size the symbol '^' so you can note the difference. This solve the problem for me, hope it works for everybody else.

Sebatián Espinosa
from Chile!!!!