Commit a439d0df authored by Jason Rhinelander's avatar Jason Rhinelander

Added option to print the table title as caption

parent 04d4a248
......@@ -173,7 +173,8 @@ std::string tabulate_latex(
#define E(s) escape(s, options)
latex << "\\begin{minipage}{\\linewidth}\\begin{center}\n\n";
if (not options.title.empty()) latex << std::regex_replace(E(options.title), std::regex("(?=\n)"), "\\\\")
if (not options.title_as_caption and not options.title.empty())
latex << std::regex_replace(E(options.title), std::regex("(?=\n)"), "\\\\")
<< "\n\\\\\n";
latex << "\\begin{tabular}{" << (options.rows_align_left ? "l" : "r");
......@@ -270,7 +271,10 @@ std::string tabulate_latex(
latex << " \\\\\n";
}
latex << "\\end{tabular}\n\n\\end{center}\\end{minipage}\n\n";
latex << "\\end{tabular}\n";
if (options.title_as_caption and not options.title.empty())
latex << "\\captionfor{table}{" << options.title << "}\n";
latex << "\n\\end{center}\\end{minipage}\n\n";
if (options.postamble) latex << tabulate_postamble(options);
......
......@@ -29,6 +29,10 @@ struct tabulation_options {
* format-specific way. If empty (the default) no heading precedes the data.
*/
std::string title;
/** If true, show the title as a caption under the table instead of showing it before the table.
* Only current has an effect in LaTeX mode.
*/
bool title_as_caption = false;
/** Whether to escape special characters (default) or leave them in formatted output. This has
* no effect for Text format, but matters for LaTeX (to escape things like %, _, etc.) and HTML
* (<, &, etc.).
......
......@@ -251,11 +251,9 @@ int main(int argc, char *argv[]) {
d == &data_no_pre_writing ? "without pre-piracy writing" :
d == &data_no_piracy_writing ? "with no piracy writing, but recovery under the policy" :
d == &data_no_post_writing ? "without piracy or policy writing" :
"with piracy writing but not policy writing") + ":";
if (args.format.latex) {
param_opts.title = "\\underline{\\normalsize{" + param_opts.title + "}\\nopagebreak}\\nopagebreak";
}
"with piracy writing but not policy writing") +
(args.format.latex ? "" : ":");
if (args.format.latex) param_opts.title_as_caption = true;
std::vector<std::string> local_params, local_params_abbrev;
for (size_t i = 0; i < params.size(); i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment