Table format of export MMD => Latex

Hello,

I have used the Scrivener documentation scrivener project as a template for my own publishing process. Really helped to shortcut a lot of things.

I have a question regarding tables now. When I export my project with compile for “MultiMarkDown => Latex .tex” and the Project Format “User Manual (Mac Latex)” the captions of the table are positioned before the actual table.
This results in Latex rendering it above the table which is a bit weird.

[code]\begin{table}[htbp]
\begin{minipage}{\linewidth}
\setlength{\tymax}{0.5\linewidth}
\centering
\small
\caption{Einstufungsübersicht Selbsttest}
\label{einstufungsübersichtselbsttest}
\begin{tabulary}{\textwidth}{@{}cc@{}} \toprule
Anzahl Programmiervorgänge & Einstufung \
\midrule

1 bis 2 & Echter Profi \
3 bis 5 & Sollte normal sein \
6 bis 10 & Noch Anfänger \
Über 11 & Ungeübter Anfänger \
\bottomrule

\end{tabulary}
\end{minipage}
\end{table}
[/code]

(How) Can I change that export format of tables?

Thanks
Christian

This isn’t something the Scrivener project or its post-processing scripts is doing, but rather MultiMarkdown’s way of making tables. To the best of my knowledge there is no way to override that easily.

What you would have to do is something similar to how the project’s scripting works. If you take a look at the Ruby script that is embedded in the Processing pane, you will find a section toward the bottom that handles the project’s mechanism for inserting custom tabulary lines. It locates and stores the tabulary line along with the caption for the table, and then continues processing the .tex file line by line until it locates the table identified by that caption, and then replaces the tabulary line. With a few small tweaks you could adjust that to remove the label and caption, wait until it encounters the \end{tabulary} command, and then insert them above that line.

But you may want to search around a bit for a better solution in MMD discussion areas, especially if Ruby isn’t something you’re familiar with.

Glad to hear the project has been helpful to you!

That’s what I thought. I have done this already actually and I am sharing my answer in PHP as maybe it might be of use for somebody else.

I have a preprocessing script in PHP and this simple replaces the line with an empty string and adds it after the table again.

[code]// 6) move caption of tables below the table
$re = ‘/\\begin{table}(.)(\\caption{(.)})(.*)\\end{table}/sUm’;
$cleaned = preg_replace_callback($re, ‘moveTableCaption’, $cleaned);

/**

  • Callback function for moving caption
    */
    function moveTableCaption($textArray) {
    $text = $textArray[0];
    print “\n\n”;
    $captionLine = $textArray[2];
    // delete upper caption
    $text = str_replace($captionLine, “”, $text);
    // add caption below table
    $text = str_replace("\end{tabulary}", “\end{tabulary}\n” . $captionLine, $text);
    return $text;
    }[/code]

Christian

Is there a way to call the preprocessing script automatically? I always run it from the console manually…

Yup! That’s the Processing compile format pane I was referring you to take a look at. You can put any kind of shell script in there. In the user manual project the script is embedded in the compile settings, but on my own system I keep the script in the path and have the compiler execute it that way.