YihangZhu / LaTeX-in-Google-Spreadsheet

A simple add-on for converting a Google spreadsheet table to a LaTeX table or a LaTeX table to a Google Spreadsheet table.
31 stars 1 forks source link

Can't do partial table #6

Closed karma-riuk closed 3 weeks ago

karma-riuk commented 3 weeks ago

When selecting an entire table, the extension works perfectly, but when you start un-selecting some columns, the extensions seems to "break".

Let me give an example:

If I have this table, I selected the entire table, then did a Ctrl-click through the C and E columns, my result is a table with only A, B and D columns. image

If I select the 'sheet->Latex' option, this is the result:

\begin{table}[!htp]\centering
\caption{Generated by Spread-LaTeX}\label{tab: }
\scriptsize
\begin{tabular}{lr}\toprule
D \\\midrule
21 \\
22 \\
23 \\
24 \\
\bottomrule
\end{tabular}
\end{table}

Note: the "focused cell" in the picture is the D column title cell.

If I then un-select and re-select the A column title, to place the "focused cell" in the top left corner, as in the following picture:

image

I get the following output:

\begin{table}[!htp]\centering
\caption{Generated by Spread-LaTeX}\label{tab: }
\scriptsize
\begin{tabular}{lrr}\toprule
A &B \\\midrule
hello &1 \\
world &2 \\
foo &3 \\
bar &4 \\
\bottomrule
\end{tabular}
\end{table}

It seems like the generated table is looking at where the "focused cell" is and not caring about any over selection outside of it.

Would it be possible to add those detached selections? I would like to use it because I have large tables, that fit well in the sheets view, but do not look good in the latex document.

Thanks in advance for your consideration.

Edit:

I didn't mention what my expected output would be, but just to be clear, with the selection in the above pictures, I would like the output the table with only the A, B and D columns:

\begin{table}[!htp]\centering
    \caption{Generated by Spread-LaTeX}\label{tab: }
    \scriptsize
    \begin{tabular}{lrrrrr}\toprule
        A     & B & D  \\\midrule
        hello & 1 & 21 \\
        world & 2 & 22 \\
        foo   & 3 & 23 \\
        bar   & 4 & 24 \\
        \bottomrule
    \end{tabular}
\end{table}
karma-riuk commented 3 weeks ago

After looking into the sheet class API, it looks like you might only need to use the [getActiveRangeList()](https://developers.google.com/apps-script/reference/spreadsheet/sheet#getActiveRangeList()) function instead of the current getActiveRange() at line 15 of the Sheet2Latex.js file. The rest of the code might probably need to be slightly updated though.

YihangZhu commented 3 weeks ago

Thanks for your suggestion. Let me check my code.

YihangZhu commented 3 weeks ago

The feature has been added.