shiblon / latex-makefile

A Makefile for LaTeX - drop it in, type make, and magic happens.
Other
185 stars 30 forks source link

Support for epslatex terminal in Gnuplot #160

Closed shiblon closed 8 years ago

shiblon commented 8 years ago

Originally reported on Google Code with ID 147

The epslatex terminal is very useful in Gnuplot since it uses the exact fonts of the
document and can use latex macros inside the Gnuplot labels etc. 

It would be really useful to enable this terminal as an option in latex-makefile. 

Normally I use gnuplot like this:
set terminal epslatex size 8.2cm,6cm color
set output "name-of-graph.tex"

and then latex like this
\input{name-of-graph}

I have previously had a Makefile command to look for any *-graph.tex files and then
compile the *-graph.gpi using gnuplot. 

Would this be possible using latex-makefile? Is there a better way?

Reported by bonne@ixum.net on 2012-01-03 07:08:57

shiblon commented 8 years ago
Unfortunately, there is no good way of automatically determining dependencies with the
makefile when you use \input, particularly for graphics.  The problem is that the graphics
must be present before the full (flattened) latex file can be built, which means that
the first latex invocation will fail on the first missing graphic.  This will happen
once for every single missing graphics file, and it's really an issue with latex itself,
not something that I can do much with automatically (at least not reliably).

There are a number of things that could be done to *sort of* solve this problem, including
what you suggest (having a separate "make" step that builds all of the graphics it
can find), but they would all be brittle, so I have steered clear of them all.  And,
unfortunately, my ability to maintain the makefile is pretty spotty lately, so experimental
features like this haven't been getting much traction.

That said, you can easily add your own rule to build those graphics....  That's probably
the right way to go.

I do apologize.  I wish I had a better answer for you.

Reported by shiblon on 2012-01-03 12:22:26

shiblon commented 8 years ago
Ok, thanks for the help. I'll write a custom makefile rule and see how that goes. 

Cheers

Reported by bonne@ixum.net on 2012-01-03 22:47:20

shiblon commented 8 years ago
In case anyone else wants to try this, I solved my problem by putting the following
into Targets.ini: 

#This overrides the default gnuplot terminal for the epslatex terminal I want. 
define gpi-terminal
epslatex size 8.2cm,6cm color
endef

#This makes a rule so that all \input files which end in -graph depend on a similarly
named gpi file. 
%-graph.tex:  %.gpi %.gpi.d $(gpi_sed) $(gpi_global)
  $(QUIET)$(call echo-graphic,$^,$@)
  $(QUIET)$(call convert-gpi,$<,$@,$(GRAY))

#This makes sure that the eps graphic that is required by the epslatex output is converted
to pdf (since for some reason it wants a .eps.pdf not just a .pdf)
ifeq "$(strip $(BUILD_STRATEGY))" "xelatex"
%.eps.pdf: %.eps $(if $(GRAY),$(gray_eps_file))
  $(QUIET)$(call echo-graphic,$^,$@)
  $(QUIET)$(call convert-eps-to-pdf,$<,$@,$(GRAY))

endif

Reported by bonne@ixum.net on 2012-01-03 23:12:04