Hiding the Tex before Typesetting

253 views
Skip to first unread message

J.R.St...@physics.org

unread,
Aug 18, 2012, 1:51:58 PM8/18/12
to mathja...@googlegroups.com
<http://www.merlyn.demon.co.uk/p231-jax.htm> (8kB) is now almost the final document, EXCEPT that
(1) For speed in testing, it contains only one page of the original, with three maths segments $$...$$ (I've not yet really considered using inline MathJax, since inline
maths is already there in HTML);
(2) There is less HTML in the pre- and post-ambles.

For the convenience of those who want to see only the text, I now run the typesetter only on demand (a button, "Typeset"), calling MathJax.Hub.Typeset().

At first, pressing the button left (as expected) the original dummy non-equations, generated by an internal preprocessor, showing. Inserting MathJax.Hub.Config({preRemoveClass: "EQN"}); did not hide them -- perhaps I have misunderstood or they are not close enough. That does not matter, as I have easily coded
EQNs = document.getElementsByClassName("EQN")
for (J in EQNs) EQNs[J].style.display="none"
to hide them.

Now, after pressing my button, all is fine.  But, before pressing it, the ugly TeX shows, and
MathJax.Hub.Config({ tex2jax: {preview: "none"}});
did not remove it. Perhaps I need to run some of your processing code onload, to extract the TeX from view??

In my preprocessing, I could I expect wrap each $$...$$ in <span class=HID> </span>, and if necessary unhide it before calling Typeset().  But it would be better to do it "your" way, which I have not yet found.
-- 
  (c) John Stockton, near London, UK.  Using Google, no spell-check.
 Mail: J.R.""""""""@physics.org or (better) via Home Page at
 Web:  <http://www.merlyn.demon.co.uk/> (may move soon)
 FAQish topics, acronyms, links, etc.; Date, Lagrange, JavaScript, ..|

J.R.St...@physics.org

unread,
Aug 19, 2012, 7:42:23 AM8/19/12
to mathja...@googlegroups.com, J.R.St...@physics.org


On Saturday, August 18, 2012 6:51:58 PM UTC+1, (unknown) wrote:
<http://www.merlyn.demon.co.uk/p231-jax.htm> ...
 
In my preprocessing, I could I expect wrap each $$...$$ in <span class=HID> </span>, and if necessary unhide it before calling Typeset().  But it would be better to do it "your" way, which I have not yet found.
 
I've done, but not yet uploaded, roughly that.

Davide P. Cervone

unread,
Aug 21, 2012, 9:14:13 AM8/21/12
to mathja...@googlegroups.com
For the convenience of those who want to see only the text, I now run the typesetter only on demand (a button, "Typeset"), calling MathJax.Hub.Typeset().

At first, pressing the button left (as expected) the original dummy non-equations, generated by an internal preprocessor, showing. Inserting MathJax.Hub.Config({preRemoveClass: "EQN"}); did not hide them -- perhaps I have misunderstood or they are not close enough.

You are right, they are not close enough.  There can be nothing between the preview element and the mathematics, and that includes spaces and newlines.

  That does not matter, as I have easily coded
EQNs = document.getElementsByClassName("EQN")
for (J in EQNs) EQNs[J].style.display="none"
to hide them.
That is fine.

Now, after pressing my button, all is fine.  But, before pressing it, the ugly TeX shows, and
MathJax.Hub.Config({ tex2jax: {preview: "none"}});
did not remove it. Perhaps I need to run some of your processing code onload, to extract the TeX from view??

The TeX is part of the page, and so will be displayed until something is done to change that.  Since MathJax is not running until the button is pressed, MathJax won't modify the page until then, so it continues to show until the button is pressed.  You are right that you could run the preprocessors to remove the TeX code and prepare it for typesetting; you would not longer see the TeX, but the math would be available for processing if the button is pressed.  To do that you would want to set the preview to none as you do above, and then use

MathJax.Hub.Queue(["PreProcess",MathJax.Hub]);

to run the preprocessors without typesetting the results.

Alternatively, you could put the TeX code into the internal format initially rather than have it be part of the text of the page.  That is, you could use

<script type="math/tex; mode=display"> ... </script>

around the displayed equations.  Then the TeX would not show up at all until typeset.  See 


for details.

In my preprocessing, I could I expect wrap each $$...$$ in <span class=HID> </span>, and if necessary unhide it before calling Typeset().  But it would be better to do it "your" way, which I have not yet found.

Either of the suggestions above should do it.

Davide
Reply all
Reply to author
Forward
0 new messages