Commit 04d4a248 authored by Jason Rhinelander's avatar Jason Rhinelander

Improve latex equation output

- in the general latex tabulation, use a minipage instead of a
  \nopagebreak; the latter only prevents page breaks at once location,
  but does nothing about page-breaks in the title that appears right
  before it (so half the equation could end up at the bottom of a
  page/column, and the other half at the top of the next page/column).
  Putting the whole thing in a minipage fixes that.

- Don't put a \n before the equation: under latex, it becomes a \\, but
  the \\ is in an invalid location and generates "no line to end here"
  errors.
parent f5b1093d
......@@ -172,8 +172,9 @@ std::string tabulate_latex(
#define E(s) escape(s, options)
latex << "\\begin{center}\n\n";
if (not options.title.empty()) latex << std::regex_replace(E(options.title), std::regex("(?=\n)"), "\\\\") << "\n\\nopagebreak\\\\\n";
latex << "\\begin{minipage}{\\linewidth}\\begin{center}\n\n";
if (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");
for (int i = 0; i < matrix.cols(); i++) latex << (options.dot_align ? "r@{.}l" : "r");
......@@ -269,7 +270,7 @@ std::string tabulate_latex(
latex << " \\\\\n";
}
latex << "\\end{tabular}\n\n\\end{center}\n";
latex << "\\end{tabular}\n\n\\end{center}\\end{minipage}\n\n";
if (options.postamble) latex << tabulate_postamble(options);
......
......@@ -391,7 +391,7 @@ int main(int argc, char *argv[]) {
for (unsigned j = 0; j < avg_effects.equations().size(); j++) {
auto &eq = avg_effects.equations()[j];
std::ostringstream title;
title << "\nEquation " << j+1 << ": " << eq << ":";
title << (args.format.latex ? "" : "\n") << "Equation " << j+1 << ": " << eq << ":";
avg_opts.title = title.str();
out << tabulate(avg_effects.summary(j), avg_opts, avg_effects.varNames(j), {"Coefficient", "std.err.", "t-stat", "p-value"}, avg_effects.pStars(j));
......
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