2

This is probably directed at the maintainers and the LaTeX3 project team.

I noticed a change in plots generated with gnuplot externalliy with the epslatex terminal. Documents compiled with pdfLaTeX or with LuaLaTeX 0.95 (from TeX Live 2016) are fine.

However, when the document is compiled with LuaLaTeX 1.0.4 (Tex Live 2017) The numbers on the axes, and in general, any text is shifted slightly to the left. I've included images here to illustrate the issue:

LuaLaTeX 0.95

LuaLaTeX 0.95 compiled image

LuaLaTeX 1.0.4

LuaLaTeX 1.0.4 compiled image

The difference is most noticeable if you look at the labels on the x-axis and how they line up with the tics.

After testing both versions from Tex Live 2016 and 2017, and all the packages loaded. I was able to narrow down the issue to luatex.def. If I substituted luatex.def v0.01h (replacing v1.0f) into my Tex Live directory it fixed the issue. That is compiling with LuaLaTeX 1.0.4 and all the associated package version listed from the log with it below.

I also though it might be something to do with the conversion of the eps to pdf which happend when the gnuplot graph is included in the main document.

If I change the inputted eps which is part of the plot to a png with imagemagick then the issue seems to disappear. So either it's occuing when the eps is converted to a pdf, or on the inclusion of the pdf. Either way it's occuring only when the latetest verion of luatex.def is loaded.

I looked at the two verisons of luatex.def but my tex-fu is not strong enough to suggest a fix. Having played with the source tex from gnuplot I could manually fix it too by playing with the \setlength{\unitlength} or with the coordinates. I could also move things around leaving the \unitlength and the coords in the \put commands as is, but modifying the coords in the \makebox commands. I'm not sure if that helps locate the issue.

I've included my minimal working example here, I use filecontents to output the gnuplot generated plot.tex in case anyone didn't have access to gnuplot. The gnuplot script to generated it follows the LaTeX MWE.

LaTeX MWE

%!TEX TS-program = lualatex
%!TEX encoding = UTF-8 Unicode
\RequirePackage{luatex85}
\RequirePackage{shellesc}

\documentclass{standalone}

\usepackage{graphicx}

\begin{filecontents}{plot.tex}
  % GNUPLOT: LaTeX picture with Postscript
  \begingroup
    \makeatletter
    \providecommand\color[2][]{%
      \GenericError{(gnuplot) \space\space\space\@spaces}{%
        Package color not loaded in conjunction with
        terminal option `colourtext'%
      }{See the gnuplot documentation for explanation.%
      }{Either use 'blacktext' in gnuplot or load the package
        color.sty in LaTeX.}%
      \renewcommand\color[2][]{}%
    }%
    \providecommand\includegraphics[2][]{%
      \GenericError{(gnuplot) \space\space\space\@spaces}{%
        Package graphicx or graphics not loaded%
      }{See the gnuplot documentation for explanation.%
      }{The gnuplot epslatex terminal needs graphicx.sty or graphics.sty.}%
      \renewcommand\includegraphics[2][]{}%
    }%
    \providecommand\rotatebox[2]{#2}%
    \@ifundefined{ifGPcolor}{%
      \newif\ifGPcolor
      \GPcolorfalse
    }{}%
    \@ifundefined{ifGPblacktext}{%
      \newif\ifGPblacktext
      \GPblacktexttrue
    }{}%
    % define a \g@addto@macro without @ in the name:
    \let\gplgaddtomacro\g@addto@macro
    % define empty templates for all commands taking text:
    \gdef\gplbacktext{}%
    \gdef\gplfronttext{}%
    \makeatother
    \ifGPblacktext
      % no textcolor at all
      \def\colorrgb#1{}%
      \def\colorgray#1{}%
    \else
      % gray or color?
      \ifGPcolor
        \def\colorrgb#1{\color[rgb]{#1}}%
        \def\colorgray#1{\color[gray]{#1}}%
        \expandafter\def\csname LTw\endcsname{\color{white}}%
        \expandafter\def\csname LTb\endcsname{\color{black}}%
        \expandafter\def\csname LTa\endcsname{\color{black}}%
        \expandafter\def\csname LT0\endcsname{\color[rgb]{1,0,0}}%
        \expandafter\def\csname LT1\endcsname{\color[rgb]{0,1,0}}%
        \expandafter\def\csname LT2\endcsname{\color[rgb]{0,0,1}}%
        \expandafter\def\csname LT3\endcsname{\color[rgb]{1,0,1}}%
        \expandafter\def\csname LT4\endcsname{\color[rgb]{0,1,1}}%
        \expandafter\def\csname LT5\endcsname{\color[rgb]{1,1,0}}%
        \expandafter\def\csname LT6\endcsname{\color[rgb]{0,0,0}}%
        \expandafter\def\csname LT7\endcsname{\color[rgb]{1,0.3,0}}%
        \expandafter\def\csname LT8\endcsname{\color[rgb]{0.5,0.5,0.5}}%
      \else
        % gray
        \def\colorrgb#1{\color{black}}%
        \def\colorgray#1{\color[gray]{#1}}%
        \expandafter\def\csname LTw\endcsname{\color{white}}%
        \expandafter\def\csname LTb\endcsname{\color{black}}%
        \expandafter\def\csname LTa\endcsname{\color{black}}%
        \expandafter\def\csname LT0\endcsname{\color{black}}%
        \expandafter\def\csname LT1\endcsname{\color{black}}%
        \expandafter\def\csname LT2\endcsname{\color{black}}%
        \expandafter\def\csname LT3\endcsname{\color{black}}%
        \expandafter\def\csname LT4\endcsname{\color{black}}%
        \expandafter\def\csname LT5\endcsname{\color{black}}%
        \expandafter\def\csname LT6\endcsname{\color{black}}%
        \expandafter\def\csname LT7\endcsname{\color{black}}%
        \expandafter\def\csname LT8\endcsname{\color{black}}%
      \fi
    \fi
      \setlength{\unitlength}{0.0500bp}%
      \ifx\gptboxheight\undefined%
        \newlength{\gptboxheight}%
        \newlength{\gptboxwidth}%
        \newsavebox{\gptboxtext}%
      \fi%
      \setlength{\fboxrule}{0.5pt}%
      \setlength{\fboxsep}{1pt}%
  \begin{picture}(3400.00,3174.00)%
      \gplgaddtomacro\gplbacktext{%
        \csname LTb\endcsname%%
        \put(594,652){\makebox(0,0)[r]{\strut{}-10}}%
        \put(594,1190){\makebox(0,0)[r]{\strut{}-5}}%
        \put(594,1728){\makebox(0,0)[r]{\strut{}0}}%
        \put(594,2266){\makebox(0,0)[r]{\strut{}5}}%
        \put(594,2804){\makebox(0,0)[r]{\strut{}10}}%
        \put(789,369){\makebox(0,0){\strut{}-10}}%
        \put(1327,369){\makebox(0,0){\strut{}-5}}%
        \put(1865,369){\makebox(0,0){\strut{}0}}%
        \put(2402,369){\makebox(0,0){\strut{}5}}%
        \put(2940,369){\makebox(0,0){\strut{}10}}%
      }%
      \gplgaddtomacro\gplfronttext{%
      }%
      \gplbacktext
      \put(0,0){\includegraphics{test-plot}}%
      \gplfronttext
    \end{picture}%
  \endgroup
\end{filecontents}


\begin{document}

\input{plot.tex}

\end{document}

Gnuplot input

set terminal epslatex size 6cm,5.6cm
set output "test-plot.tex"
set tics out
unset key
set size square
set format x '%g'
set format y '%g'
f(x) = x
plot f(x) with lines

You can find the eps for inclusion here: https://www.dropbox.com/s/0thsdguhje266rr/test-plot.eps?dl=0


These are the key packages loaded, according to the log file, by each compilation method:

LuaTeX, Version 0.95.0 (TeX Live 2016)

  • luatex85 2016/06/15 v1.4
  • shellesc 2016/06/07 v0.02a
  • graphicx 2014/10/28 v1.0g
  • graphics 2016/10/09 v1.0u
  • luatex.def 2017/01/12 v0.01h

LuaTeX, Version 1.0.4 (TeX Live 2017)

  • luatex85 2016/06/15 v1.4
  • shellesc 2016/06/07 v0.02a
  • graphicx 2017/06/01 v1.1a
  • graphics 2017/06/25 v1.2c
  • luatex.def 2017/06/24 v1.0f

Incidentally pdfLaTeX compiles fine for both 2017 and 106 TeX Live versions:

pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017)

  • luatex85 2016/06/15 v1.4
  • shellesc 2016/06/07 v0.02a
  • graphicx 2017/06/01 v1.1a
  • graphics 2016/10/09 v1.0u
  • pdftex.def 2017/06/24 v1.0g
2

Sorry about, that it looks like a fix applied to pdftex.def wasn't copied over to luatex.def

\DeclareGraphicsExtensions{.pdf,.png}

in the document should fix it, or

just add a % after JB2 on line 485 of luatex.def I have updated the file at github will make a ctan update pending further tests.

  • No problems, happy to help bug squash. Both fixes work. Awesome stuff. And what a response time! – tmgriffiths Nov 22 '17 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.