独立和 pst-solides3d 编译失败

独立和 pst-solides3d 编译失败

我有一个由和PStricks共同创建的模式,将其(感谢独立包)分开放在不同的文件中。pst-solides3dpst-3dplot

该模式在本身编译时不会产生任何问题,并且输出正常,正如它应该的那样。

这是我的主要文档的序言:

\documentclass[a4paper,11pt]{report}
\usepackage{standalone}
\usepackage{a4wide}
\usepackage[french]{babel}
\NoAutoSpaceBeforeFDP % empêcher d'ajouter un espace après :
\usepackage[table, usenames,dvips, dvipsnames]{xcolor}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath, here}
\usepackage[hyperindex, pdfborder={0 0 0}]{hyperref} % Table des matières & références interactive
\usepackage{url}
\usepackage{wrapfig}
\usepackage{fancyhdr}
\usepackage{fancyref}

\usepackage{pstricks,  pst-circ, pst-plot, pst-3dplot, pst-solides3d}
\usepackage[locale = FR]{siunitx}

如果我加载pst-solides3d(需要绘制包含文件中的模式),它不会编译,并且我收到以下错误:

Error: /typecheck in --length--
Operand stack:
71.7882   -207.763   71.7882   -193.537   71.7882   -179.31   71.7882   -179.31   
[...]
809.324   -165.366   809.324   -165.366   1   1
Execution stack:
%interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2  
%stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1  
%stopped_push   1900   1   3   %oparray_pop   1899   1   3   %oparray_pop   18831   3   %oparray_pop   1771   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2  
--nostringval--   --nostringval--   --nostringval--   2   %stopped_push  
--nostringval--  
--nostringval--
Dictionary stack:
--dict:1163/1684(ro)(G)--   --dict:1/20(G)--   --dict:139/200(L)--
--dict:747/1012(L)--   --dict:227/300(L)--   --dict:62/200(L)--   --dict:57/75(L)--  
--dict:211/313(L)--   --dict:72/140(L)--   --dict:0/10(G)--   --dict:18/20(L)--      
--dict:4/50(ro)(G)--   --dict:56/71(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 10226107
GPL Ghostscript 9.10: Unrecoverable error, exit code 1

此外,如果我不加载该包pst-solides3d,LaTeX 就无法识别pst-solides3d宏,就会出现错误,也无法编译……

我不知道该怎么办,因为分开的文件编译,并且当包含在主文件中时,它不再编译......

它与其他包有交互吗?

以下是我使用的 PSTricks 代码:

\documentclass[pstricks, float]{standalone}
\usepackage{pstricks, pst-circ, pst-plot, pst-3dplot, pst-solides3d}
\begin{document}

%\bgroup% holds everything local
\begin{pspicture}[showgrid=false](-1,-2)(9,6)
    \psset{unit=0.5, Alpha=45, Beta=15,
            viewpoint=60 45 15 rtp2xyz, Decran=120, lightsrc=viewpoint,
            linewidth=0.15pt,solidmemory}
    %%%%%%      
    \defFunction{K}(t){t cos 2.5 mul}{t sin 2.5 mul}{}
    \psSolid[object=prisme,h=0.15,
        %fillcolor=yellow,
        RotX=-90,
        resolution=50,
        action=none,name=fond,
        base=90 270 {K} CourbeR2+](0,-0.15,2.5)
    \defFunction{F}(t){t cos 2.5 mul}{t sin 2.5 mul}{}
    \defFunction{G}(t){t cos 2.4 mul}{t sin 2.4 mul}{}
    \psSolid[object=prisme,
        h=8,%fillcolor=yellow,
        RotX=90,ngrid=1 0,
        resolution=50,
        base=90 270 {F} CourbeR2+
        270 90 {G} CourbeR2+,
        action=none,name=can](0,8,2.5)
    \psSolid[linewidth=0.15pt,
            object=cylindre,
            h=0.1,r=0.25,
            fillcolor=red!50,
            action=none,name=pas,
            mode=4,
            ngrid=1 20]
            (0, 2, -0.1)    
    \psSolid[linewidth=0.15pt,
            object=cylindre,
            h=0.3,r=0.15,
            fillcolor=red!50,
            action=none,name=bout,
            mode=4,
            ngrid=1 20]
            (0, 2, -0.4)    
    \psSolid[object=fusion,
            action=draw**, linewidth=0.2pt,
            base=can fond pas bout](0,0,0)
    %\composeSolid  
        \psSolid[linewidth=0.15pt,
            object=cylindre,
            h=0.1,r=0.15,
            fillcolor=red!50,
            mode=4,
            action=none,name=filet,
            ngrid=1 20]
            (0, 2, 0)
    \psSolid[linewidth=0.15pt,
            object=cylindre,
            h=1.5625,r=0.05,
            fillcolor=green,
            mode=4,
            action=none,name=antenne,
            ngrid=1 10]
            (0, 2, 0.1) 
    \psSolid[object=fusion,
            action=draw**, linewidth=0.2pt,
            base=filet antenne](0,0,0)
    \composeSolid

%   \axesIIID(4,9,6)
%   \pstThreeDCoor[xMin=0,xMax=4.5,yMin=0,yMax=9,zMin=0,zMax=6,IIIDticks]

    \psset{linewidth=0.05, linecolor=black,arrowsize=0.2}   
    \pstThreeDLine{<->}(0, 0, 1.7)(0, 2, 1.7)
        \pstPlanePut[plane=yz,
            planecorr=normal](0, 2, 4.1){$\frac{L_g}{4}$}
    \pstThreeDLine{<->}(0, 2.7, 0.1)(0, 2.7, 1.6625)
        \pstPlanePut[plane=yz,
            planecorr=normal](0, 6, 1.6){\colorbox{white!10}{$\frac{L_o}{4}$}}  
    \pstThreeDLine{<->}(0.5, 0, 0.1)(0.5, 0, 4.9)
        \pstPlanePut[plane=xz,
            planecorr=normal](2.2, 0, 4.4){$D$}
    \pstThreeDLine{<->}(0.5, 0, 0)(0.5, 8, 0)
        \pstPlanePut[plane=yz,
            planecorr=xyrot](0.5, 8, -1){$\frac{3}{4}L_g$}
    \end{pspicture}
%\egroup
\end{document}

这是我单独编译时得到的结果: 在此处输入图片描述

答案1

分而治之(最佳实践)

将每个图表放入其单独的可编译输入文件中。为此,使用standalone文档类。然后编译输入文件以latex->dvips->ps2pdf获取 PDF 输出。

% the filename of this code is diagram-1.tex

% compile this with the following 3 steps:
% latex diagram-1
% dvips diagram-1
% ps2pdf -dAutoRotatePages=/None diagram-1.ps
\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-solides3d,pst-3dplot}
\begin{document}

%\bgroup% holds everything local
\begin{pspicture}[showgrid=false](-1,-2)(9,6)
    \psset{unit=0.5, Alpha=45, Beta=15,
            viewpoint=60 45 15 rtp2xyz, Decran=120, lightsrc=viewpoint,
            linewidth=0.15pt,solidmemory}
    %%%%%%      
    \defFunction{K}(t){t cos 2.5 mul}{t sin 2.5 mul}{}
    \psSolid[object=prisme,h=0.15,
        %fillcolor=yellow,
        RotX=-90,
        resolution=50,
        action=none,name=fond,
        base=90 270 {K} CourbeR2+](0,-0.15,2.5)
    \defFunction{F}(t){t cos 2.5 mul}{t sin 2.5 mul}{}
    \defFunction{G}(t){t cos 2.4 mul}{t sin 2.4 mul}{}
    \psSolid[object=prisme,
        h=8,%fillcolor=yellow,
        RotX=90,ngrid=1 0,
        resolution=50,
        base=90 270 {F} CourbeR2+
        270 90 {G} CourbeR2+,
        action=none,name=can](0,8,2.5)
    \psSolid[linewidth=0.15pt,
            object=cylindre,
            h=0.1,r=0.25,
            fillcolor=red!50,
            action=none,name=pas,
            mode=4,
            ngrid=1 20]
            (0, 2, -0.1)    
    \psSolid[linewidth=0.15pt,
            object=cylindre,
            h=0.3,r=0.15,
            fillcolor=red!50,
            action=none,name=bout,
            mode=4,
            ngrid=1 20]
            (0, 2, -0.4)    
    \psSolid[object=fusion,
            action=draw**, linewidth=0.2pt,
            base=can fond pas bout](0,0,0)
    %\composeSolid  
        \psSolid[linewidth=0.15pt,
            object=cylindre,
            h=0.1,r=0.15,
            fillcolor=red!50,
            mode=4,
            action=none,name=filet,
            ngrid=1 20]
            (0, 2, 0)
    \psSolid[linewidth=0.15pt,
            object=cylindre,
            h=1.5625,r=0.05,
            fillcolor=green,
            mode=4,
            action=none,name=antenne,
            ngrid=1 10]
            (0, 2, 0.1) 
    \psSolid[object=fusion,
            action=draw**, linewidth=0.2pt,
            base=filet antenne](0,0,0)
    \composeSolid

%   \axesIIID(4,9,6)
%   \pstThreeDCoor[xMin=0,xMax=4.5,yMin=0,yMax=9,zMin=0,zMax=6,IIIDticks]

    \psset{linewidth=0.05, linecolor=black,arrowsize=0.2}   
    \pstThreeDLine{<->}(0, 0, 1.7)(0, 2, 1.7)
        \pstPlanePut[plane=yz,
            planecorr=normal](0, 2, 4.1){$\frac{L_g}{4}$}
    \pstThreeDLine{<->}(0, 2.7, 0.1)(0, 2.7, 1.6625)
        \pstPlanePut[plane=yz,
            planecorr=normal](0, 6, 1.6){\colorbox{white!10}{$\frac{L_o}{4}$}}  
    \pstThreeDLine{<->}(0.5, 0, 0.1)(0.5, 0, 4.9)
        \pstPlanePut[plane=xz,
            planecorr=normal](2.2, 0, 4.4){$D$}
    \pstThreeDLine{<->}(0.5, 0, 0)(0.5, 8, 0)
        \pstPlanePut[plane=yz,
            planecorr=xyrot](0.5, 8, -1){$\frac{3}{4}L_g$}
    \end{pspicture}
%\egroup
\end{document}

如果您有一些需要在图表输入文件和主输入文件中加载的设置,请将这些设置放在一个新包中,即mycommonsetting.sty,并将其保存在 TeX 系统可以找到的文件夹中。

所有图表都转换为 PDF 格式后,您现在可以从主输入文件导入它们,如下所示

% the filename of this code is main.tex
% compile it with
% pdflatex main

\documentclass{article}
\usepackage{graphicx}
\graphicspath{{Images/}}
\begin{document}
\includegraphics{diagram-1}
\end{document}

我假设文件夹Images包含您要从中导入的所有图表,这些main.tex图表保存在文件夹所在的同一文件夹中Images。困惑吗?这是文件和文件夹的树结构。

\<any folder>\main.tex
\<any folder>\Images\diagram-1.tex

使用 编译主程序后,您将获得项目的 PDF 输出pdflatex main。完成。

答案2

When I use this document:

\documentclass[a4paper,11pt]{report}
\usepackage{ifxetex}
\usepackage{amsmath}
\ifxetex
  \usepackage{unicode-math}
  \setmathfont{XITS Math}
\else
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
\fi
\usepackage{libertine}
\usepackage[french]{babel}

\usepackage{a4wide}
\usepackage[table,dvipsnames]{xcolor}
\NoAutoSpaceBeforeFDP % empêcher d'ajouter un espace après :
\usepackage{wrapfig}
\usepackage{caption}
\usepackage{fancyhdr}
\usepackage{fancyref}
\usepackage[locale = FR]{siunitx}
\usepackage[hyperindex, pdfborder={0 0 0}]{hyperref} % Table des matières & références interactive

\usepackage{pst-circ,pst-plot,pst-3dplot, pst-solides3d}
\begin{document}
...
... The PSTricks code
...
\end{document}

xelatex <file>我可以毫无问题地通过运行或使用来 创建文档latex->dvips->ps2pdf

答案3

解决了,我遇到了GhostScript由于 Adob​​e Illustrator 引起的问题...

我用它将一些 pdf 转换为 eps 文件,但带来了一些错误......

我用pdf2ps(终端命令)转换了它们,问题就解决了......

相关内容