opencollab / jlatexmath

A Java API to render LaTeX
Other
514 stars 109 forks source link

ArrayOptions IndexOutOfBoundsException #62

Open ljyao opened 4 years ago

ljyao commented 4 years ago

ArrayOptions

 fun getAlignment(i: Int): TeXConstants.Align {
        return options[i + 1].alignment
    }

There is a problem with this function

 public ArrayOptions complete(final int n) {
        final int s = options.size();
        for (int i = 0; i < n - s; ++i) {
            addAlignment(TeXConstants.Align.CENTER);
        }
        return this;
    }

Because its options.size == n+1 ,Should be like this for (int i = 0; i <= n - s; ++i)

Test case

\begin{array}{cc}{-6-10} & {6-0} & {0+10} \\{9-35}& {3-5} & {12-30}\end{array}
murkle commented 4 years ago

Does it work in the "experimental" branch?

ljyao commented 4 years ago

Does it work in the "experimental" branch?

No, you can test this test case

\begin{array}{cc}{-6-10} & {6-0} & {0+10} \{9-35}& {3-5} & {12-30}\end{array}

murkle commented 4 years ago

Are you sure your syntax is right? It looks a bit odd eg \{

Try {\begin{array}{cc}-6-10&9-35 \\ 6-0&3-5 \\ 0+10&12-30 \\ \end{array}}

ljyao commented 4 years ago

Are you sure your syntax is right? It looks a bit odd eg \{

Try {\begin{array}{cc}-6-10&9-35 \\ 6-0&3-5 \\ 0+10&12-30 \\ \end{array}}

Sorry,\ should be\\

\begin{array}{cc} {-6-10} & {6-0} & {0+10} \\{9-35}& {3-5} & {12-30}\end{array}
murkle commented 4 years ago

So there's a "c" missing - try:

\begin{array}{ccc} {-6-10} & {6-0} & {0+10} \\{9-35}& {3-5} & {12-30}\end{array}

ljyao commented 4 years ago

So there's a "c" missing - try:

\begin{array}{ccc} {-6-10} & {6-0} & {0+10} \\{9-35}& {3-5} & {12-30}\end{array}

So what does ArrayOptions. complete function mean?

The following align parameter can be missing

calixteman commented 4 years ago

You're right the goal is to have auto "c" for missing specifiers. Feel free to propose a patch and a test (https://github.com/opencollab/jlatexmath/tree/experimental/jlatexmath/src/test/resources)