pstricks 图片中未包含 newcommand 对象

pstricks 图片中未包含 newcommand 对象

我曾经有包含 pstricks 图片的旧 latex 文档。我必须定义可以在图片中多次重复使用的对象,并使用 newcommand/def 执行此操作(一切都很好)。我最近必须编译这些文件,但它不再起作用:newcommand 行中定义的对象未显示。

我试图展示一个简短的、不起作用的例子:

\documentclass{article}
\usepackage{pdftricks}
\begin{psinputs}
    \usepackage{pstricks}
\end{psinputs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\newcommand*{\example}{\qline(0,0)(1,1)}

\begin{pdfdisplay}
    \begin{pspicture}(3,3)
       \qline(0,0)(1,1) %this line displays correctly
       \rput(1,0){\qline(0,0)(1,1)}  %this line displays correctly
       \rput(2,0){\example}  %this line isn't displayed!
    \end{pspicture}
\end{pdfdisplay} 
\end{document}

在上面的代码中,前两行绘制正确,但第三行绘制不正确。我为此奋斗了几个小时,却找不到问题所在。我唯一能理解的信息是,该图被包装在 tex 文件中,然后在 postscript 中编译,然后转换为 pdf,并且 \example 代码没有随它一起传递:

%%% This is the example-fig1.tex automatically generated file
\documentclass{article}
\input tmp.inputs
\pagestyle{empty}
\begin{document}
    \begin{pspicture}(3,3)
       \qline(0,0)(1,1) %this line displays correctly
       \rput(1,0){\qline(0,0)(1,1)}  %this line displays correctly
       \rput(2,0){\example}  %this line doesn't display!
    \end{pspicture}

\end{document}

非常感谢您的帮助!谢谢。

答案1

下面应该可以工作!

\documentclass{article}
\usepackage{pdftricks}
\begin{psinputs}
    \usepackage{pstricks}
    \newcommand*{\example}{\qline(0,0)(1,1)}
\end{psinputs}

\begin{document}
\begin{pdfdisplay}
    \begin{pspicture}(3,3)
       \qline(0,0)(1,1) %this line displays correctly
       \rput(1,0){\qline(0,0)(1,1)}  %this line displays correctly
       \rput(2,0){\example}  %this line ALSO displays correctly!
    \end{pspicture}
\end{pdfdisplay} 
\end{document}

相关内容