当我sin(x)
在 gnuplot 中制作并通过 Lualatex 编译它时,它确实可以工作,但是当我在 gnuplot 中制作堆积条形图并执行相同操作时,它现在不起作用。我正在使用\input{filename.tex}
包graphicx
。免责声明 - 我是 gnuplot 的新手。这是源代码sin(x)
:
% 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(726,440){\makebox(0,0)[r]{\strut{}$-1$}}%
\put(726,878){\makebox(0,0)[r]{\strut{}$-0.8$}}%
\put(726,1316){\makebox(0,0)[r]{\strut{}$-0.6$}}%
\put(726,1754){\makebox(0,0)[r]{\strut{}$-0.4$}}%
\put(726,2192){\makebox(0,0)[r]{\strut{}$-0.2$}}%
\put(726,2630){\makebox(0,0)[r]{\strut{}$0$}}%
\put(726,3067){\makebox(0,0)[r]{\strut{}$0.2$}}%
\put(726,3505){\makebox(0,0)[r]{\strut{}$0.4$}}%
\put(726,3943){\makebox(0,0)[r]{\strut{}$0.6$}}%
\put(726,4381){\makebox(0,0)[r]{\strut{}$0.8$}}%
\put(726,4819){\makebox(0,0)[r]{\strut{}$1$}}%
\put(858,220){\makebox(0,0){\strut{}$-10$}}%
\put(2344,220){\makebox(0,0){\strut{}$-5$}}%
\put(3831,220){\makebox(0,0){\strut{}$0$}}%
\put(5317,220){\makebox(0,0){\strut{}$5$}}%
\put(6803,220){\makebox(0,0){\strut{}$10$}}%
}%
\gplgaddtomacro\gplfronttext{%
\csname LTb\endcsname%%
\put(5816,4646){\makebox(0,0)[r]{\strut{}$sin(x)$}}%
}%
\gplbacktext
\put(0,0){\includegraphics[width={360.00bp},height={252.00bp}]{sinus}}%
\gplfronttext
\end{picture}%
\endgroup
可以正常工作。接下来是直方图的源代码,但不能正常工作:
% 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(594,440){\makebox(0,0)[r]{\strut{}$0$}}%
\put(594,1316){\makebox(0,0)[r]{\strut{}$20$}}%
\put(594,2192){\makebox(0,0)[r]{\strut{}$40$}}%
\put(594,3067){\makebox(0,0)[r]{\strut{}$60$}}%
\put(594,3943){\makebox(0,0)[r]{\strut{}$80$}}%
\put(594,4819){\makebox(0,0)[r]{\strut{}$100$}}%
\put(1069,220){\makebox(0,0){\strut{}2011}}%
\put(1411,220){\makebox(0,0){\strut{}2012}}%
\put(1754,220){\makebox(0,0){\strut{}2013}}%
\put(2097,220){\makebox(0,0){\strut{}2014}}%
\put(2440,220){\makebox(0,0){\strut{}2015}}%
\put(2782,220){\makebox(0,0){\strut{}2016}}%
\put(3125,220){\makebox(0,0){\strut{}2017}}%
\put(3468,220){\makebox(0,0){\strut{}2018}}%
\put(3811,220){\makebox(0,0){\strut{}June2019}}%
\put(4153,220){\makebox(0,0){\strut{}March2020}}%
}%
\gplgaddtomacro\gplfronttext{%
\csname LTb\endcsname%%
\put(5615,4489){\makebox(0,0)[l]{\strut{}Urban areas}}%
\csname LTb\endcsname%%
\put(5615,4709){\makebox(0,0)[l]{\strut{}Rural areas}}%
}%
我很无助,试图寻找解决方案近2天......我还有一些错误的截图。
这是直方图:
有效的测试文件
\documentclass{article}
\usepackage{graphicx}
\usepackage{fontspec}
\setmainfont{Minion Pro}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{xits math}
\begin{document}
\input{sinus}
\end{document}
测试文件不起作用
\documentclass{article}
\usepackage{graphicx}
\usepackage{fontspec}
\setmainfont{Minion Pro}
\usepackage{amsmath}
\usepackage{unicode-math}
\setmathfont{xits math}
\begin{document}
\input{plothisto}
\end{document}
编辑:添加后
\gplbacktext
\put(0,0){\includegraphics[width={360.00bp},height={252.00bp}]{sinus}}%
\gplfronttext
\end{picture}%
\endgroup
对于我的代码,它会打印这个,虽然它很窄......