epslatex ターミナルを使用した Gnuplot

epslatex ターミナルを使用した Gnuplot

重複の可能性あり:
Epstopdf を使用しても Gnuplot サブディレクトリが見つかりません

こんにちは。gnuplot 4.6 を使用して、ドキュメントに高品質のグラフを挿入する手順を実行しました。手順は次のとおりです。

  1. sample.gp次のようなソースコードを含むファイルを作成しました:

    set terminal epslatex
    set output 'test.tex'
    f(x) = sin(x)
    plot f(x)
    
  2. ソースファイルを変換してgnuplot sample.gp、2つのファイルを取得しました。テスト.epsそしてテスト.tex

  3. しかし.epsPDFLatexを使用してLatexドキュメントをコンパイルしたいので、この形式は私には適していません。そのため、ps2pdf13 -dEPSCrop test.eps test.pdfPDFファイルを生成するためにghostscriptコマンドを使用しました。テスト.pdf

  4. 私は私のテスト.texコード行を使用してLaTeX文書に\input{test.tex}

PDFLatex でコンパイルするとエラーが発生します:

test.tex:96:ファイル 'test' が見つかりません、\put(0,0){\includegraphics{test}}

私は混乱しています。なぜなら、写真テスト.pdf同じフォルダにありますテスト.texただし、どちらもルート Latex フォルダーのサブフォルダー「pictures」にあります。

さて、ここにソースコードがありますテスト.texgnuplot が生成したものです。お役に立てば幸いです。エラーを報告する行はファイルの末尾近くにあります。

% 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}%
  \begin{picture}(7200.00,5040.00)%
    \gplgaddtomacro\gplbacktext{%
      \csname LTb\endcsname%
      \put(462,440){\makebox(0,0)[r]{\strut{} 0}}%
      \put(462,1307){\makebox(0,0)[r]{\strut{} 1}}%
      \put(462,2174){\makebox(0,0)[r]{\strut{} 2}}%
      \put(462,3041){\makebox(0,0)[r]{\strut{} 3}}%
      \put(462,3908){\makebox(0,0)[r]{\strut{} 4}}%
      \put(462,4775){\makebox(0,0)[r]{\strut{} 5}}%
      \put(594,220){\makebox(0,0){\strut{} 0}}%
      \put(1836,220){\makebox(0,0){\strut{} 2}}%
      \put(3078,220){\makebox(0,0){\strut{} 4}}%
      \put(4319,220){\makebox(0,0){\strut{} 6}}%
      \put(5561,220){\makebox(0,0){\strut{} 8}}%
      \put(6803,220){\makebox(0,0){\strut{} 10}}%
    }%
    \gplgaddtomacro\gplfronttext{%
      \csname LTb\endcsname%
      \put(5816,4602){\makebox(0,0)[r]{\strut{}f(x)}}%
    }%
    \gplbacktext
    \put(0,0){\includegraphics{test}}%
    \gplfronttext
  \end{picture}%
\endgroup

答え1

調べてみたらテスト.texgnuplotによって生成された行には\put(0,0){\includegraphics{test}}%テスト.pdf画像。

コマンド\includegraphics{test}テスト.tex目的地のテスト.pdf目的地に応じてテスト.texこれは、ルート Latex フォルダのサブフォルダ「pictures」にあります。

\input{./pictures/test}しかし、メインの Latex ドキュメント内でコマンドを使用したため、\includegraphics{test}その中のコマンドの宛先はルート Latex フォルダーを基準にしたものになります。

だから、内部の行を変更することで簡単に問題を解決できましたテスト.tex\put(0,0)\includegraphics{./pictures/test}

関連情報