Giter Club home page Giter Club logo

Comments (13)

laughinghan avatar laughinghan commented on May 17, 2024
  1. yep, same went for \sqrt[n]{} and still goes for whitespace (\,,
    \:, \;, \!)
  2. yeah, \vector is meant for column vectors:
    http://en.wikipedia.org/wiki/Column_vector
    matrices are basically not supported at all. If you like, you could try
    implementing a \matrix command that's similar to \vector but uses
    <table><tr><td></table> as it's html_template. You may have to override
    MathCommand::initBlocks.

Han

On Fri, Apr 22, 2011 at 12:37 PM, jenseng <
[email protected]>wrote:

it looks like there are a couple problems around matrices:

  1. when you create a matrix in mathquill, the generated latex cannot
    actually be parsed by mathquill. e.g. typing \vectorab
    gives you the latex \begin{matrix}a\b\end{matrix}. when you try to
    write that to mathquill, the rendered latex in mathquill just looks like
    begin{matrix.
  2. mathquill matrices don't really support columns. you can separate
    elements in a row with spaces, but you can't actually make true columns
    (separated by &) in latex. the effect is that it's difficult/impossible to
    get your columns lined up when cells are different sizes. e.g. we should be
    able to do stuff like this: http://latex.codecogs.com/gif.latex
    ?\begin{matrix}a+1&b\c&d\end{matrix}

Reply to this email directly or view it on GitHub:
https://github.com/laughinghan/mathquill/issues/31

from mathquill.

jenseng avatar jenseng commented on May 17, 2024

k that makes sense, i'll take a stab at it ... i guess the only real issue with vectors is that mathquill doesn't parse the generated latex. that might be a little tricky to fix short of implementing matrices

from mathquill.

laughinghan avatar laughinghan commented on May 17, 2024

from mathquill.

jenseng avatar jenseng commented on May 17, 2024

what, two weeks of working with LaTeX doesn't make me an expert? :P

if i do anything around this, it'll be in its own experimental branch

from mathquill.

andpap avatar andpap commented on May 17, 2024

just intresting how current selection will work with table

<table>
<tr>
<span class="selection">
<td>1<td><td>2
</span>
<tr><td>3<td><td>4<td></tr>
</table>

from mathquill.

laughinghan avatar laughinghan commented on May 17, 2024

uh, does it? It would depend a lot on how the table is represented in the Math DOM

from mathquill.

andpap avatar andpap commented on May 17, 2024

Does it means that I can not to select a row? just td or table

from mathquill.

andpap avatar andpap commented on May 17, 2024

Matrix draft version

.mathquill-rendered-math .mtable {
  text-align: center;
  display: inline-table;
}

.mathquill-rendered-math .mtr {
  margin: .2em 0;
  display: table-row !important;
  display: block;
}

.mathquill-rendered-math .mtd {
  white-space: nowrap;
  padding: 0 .1em;
  display:table-cell !important;
  display:inline-block;
}


function Matrix(replacedFragment) {
  MathCommand.call(this, '\\matrix', undefined, undefined, replacedFragment);
}
_ = Matrix.prototype = new MathCommand;
_.html_template = ['&lt;table class="mtable">&lt;tr class="mtr">&lt;td class="mtd">&lt;/td>&lt;/tr>&lt;/table>'];

_.initBlocks = function(replacedFragment) {
  var self = this;

  var newBlock, prev;
  this.firstChild = newBlock = prev =
    (replacedFragment && replacedFragment.blockify()) || new MathBlock;

  newBlock.jQ = $("&lt;span>&lt;/span>")
    .data(jQueryDataKey, {block: newBlock})
    .append(newBlock.jQ)
    .appendTo(self.jQ.find("td"));

  newBlock.blur();
  self.lastChild = newBlock;
  newBlock.parent = self;
};

_.placeCursor = function(cursor) {
  this.cursor = cursor.appendTo(this.firstChild);
};

_.latex = function() {
  return '\\begin{matrix}' + this.foldChildren([], function(latex, child) {
    latex.push(child.latex());
    return latex;
  }).join('\\\\') + '\\end{matrix}';
};
_.text = function() {
  return '[' + this.foldChildren([], function(text, child) {
    text.push(child.text());
    return text;
  }).join() + ']';
}     

_.keydown = function(e) {
  var currentBlock = this.cursor.parent;
  var self = this;
  if (currentBlock.parent === this) {
    if (e.which === 13) { //enter
      var tr = $('tr:last', this.jQ).clone(true);
      var cb;
      tr.find("td").html('').each(function(){
        $(this).addClass("mtd");  
        var newBlock = new MathBlock;
        cb = cb || newBlock;
        newBlock.parent = self;
        newBlock.jQ = $('&lt;span>&lt;/span>').data(jQueryDataKey, {block: newBlock}).appendTo(this);
        newBlock.prev = self.lastChild;
        self.lastChild.next = newBlock; 
        self.lastChild = newBlock;
        self.cursor.appendTo(newBlock);
      });
      self.cursor.appendTo(cb).redraw();
      tr.appendTo(this.jQ);
      return false;
    }
    else if (e.which === 9 && !e.shiftKey && !currentBlock.next && self.jQ.find("tr").length == 1) { //tab
        var newBlock = new MathBlock;
        newBlock.parent = this;
        var td =  $('&lt;td class="mtd">&lt;/td>').appendTo(currentBlock.jQ.parent().parent());
        newBlock.jQ = $('&lt;span>&lt;/span>').data(jQueryDataKey, {block: newBlock}).appendTo(td);
        this.lastChild = newBlock;
        currentBlock.next = newBlock;
        newBlock.prev = currentBlock;
        this.cursor.appendTo(newBlock).redraw();
      return false;
    } else if (e.which === 8) { //backspace
      if (currentBlock.isEmpty()) {
        if (currentBlock.prev) {
          this.cursor.appendTo(currentBlock.prev);

        } else {
          this.cursor.insertBefore(this);
        }
        return false;
      }
      else if (!this.cursor.prev)
        return false;
    }
  }
  return this.parent.keydown(e);
};

from mathquill.

laughinghan avatar laughinghan commented on May 17, 2024

damn it you're right, you can't select tds or trs if Selection has to be a span. That's why array is currently implemented by having the children be display:block, which won't work well for more than one column, unless we hack it to set the width on redraw or something. An inline table clearly makes the most sense for matrices, it seems like what we should do is addClass('selection') to the trs.

I'm not sure how best to change the architecture to support that, perhaps some way of moving the selection methods Cursor::selectLeft, selectRight, selectFrom and Selection::levelUp to MathElement or something so they can be overridden.

from mathquill.

Srividyakrishnan avatar Srividyakrishnan commented on May 17, 2024

is it possible to type squareroot as sqrt as it is in desmos calculator and not as "\sqrt" ?

from mathquill.

maxtin avatar maxtin commented on May 17, 2024

I experienced this issue today ("begin{matrix") and wonder after 2 years if any update or fix is available somehow?

from mathquill.

jneen avatar jneen commented on May 17, 2024

The current plan is to simply remove the current implementation of \vector, which was never very well thought-through. We do have some ideas for making a table-based vector or matrix environment, but they'll need to be much more deeply integrated than that was, to avoid problems like this.

from mathquill.

jneen avatar jneen commented on May 17, 2024

See #187.

from mathquill.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.