From bfd66cc4c83d6afc45b6da0b8c86840fa102dba3 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Mon, 26 Oct 2020 19:11:28 +0100 Subject: [PATCH] TeX driver: Conditionally emit "\input graphics" control sequence. Only emit the \input graphicx control sequence if it is actually needed. This way, systems which do not have the graphicx package installed will not fail on examples which need no graphics component. --- src/output/tex.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/output/tex.c b/src/output/tex.c index 4191e69381..ee23505cce 100644 --- a/src/output/tex.c +++ b/src/output/tex.c @@ -66,6 +66,7 @@ struct tex_driver struct output_driver driver; /* A hash table containing any Tex macros which need to be emitted. */ struct hmap macros; + bool require_graphics; #ifdef HAVE_CAIRO struct cell_color fg; struct cell_color bg; @@ -215,8 +216,6 @@ tex_destroy (struct output_driver *driver) shipout (&tex->preamble_list, "%%%% Define the horizontal space between table columns\n"); shipout (&tex->preamble_list, "\\def\\psppcolumnspace{1mm}\n\n"); - shipout (&tex->preamble_list, "\\input graphicx\n\n"); - char *ln = get_language (); if (ln) shipout (&tex->preamble_list, "%%%% Language is \"%s\"\n", ln); @@ -260,6 +259,9 @@ tex_destroy (struct output_driver *driver) } hmap_destroy (&tex->macros); + if (tex->require_graphics) + shipout (&tex->preamble_list, "\\input graphicx\n\n"); + post_process_tokens (tex->file, &tex->preamble_list); shipout (&tex->token_list, "\n\\bye\n"); @@ -327,6 +329,7 @@ tex_submit (struct output_driver *driver, // printf ("The chart title is %s\n", title); shipout (&tex->token_list, "\\includegraphics{%s}\n", file_name); + tex->require_graphics = true; free (file_name); } } -- 2.30.2