| 2338 | |
| 2339 | |
| 2340 | static void |
| 2341 | print_latex_text(const printTableContent *cont, FILE *fout) |
| 2342 | { |
| 2343 | bool opt_tuples_only = cont->opt->tuples_only; |
| 2344 | unsigned short opt_border = cont->opt->border; |
| 2345 | unsigned int i; |
| 2346 | const char *const *ptr; |
| 2347 | |
| 2348 | if (cancel_pressed) |
| 2349 | return; |
| 2350 | |
| 2351 | if (opt_border > 3) |
| 2352 | opt_border = 3; |
| 2353 | |
| 2354 | if (cont->opt->start_table) |
| 2355 | { |
| 2356 | /* print title */ |
| 2357 | if (!opt_tuples_only && cont->title) |
| 2358 | { |
| 2359 | fputs("\\begin{center}\n", fout); |
| 2360 | latex_escaped_print(cont->title, fout); |
| 2361 | fputs("\n\\end{center}\n\n", fout); |
| 2362 | } |
| 2363 | |
| 2364 | /* begin environment and set alignments and borders */ |
| 2365 | fputs("\\begin{tabular}{", fout); |
| 2366 | |
| 2367 | if (opt_border >= 2) |
| 2368 | fputs("| ", fout); |
| 2369 | for (i = 0; i < cont->ncolumns; i++) |
| 2370 | { |
| 2371 | fputc(*(cont->aligns + i), fout); |
| 2372 | if (opt_border != 0 && i < cont->ncolumns - 1) |
| 2373 | fputs(" | ", fout); |
| 2374 | } |
| 2375 | if (opt_border >= 2) |
| 2376 | fputs(" |", fout); |
| 2377 | |
| 2378 | fputs("}\n", fout); |
| 2379 | |
| 2380 | if (!opt_tuples_only && opt_border >= 2) |
| 2381 | fputs("\\hline\n", fout); |
| 2382 | |
| 2383 | /* print headers */ |
| 2384 | if (!opt_tuples_only) |
| 2385 | { |
| 2386 | for (i = 0, ptr = cont->headers; i < cont->ncolumns; i++, ptr++) |
| 2387 | { |
| 2388 | if (i != 0) |
| 2389 | fputs(" & ", fout); |
| 2390 | fputs("\\textit{", fout); |
| 2391 | latex_escaped_print(*ptr, fout); |
| 2392 | fputc('}', fout); |
| 2393 | } |
| 2394 | fputs(" \\\\\n", fout); |
| 2395 | fputs("\\hline\n", fout); |
| 2396 | } |
| 2397 | } |
no test coverage detected