jlatexmath icon indicating copy to clipboard operation
jlatexmath copied to clipboard

ArrayOptions IndexOutOfBoundsException

Open ljyao opened this issue 5 years ago • 7 comments

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}

ljyao avatar Dec 30 '19 08:12 ljyao

Does it work in the "experimental" branch?

murkle avatar Dec 30 '19 09:12 murkle

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}

ljyao avatar Dec 30 '19 09:12 ljyao

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}}

murkle avatar Dec 31 '19 11:12 murkle

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}

ljyao avatar Dec 31 '19 11:12 ljyao

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

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

murkle avatar Dec 31 '19 11:12 murkle

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

ljyao avatar Dec 31 '19 11:12 ljyao

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)

calixteman avatar Dec 31 '19 11:12 calixteman