3

Background

Using Pandoc to generate tables that are sourced from an R Markdown document.

Problem

Pandoc does not have a way to override the code generated for a Markdown table. As such, there does not seem to be a way to instruct Pandoc to include here or split. That is, Pandoc cannot generate the following code:

\startplacetable[location={here, split}]

Minimum Working Example

The following code shows the problem:

\starttext
\startplacetable[title={Average Annual Temperatures}]
\startxtable
\startxtablehead[head]
\startxrow
\startxcell[align=middle,width={0.10\textwidth}] Year \stopxcell
\startxcell[align=middle,width={0.14\textwidth}] Value \stopxcell
\stopxrow
\stopxtablehead
\startxtablebody[body]
\dorecurse{100}{%
\startxrow
\startxcell[align=middle,width={0.10\textwidth}] 1880 \stopxcell
\startxcell[align=middle,width={0.14\textwidth}] 0.1146 \stopxcell
\stopxrow}
\stopxtablebody
\startxtablefoot[foot]
\startxrow
\startxcell[align=middle,width={0.10\textwidth}] 2018 \stopxcell
\startxcell[align=middle,width={0.14\textwidth}] 1.014 \stopxcell
\stopxrow
\stopxtablefoot
\stopxtable
\stopplacetable
\stoptext

This produces:

No Table Split

Changing the startplacetable command options produces the desired result, but requires modifying the output generated from pandoc:

\startplacetable[title={Average Annual Temperatures}, location={here,split}]

Splitting across pages is enabled:

Split Table

Ideas

My first instinct was to change the setups for table:

\setupfloat[table][location={here,split}]

This didn't work because the location parameter for the \setupfloat macro is different than the location option for the \startplacetable macro.

In the past, I've used sed in shell scripts to replace \startplacetable with \startplacetable[location={split}], but that's a brittle solution.

Using \setupxtable's split=yes option doesn't work, either, probably because the extreme table is embedded within a captioned float:

\setupxtable[frame=off,split=yes,header=repeat,footer=repeat]

Another idea is to redefine \startplacetable. Something like:

\def\oldstartplacetable\startplacetable

\define[1]\startplacetable{
  \oldstartplacetable[#1,location={split}]
}

That doesn't compile, though.

Question

Without changing the code generated by pandoc, how would you allow all extreme tables inside a \startplacetable environment to split across pages?

4

The default location for floats is not called location but default.

\setupfloat[table][default={here,split}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.