Is it possible to change the linebreaks settings with Javascript after MathJax has typeset content?

205 views
Skip to first unread message

Peter Gibney

unread,
Dec 7, 2013, 2:13:02 PM12/7/13
to mathja...@googlegroups.com
Hi,

Is it possible to change the linebreaks settings with Javascript after MathJax has typeset content?

I wish to turn on/off automatic and change the container setting interactively using Javascript, I have already set them in: "HTML-CSS":{ linebreaks: { automatic: true, width: "90% container"},

At the moment I am opening the page in the browser, looking at the rendered equations, then editing the page and changing say the nn in "nn% container" and then reloading the page.

I am sure that there is a more elegant way than this but I have searched for answers without success.

I would be most obliged for any assistance.

Peter

Peter Krautzberger

unread,
Dec 7, 2013, 2:56:55 PM12/7/13
to mathja...@googlegroups.com
Hi,


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

should get you started.

Peter,


--
You received this message because you are subscribed to the Google Groups "MathJax Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mathjax-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Peter Gibney

unread,
Dec 7, 2013, 3:44:12 PM12/7/13
to mathja...@googlegroups.com
Thank you Peter,

I am afraid that I did not spell out what I wanted very well.

I want a function that will allow me change for example controls how wide the lines of mathematics can be, instead of having fixed in what I coded in 
MathJax.Hub.Config(.... "HTML-CSS":{  linebreaks: { automatic: true, width: "99% container"},

I would like to be able to write a function

function changeWidth(wide){
  linebreaks.width = wide+"em";
}

Many thanks,

Peter

Peter Krautzberger

unread,
Dec 7, 2013, 6:30:35 PM12/7/13
to mathja...@googlegroups.com

Sorry, I don't understand what you are after.

Peter.

Davide P. Cervone

unread,
Dec 7, 2013, 6:48:24 PM12/7/13
to mathja...@googlegroups.com
You could try

function changeWidth(wide){
  MathJax.Hub.Queue(
    ["Config",MathJax.Hub,{"HTML-CSS": {linebreaks: {width: wide+"em"}}}],
    ["Rerender",MathJax.Hub]
  );
}

which should change the line break width and then re-render the page.

Davide

Peter Gibney

unread,
Dec 8, 2013, 9:52:44 AM12/8/13
to mathja...@googlegroups.com, dp...@union.edu
Thank you Davide.

That does exactly what I want it to do.

Is it possible for me to read the width?  I am incrementing/decrementing the width and at the moment I am storing the previous value in a global variable, incrementing/decrementing that and then writing it to MathJax using the function that you provided.

I have noticed that text content is not word wrapped for long lines, that is text that is entered using \text{Lorem...} even it it contains spaces.

In order to get long lines of text wrapped I have to replace all occurrences of white space with }\phantom{.}\text{ as in the following example:

\text{Lorem}\phantom{.}\text{Ipsum}\phantom{.}\text{is}\phantom{.}\text{simply}\phantom{.}\text{dummy}\phantom{.}\text{text}\phantom{.}\text{of}\phantom{.}\text{the}\phantom{.}\text{printing}\phantom{.}\text{and}\phantom{.}\text{typesetting}\phantom{.}\text{industry.}

This is wrapped perfectly at the spaces created by \phantom{.} but the new lines now have a leading white space.

My application is dynamic in the sense that text and maths are read in one place from a textarea input and then processed to some extent and then written to a SPAN and then MathJax typesets and renders the content of the span and displays it in the span.  I could make replacing all my white spaces in the text portion of the input part of the processing and accept the leading space on the wrapped lines if there is no other solution.  Have you any suggestons?

Many thanks again for the function changeWidth(wide)

Peter

Peter Gibney

unread,
Dec 11, 2013, 4:59:28 PM12/11/13
to mathja...@googlegroups.com, dp...@union.edu
Hi,

Has anyone any thoughts about this.  To recap: text that is entered using \text{...} is not wrapped.  If I want to display with wrap say "Lorem Ipsum is simply dummy text of the printing and typesetting industry." I have to break up each word and wrap each word with \text{.....}\phantom{.}   So my Lorem Ipsun becomes:  \text{Lorem}\phantom{.}\text{
Ipsum}\phantom{.}\text{is}\phantom{.}\text{simply}\phantom{.}\text{dummy}\phantom{.}\text{text}\phantom{.}\text{of}\phantom{.}\text{the}\phantom{.}\text{printing}\phantom{.}\text{and}\phantom{.}\text{typesetting}\phantom{.}\text{industry.}  This will wrap but when it is wrapped the lines after the first line all have a leading space.  Were it not for the leading spaces I could write a preprocessor that if I put the text that I want rendered as text between \text{full sentence goes here} the preprocessor will strip out each word and replace each word with \text{.....}\phantom{.} 

In one regard it is great that MathJax can word wrap lines of math but it is a drawback that it is unable to automatically word wrap a string of text.

All help would be greatly received.

Many thanks,
Reply all
Reply to author
Forward
0 new messages