Insert Latex Table

I have a macro which inserts a Markdown Table. The macro was originally developed by the person behind www.rocketink.net. What it does is: When hit the trigger, the macro asks for a user input--the number of columns and rows required for the table. It perfectly works for Markdown Table. I was trying to port it to Latex table. But, I am not able to make it perfect. Can you guys help me?

Create Latex Table.kmmacros (8.5 KB)

In its current state, it is able to generate a table like:
`\begin{tabular}{l|l|l}

& Title & Title & Title & Title
& Cell & Cell & Cell & Cell
& Cell & Cell & Cell & Cell
& Cell & Cell & Cell & Cell
& Cell & Cell & Cell & Cell
& Cell & Cell & Cell & Cell
& Cell & Cell & Cell & Cell
& Cell & Cell & Cell & Cell
& Cell & Cell & Cell & Cell

\end{tabular}`

What I want it to be is like this:

`\begin{tabular}{l|l|l}

& Title & Title & Title & Title \\
& Cell & Cell & Cell & Cell \\
& Cell & Cell & Cell & Cell \\
& Cell & Cell & Cell & Cell \\
& Cell & Cell & Cell & Cell \\
& Cell & Cell & Cell & Cell \\
& Cell & Cell & Cell & Cell \\
& Cell & Cell & Cell & Cell \\
& Cell & Cell & Cell & Cell \\

\end{tabular}`

This one works (for me):

Create Latex Table [rev 1].kmmacros (9.3 KB)

The changed or added actions are green. I only made minimal changes, in 2 shell scripts.

The added ⌘LeftArrow was necessary for correct placing of the table body, also the little pause after the Arrow and Return actions. But the whole placing system still is a bit messy :wink:

***

Yes, it is working perfectly. Thank you very much. The placement is fine; I can put it into a variable if it fails. The shell script was the hard part for me.

I already was wondering why you were doing everything with shell scripts. I thought it was maybe for learning purposes :slight_smile:

Actually you can do the whole thing without a single line of shell script. And it’s easier, shorter and faster:


Create LaTeX Table (Ver 2).kmmacros (6.9 KB)

1 Like

I just copied it from the original; I am not actually learning Shell. I just want to use the tool because I find it extremely useful since I have to insert a lot of tables for my dissertation.

Thank you very much. Yes, this one is much faster.