JDMCreator / LaTeXTableEditor

readme
MIT License
143 stars 15 forks source link

Bug: Shrink columns adds single unopend \end{landscape} tag #59

Closed NielsKorschinsky closed 2 years ago

NielsKorschinsky commented 2 years ago

When using the Shrink columns BETA-feature a unwanted \end{landscape} tag is added at the very bottom, causing a latex error. Display table in landscape mode is disabled. Once the additional tag is removed, the code is fully working.

See screenshots below for full settings.

Generated code:


% \usepackage{array}
% \usepackage{colortbl}
% \usepackage{longtable}
% \usepackage{booktabs}

{
\begin{longtable}{|>{\hspace{0pt}}m{0.363\linewidth}|>{\hspace{0pt}}m{0.363\linewidth}|}
\caption{Zusätzliche Spalten für die Priorisierung der Metriken}\\ 
\toprule
\rowcolor[rgb]{0.753,0.749,0.737} \textbf{test} & \textbf{test}  \endfirsthead 
\hline
{\cellcolor[rgb]{0.965,0.961,0.957}}test        & test           \\ 
\hline
{\cellcolor[rgb]{0.965,0.961,0.957}}test        & test           \\ 
\hline
{\cellcolor[rgb]{0.965,0.961,0.957}}test        & test           \\
\bottomrule
\end{longtable}
\end{landscape}

image

image

NielsKorschinsky commented 2 years ago

After a short code-search I've found following code:

else if(rotateTable){
    str += "\\end{landscape}";
}

file js.js, line 4612

This is the only write occurrence of the landscape tag within the project, non v1. Therefore there must be an error with the rotateTable variable, getting true even though it should not be.

There are only two write occurrences on this certain variable, the initial setup from the user input and following code:

if(booktabColor){
    if(!rotateTable){
        firstPart += "{\n";
    }
    rotateTable += booktabColor
}

File js.js, line 4312

before some strings are written into the booktabColor, therefore I guess that this line must be a programming error. This is only a quick look into this, I do not have any insight which variable should be set instead of this. Comparing with other code around I guess the line should actually be:

if(booktabColor){
    if(!rotateTable){
        firstPart += "{\n";
    }
    firstPart += booktabColor
}

This is though only a guess without a valid testing or background check. I will open a pull request for this.

JDMCreator commented 2 years ago

Thank you for reporting this issue. It happened when the table used longtable, booktabs and background colors. Your fix indeed worked.

NielsKorschinsky commented 2 years ago

Hello @JDMCreator, Great to hear that this fix worked and you've implemented it. Though I would be grateful if you could also include the commits of others to honor their work within your project. Thanks a lot for your app, it's helping me create organized tables for my latex work.