2

I have to submit a paper to a journal written in LaTeX. As always, I split my files into different ones. However, the upload is only possible for one file. The different tex files are inserted using the \input{otherFile} command. As far as I read, this commend just inserts the whole code of the otherFile into the actual position. This is working fine for my normal tex files but for one special case it fails and I don´t know why.

I generated a graphic with gnuplot and exported it as epslatex. Therefore, I get a tex and eps file. The figure is included to the main tex file as:

\begin{figure}
\scalebox{scale=0.65}{\input{myGraphic}}
\end{figure}

If I replace the content \input{myGraphic} with the whole content of the file itself, the compilation fails. I get errors like, undefined if else... Does anyone know why this happens?

\begin{figure}
\scalebox{scale=0.65}
{
%content of file
.
.
.
%content of file end
}
\end{figure}

Any hint is highly appreciated. Thanks in advance, Tobi

PS: The output of the gnuplot file (the *.tex one) is given below:

% 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}(7200.00,5040.00)%
    \gplgaddtomacro\gplbacktext{%
      \csname LTb\endcsname%
      \put(525,704){\makebox(0,0)[r]{\strut{}None}}%
      \put(525,1213){\makebox(0,0)[r]{\strut{}}}%
      \put(525,1722){\makebox(0,0)[r]{\strut{}}}%
      \put(525,2231){\makebox(0,0)[r]{\strut{}}}%
      \put(525,2740){\makebox(0,0)[r]{\strut{}Moderate}}%
      \put(525,3248){\makebox(0,0)[r]{\strut{}}}%
      \put(525,3757){\makebox(0,0)[r]{\strut{}}}%
      \put(525,4266){\makebox(0,0)[r]{\strut{}}}%
      \put(525,4775){\makebox(0,0)[r]{\strut{}High}}%
      \put(720,484){\makebox(0,0){\strut{}$0$}}%
      \put(1560,484){\makebox(0,0){\strut{}$10$}}%
      \put(2400,484){\makebox(0,0){\strut{}$20$}}%
      \put(3240,484){\makebox(0,0){\strut{}$30$}}%
      \put(4079,484){\makebox(0,0){\strut{}$40$}}%
      \put(4919,484){\makebox(0,0){\strut{}$50$}}%
      \put(5759,484){\makebox(0,0){\strut{}$60$}}%
    }%
    \gplgaddtomacro\gplfronttext{%
      \csname LTb\endcsname%
      \put(-377,2739){\rotatebox{-270}{\makebox(0,0){\strut{}Amount of inserted energy [-]}}}%
      \put(3239,154){\makebox(0,0){\strut{}Time [s]}}%
      \csname LTb\endcsname%
      \put(4652,1457){\makebox(0,0)[r]{\strut{}Energy insertion}}%
    }%
    \gplgaddtomacro\gplbacktext{%
      \put(5954,704){\makebox(0,0)[l]{\strut{}$0$}}%
      \put(5954,1213){\makebox(0,0)[l]{\strut{}$10$}}%
      \put(5954,1722){\makebox(0,0)[l]{\strut{}$20$}}%
      \put(5954,2231){\makebox(0,0)[l]{\strut{}$30$}}%
      \put(5954,2740){\makebox(0,0)[l]{\strut{}$40$}}%
      \put(5954,3248){\makebox(0,0)[l]{\strut{}$50$}}%
      \put(5954,3757){\makebox(0,0)[l]{\strut{}$60$}}%
      \put(5954,4266){\makebox(0,0)[l]{\strut{}$70$}}%
      \put(5954,4775){\makebox(0,0)[l]{\strut{}$80$}}%
    }%
    \gplgaddtomacro\gplfronttext{%
      \csname LTb\endcsname%
      \put(6459,2739){\rotatebox{-270}{\makebox(0,0){\strut{}Von Mises Stress [MPa]}}}%
      \csname LTb\endcsname%
      \put(4652,1216){\makebox(0,0)[r]{\strut{}Von Mises Stress}}%
    }%
    \gplgaddtomacro\gplbacktext{%
      \csname LTb\endcsname%
      \put(7010,704){\makebox(0,0)[l]{\strut{}$0$}}%
      \put(7010,1213){\makebox(0,0)[l]{\strut{}$75$}}%
      \put(7010,1722){\makebox(0,0)[l]{\strut{}$150$}}%
      \put(7010,2231){\makebox(0,0)[l]{\strut{}$225$}}%
      \put(7010,2740){\makebox(0,0)[l]{\strut{}$300$}}%
      \put(7010,3248){\makebox(0,0)[l]{\strut{}$375$}}%
      \put(7010,3757){\makebox(0,0)[l]{\strut{}$450$}}%
      \put(7010,4266){\makebox(0,0)[l]{\strut{}$525$}}%
      \put(7010,4775){\makebox(0,0)[l]{\strut{}$600$}}%
    }%
    \gplgaddtomacro\gplfronttext{%
      \csname LTb\endcsname%
      \put(7647,2739){\rotatebox{-270}{\makebox(0,0){\strut{}Temperature [$^{\circ} $C]}}}%
      \csname LTb\endcsname%
      \put(4652,968){\makebox(0,0)[r]{\strut{}Temperature}}%
    }%
    \gplbacktext
    \put(0,0){\includegraphics{pictures/EPS/PowerControl}}%
    \gplfronttext
  \end{picture}%
\endgroup
  • 1
    it should work unless you have verbatim material in the file, but as you have provided no example, impossible to say in detail whether it should work for your file. – David Carlisle Sep 7 '17 at 21:51
  • 1
    Can you post the content of the tex file generated by gnuplot? – Michael Palmer Sep 7 '17 at 23:53
  • Hi David and Michael, I put the output file of gnuplot into my question. Thanks for the feedback. Tobi – Tobi Sep 9 '17 at 9:47
  • 1
    It works for me, after I add this to an empty LaTeX file just including the graphicx package and commenting out the line near the bottom which includes pictures/EPS/PowerControl (which I don't have, obviously). I'm afraid you may have to provide a complete MWE. – Harald Hanche-Olsen Sep 9 '17 at 9:58
  • Move the code from \begingroup to \makeatother included before \scalebox and \endgroup after the closing brace – egreg Sep 9 '17 at 11:08
2

The input file has \makeatletter which cannot do its work if it's absorbed in the argument to another command, in your case \scalebox. The situation changes if the file is input: the category codes are not frozen as they would when absorbed as an argument.

The “solution” is to move the setup part before the \scalebox:

\begin{figure}
% 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}%
\scalebox{scale=0.65}{% <--- don't forget
\begin{picture}(7200.00,5040.00)%
<THE REST OF THE PICTURE COMMANDS>
  \end{picture}%
}% <--- matching \scalebox{
\endgroup

\end{figure}

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.