mfpic 图形仅显示空白 boxex

mfpic 图形仅显示空白 boxex

我对 LaTeX 还很陌生,这个问题可能有点愚蠢,但我花了好几个小时才弄清楚如何让实际图形显示在 TeXnicCenter 中。你能帮帮我吗?

以下是代码

\documentclass{article}
\usepackage[metapost,mplabels]{mfpic}
\opengraphsfile{mypics}
\begin{document}
Hyperbolic metric disks:

\begin{mfpic}[72]{-1}{1}{-1}{1}
  \setmfpair{Z}{(dir 45)/3}
  \setmfpair{W}{Moebius (Z)(.5*dir -45)}
  \draw\gfill[gray(.94)]\circle{(0,0),1}
  \draw\gfill[gray(.87)]\pshcircle{Z,4/5}
  \gfill[gray(.80)]\pshcircle{Z,1/2}
  \draw\gfill[gray(.73)]\pshcircle{W,1/2}
  \draw\pshcircle{Z,1/2}
  \tlpointsep{3bp}
  \point{Z,W,(0,0)}
  \tlabel[br]{Z}{$z$}
  \tlabel[tl]{W}{$w$}
  \tlabel[tr]{(0,0)}{$0$}
\end{mfpic}

Hyperbolic geodesics:

\begin{mfpic}[72]{-1}{1}{-1}{1}
  \circle{(0,0),1}
  \draw\gfill[gray(.88)]
    \lclosed
    \connect
      \hypergeodesic{.999*dir 0, .999*dir 120}
      \hypergeodesic{.999*dir 120, .999*dir 240}
      \hypergeodesic{.999*dir 240, .999*dir 0}
    \endconnect
  \mfpfor{K=6,12,24,48}
    \mfpfor{J=0 upto K-1}
      \rotatepath{(0,0),J*(360/K)}\hypergeodesic{.999*dir 0, .999*dir (360/K)}
    \endmfpfor
  \endmfpfor
\end{mfpic}

\closegraphsfile
\end{document}

空白图像图形框

答案1

您必须在文件mpost上运行mypics.mp。具体如何运行取决于您的操作系统和 TeX 发行版。

然而,在较新的 TeX 发行版中,您可以让 TeX 为您完成此操作。

\documentclass{article}
\usepackage[metapost,mplabels]{mfpic}
\usepackage{etoolbox}
\usepackage{shellesc}

\makeatletter
\patchcmd{\mfp@closegraphsfile}
  {\closeout\mfp@out}
  {\closeout\mfp@out\ShellEscape{r-mpost \mfp@filename}}
  {}{}
\makeatother

\opengraphsfile{mypics}
\begin{document}
Hyperbolic metric disks:

\begin{mfpic}[72]{-1}{1}{-1}{1}
  \setmfpair{Z}{(dir 45)/3}
  \setmfpair{W}{Moebius (Z)(.5*dir -45)}
  \draw\gfill[gray(.94)]\circle{(0,0),1}
  \draw\gfill[gray(.87)]\pshcircle{Z,4/5}
  \gfill[gray(.80)]\pshcircle{Z,1/2}
  \draw\gfill[gray(.73)]\pshcircle{W,1/2}
  \draw\pshcircle{Z,1/2}
  \tlpointsep{3bp}
  \point{Z,W,(0,0)}
  \tlabel[br]{Z}{$z$}
  \tlabel[tl]{W}{$w$}
  \tlabel[tr]{(0,0)}{$0$}
\end{mfpic}

Hyperbolic geodesics:

\begin{mfpic}[72]{-1}{1}{-1}{1}
  \circle{(0,0),1}
  \draw\gfill[gray(.88)]
    \lclosed
    \connect
      \hypergeodesic{.999*dir 0, .999*dir 120}
      \hypergeodesic{.999*dir 120, .999*dir 240}
      \hypergeodesic{.999*dir 240, .999*dir 0}
    \endconnect
  \mfpfor{K=6,12,24,48}
    \mfpfor{J=0 upto K-1}
      \rotatepath{(0,0),J*(360/K)}\hypergeodesic{.999*dir 0, .999*dir (360/K)}
    \endmfpfor
  \endmfpfor
\end{mfpic}

\closegraphsfile
\end{document}

因此,\closegraphsfile命令将处理生成的.mp文件,并且图片将在下次运行时加载。

代码调用r-mpost,这对于目的来说已经足够,并且也可以使用受限的(更安全)的 shell 逃逸来运行,而mpost需要不受限制的(不太安全)的 shell 逃逸。

在此处输入图片描述

相关内容