Developing Mathjax 3.2.2

38 views
Skip to first unread message

jox joe

unread,
Oct 30, 2024, 3:28:16 PM10/30/24
to MathJax Development
Hello Davide,

001: environment
Mathjax 3.2.2
I use the svg output processor.
Firefox, Google Chrome

002: code snippet/Tex
begin{align}
&=first\\[10ex]
&=second\\[0ex]
end{align}

003: code snippet/Typescript from 3.2.2
/**
 * Handle newline outside array.
 * @param {TexParser} parser The calling parser.
 * @param {string} name The macro name.
 * @param {boolean} nobrackets Flag indicating if newline is followed by
 *     brackets.
 */
BaseMethods.CrLaTeX = function(parser: TexParser, name: string, nobrackets: boolean = false) {
  let n: string;
  if (!nobrackets) {
    // TODO: spaces before * and [ are not allowed in AMS environments like align, but
    //       should be allowed in array and eqnarray.  This distinction should be honored here.
    if (parser.string.charAt(parser.i) === '*') {  // The * controls page breaking, so ignore it
      parser.i++;
    }
    if (parser.string.charAt(parser.i) === '[') {
      let dim = parser.GetBrackets(name, '');
      let [value, unit, ] = ParseUtil.matchDimen(dim);
      // @test Custom Linebreak
      if (dim && !value) {
        // @test Dimension Error
        throw new TexError('BracketMustBeDimension',
                           'Bracket argument to %1 must be a dimension', parser.currentCS);
      }
      n = value + unit;
      let message: string = n;
alert(message);

}
  }
  parser.Push(
    parser.itemFactory.create('cell').setProperties({isCR: true, name: name, linebreak: true})
  );
  const top = parser.stack.Top();
  let node: MmlNode;
   
  if (top instanceof sitem.ArrayItem)
  {
    // @test Array
    if (n)
    {
      top.addRowSpacing(n);
    }
   
  }
  else
  {
    if (n)
    {
      // @test Custom Linebreak
      node = parser.create('node', 'mspace', [], {depth: n});
      parser.Push(node);
    }
    // @test Linebreak
    node = parser.create('node', 'mspace', [], {linebreak: TexConstant.LineBreak.NEWLINE});
    parser.Push(node);
  }
 
};

004: my question

from 002: \\[10ex]  <- the distance between two lines
from 003: n = value + unit;  <- n contains the number and the unit 
The number can be negative or positive, but the subsequent
modules limit its absolute value.

In which part of the source code can I change
this behaviour?
I want to move the lines to anywhere on the page,
left, right, up and down.

005: recompiling Mathjax 3.2.2
I modified the Typescript source
and I could recompile and test the full
application successfully.

006: question
When are you going to publish
the "final" version of Mathjax 4?

Thank you.
joe




jox joe

unread,
Oct 31, 2024, 8:34:02 AM10/31/24
to MathJax Development
Hi Davide,

*********************
*** 01/ environment
Mathjax 3.2.0    (3.2.2)
I use the svg output processor.
Firefox, Google Chrome

*********************
*** 02/ code/Tex

%BEGIN code
\begin{align}

%ROW 01
&
%\smash{\Rule{10px}{20px}{10px}}
\color{green}
\smash{\Rule{717.9px}{10px}{2pt}}
\\[0.0pt]

%ROW 02
&
\color{red}
\smash{\Rule{10px}{20px}{176.9px}}
\hspace{200px}
\color{black}{\boldsymbol{\mathsf{Huntington \,1904\,Boolean\, algebra\, axioms}}}
\hspace{170px}
\smash{\Rule{10px}{20px}{185.9px}}
\\[0.0pt]

%ROW 03
&
%\smash{\Rule{10px}{20px}{10px}}
\color{blue}
\smash{\Rule{717.8px}{10px}{2pt}}
\\[0.0pt]

%ROW 04
&
%\smash{\Rule{10px}{20px}{10px}}
\hspace{100px}
\color{black}{\boldsymbol{\mathsf{AND}}}
\hspace{129px}
\smash{\Rule{10px}{20px}{126px}}%%%%
\hspace{124px}
\color{black}{\boldsymbol{\mathsf{OR}}}
\hspace{124px}
\smash{\Rule{10px}{20px}{126px}}%%%%%%%
\hspace{10px}
\color{black}{\boldsymbol{\mathsf{Name}}}
\hspace{80.9px}
%\smash{\Rule{10px}{20px}{230px}}
\\[-10.0pt]

%ROW 05
&
%\smash{\Rule{10px}{20px}{10px}}
\color{black}
\smash{\Rule{710px}{10px}{2pt}}
\\[0.0pt]


%ROW 06
&
%\smash{\Rule{10px}{20px}{10px}}
\hspace{20px}
\color{black}{\boldsymbol{\mathsf{x \,  {\raise 1px \Huge {_\cdot}}   1 = x  }}}
\hspace{190.9px}
%\smash{\Rule{10px}{20px}{10px}}
\hspace{10px}
\color{black}{\boldsymbol{\mathsf{x+ 0 = x \,  }}}
\hspace{194.7px}
%\smash{\Rule{10px}{20px}{10px}}
\hspace{10.0px}
\color{black}{\boldsymbol{\mathsf{Identity}}}
\hspace{69.1px}
%\smash{\Rule{10px}{20px}{10px}}
\\[-0.0pt]

%ROW 07
&
%\smash{\Rule{10px}{20px}{10px}}
\hspace{20px}
\color{black}{\boldsymbol{\mathsf{x\,  {\raise 1px \Huge {_\cdot} }      \, y = y \, {\raise 1px \Huge {_\cdot} } \,      x}}}
\hspace{149.9px}
%\smash{\Rule{10px}{20px}{10px}}
\hspace{20.0px}
\color{black}{\boldsymbol{\mathsf{x+ y = y+ x}}}
\hspace{155.8px}
%\smash{\Rule{10px}{20px}{10px}}
\hspace{20.0px}
\color{black}{\boldsymbol{\mathsf{Commutativity}}}
\hspace{10.0px}
%\smash{\Rule{10px}{20px}{10px}}
\\[0.0ex]


%ROW 08
&
%\smash{\Rule{10px}{20px}{10px}}
\hspace{20px}
\color{black}{\boldsymbol{\mathsf{x \, {\raise 1px \Huge {_\cdot}} \, (y+z) = (x \, {\raise 1px \Huge {_\cdot}} \, y) + (x \, {\raise 1px \Huge {_\cdot}} \, z) }}}
\hspace{20px}
%\smash{\Rule{10px}{20px}{10px}}
\hspace{10px}
\color{black}{\boldsymbol{\mathsf{   x + (y \,{\raise 1px \Huge {_\cdot}}\, z) = (x+ y) \,{\raise 1px \Huge {_\cdot}}\, (x+ z)  \,  \color{red}{!} }}}
\hspace{20px}
%\smash{\Rule{10px}{20px}{10px}}
\hspace{10.0px}
\color{black}{\boldsymbol{\mathsf{Distributivity}}}
\hspace{25.7px}
%\smash{\Rule{10px}{20px}{10px}}
\\[0.0ex]


%ROW 09
&
%\smash{\Rule{10px}{20px}{10px}}
\hspace{20px}
\color{black}{\boldsymbol{\mathsf{x \,  {\raise 1px \Huge {_\cdot}}  \, \bar x = 0 }}}
\hspace{187.9px}
%\smash{\Rule{10px}{20px}{15px}}
\hspace{10.0px}

\color{black}{\boldsymbol{\mathsf{   {x + \bar x = 1} }}}
\hspace{187.6px}
%\smash{\Rule{10px}{20px}{15px}}
\hspace{20.0px}
\color{black}{\boldsymbol{\mathsf{ Complements}}}
\hspace{20.9px}
%\smash{\Rule{10px}{20px}{18px}}
\\[0.0ex]

%ROW 10
&
%\smash{\Rule{10px}{20px}{3.5px}}
\color{green}
\smash{\Rule{717.9px}{10px}{2pt}}
\\[0.0pt]

\end{align}
%END code

*********************
*** 03/ evaluation/question
The Tex code above is a table.

I used
\smash{}
and
\hspace{}
for positioning the objects.
Both set relative coordinates
so this solution is some sort
of "hacking".

It would be good to have absolute/world
coordinates to position the objects with less code.
The origo of the coordinate system could
be the top left corner of the page or the top
left element, for example.

What is your opinion?

Thank you.
joe  

jox joe

unread,
Nov 5, 2024, 3:19:23 PM11/5/24
to MathJax Development
Hi Davide,

*********************
*** 01/ environment
Mathjax 3.2.0    (3.2.2)
I use the svg output processor.
Firefox, Google Chrome

*********************
*** 02/ question
I can modify the code point content in normal.ts manually
adding the SVG path.
I'd like to add new character using the Unicode
Private Use Area (PUA).
If I add it to normal.ts I can see only bitpattern characters.
Apart from normal.ts,
which other files should I modify to do this?

Thank you,
joe

Davide Cervone

unread,
Nov 10, 2024, 7:41:45 AM11/10/24
to mathj...@googlegroups.com
> The number can be negative or positive, but the subsequent
> modules limit its absolute value.

Correct. Because alignments are stored as MathML mtable elements, the \\[...] values are used to adjust the rowspacing attribute. The MathML spec doesn't allow that value to be less than 0. That is why a negative value is never used.

> In which part of the source code can I change
> this behaviour?

You should not do that, as it is against the spec.

> I want to move the lines to anywhere on the page,
> left, right, up and down.

MathJax is not designed to be a general layout engine for the page. That is what HTML is for. You can use an absolutely positioned HTML element containing a math expression to do this. It is inappropriate to use a MathJax alignment to try to accomplish this.

It is also possible to use \newcommand{\position}[3]{\rlap{\hskip{#1}\raise #2{\smash{#3}}} or something similar to position an expression arbitrarily in relation to the position of the math expression. If the expression is at the top left of the page, that may be enough to get what you are trying to do.

It is also possible to use the \style macro to add CSS to place a subexpression relative to the first positioned parent item of the math; for example

\style{position: absolute; left:2em; top:3em}{x}

should do that.

> When are you going to publish
> the "final" version of Mathjax 4?

When everything is ready. I am not sure when that will be. We are dealing with some issues with the new explorer paradigm, and are in the process of doing a major code cleanup before the release. We hope it will be soon.

Davide

Davide Cervone

unread,
Nov 10, 2024, 7:45:38 AM11/10/24
to mathj...@googlegroups.com
I used
\smash{}
and
\hspace{}
for positioning the objects.

I suggest \rlap and \raise (or \lower) for this in my previous message.

It would be good to have absolute/world
coordinates to position the objects with less code.
The origo of the coordinate system could
be the top left corner of the page or the top
left element, for example. 

What is your opinion?

This is outside the scope of MathJax's mission, and not something I would be in favor of.  I suggested a way to use CSS to do this in my previous message, though I still think it is  not an appropriate use of MathJax.  HTML and CSS is the correct framework for that.

Davide

Davide Cervone

unread,
Nov 10, 2024, 7:47:51 AM11/10/24
to mathj...@googlegroups.com
I can modify the code point content in normal.ts manually
adding the SVG path.
I'd like to add new character using the Unicode
Private Use Area (PUA).
If I add it to normal.ts I can see only bitpattern characters.
Apart from normal.ts,
which other files should I modify to do this?

If you mean you have edited ts/output/svg/fonts/tex/normal.ts, then you also need to edit ts/output/common/fonts/tex/normal.ts, which is where the character metrics are stored.  That is the one that actually tells MathJax that a character is available.  The svg-specific file only adds the path to the existing metric data, and if that isn't there, the character will not be found by MathJax.

Davide


Reply all
Reply to author
Forward
0 new messages