Skip to content

Commit

Permalink
allow tables to exist inside footnotes in LaTeX
Browse files Browse the repository at this point in the history
  • Loading branch information
fletcher committed Jun 23, 2015
1 parent 18e3d55 commit bd9438d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
15 changes: 13 additions & 2 deletions latex.c
Expand Up @@ -663,7 +663,9 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
g_string_append_printf(out, "}}\\glsadd{%s}",temp_node->children->children->str);
} else {
g_string_append_printf(out, "\\footnote{");
scratch->inside_footnote = true;
print_latex_node_tree(out, temp_node->children, scratch);
scratch->inside_footnote = false;
g_string_append_printf(out, "}");
}
scratch->padded = 0;
Expand Down Expand Up @@ -826,9 +828,18 @@ void print_latex_node(GString *out, node *n, scratch_pad *scratch) {
break;
case TABLE:
pad(out, 2, scratch);
g_string_append_printf(out, "\\begin{table}[htbp]\n\\begin{minipage}{\\linewidth}\n\\setlength{\\tymax}{0.5\\linewidth}\n\\centering\n\\small\n");

if (!scratch->inside_footnote)
g_string_append_printf(out, "\\begin{table}[htbp]\n");

g_string_append_printf(out,"\\begin{minipage}{\\linewidth}\n\\setlength{\\tymax}{0.5\\linewidth}\n\\centering\n\\small\n");
print_latex_node_tree(out, n->children, scratch);
g_string_append_printf(out, "\n\\end{tabulary}\n\\end{minipage}\n\\end{table}");

g_string_append_printf(out, "\n\\end{tabulary}\n\\end{minipage}");

if (!scratch->inside_footnote)
g_string_append_printf(out, "\n\\end{table}");

scratch->padded = 0;
break;
case TABLESEPARATOR:
Expand Down
1 change: 1 addition & 0 deletions parse_utilities.c
Expand Up @@ -276,6 +276,7 @@ scratch_pad * mk_scratch_pad(unsigned long extensions) {
result->cell_type = 0;
result->table_alignment = NULL;
result->table_column = 0;
result->inside_footnote = 0;

if (extensions & EXT_RANDOM_FOOT) {
srand((int)time(NULL));
Expand Down
1 change: 1 addition & 0 deletions parser.h
Expand Up @@ -53,6 +53,7 @@ typedef struct {
int language; /* For smart quotes */
char *table_alignment; /* Hold the alignment string while parsing table */
int table_column; /* Track the current column number */
bool inside_footnote; /* Are we inside a footnote? */
char cell_type; /* What sort of cell type are we in? */
bool printing_notes; /* Are we printing notes/glossary/etc.? */
node *notes; /* Store reference notes */
Expand Down

0 comments on commit bd9438d

Please sign in to comment.