无法修补 pict2e 以形成可填充的椭圆形

无法修补 pict2e 以形成可填充的椭圆形

我正在尝试“即时”修补,pict2e.sty以便可以填充椭圆形(来自这里:https://github.com/Rmano/circledsteps/issues/5)我尝试过这个:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pict2e, picture}
\usepackage{etoolbox}
\tracingpatches
\makeatletter
\newif\ifcstepsfilledovals
\patchcmd{\@oval}{\pIIe@strokeGraph}{%
    \ifcstepsfilledovals\pIIe@fillGraph\else\pIIe@strokeGraph\fi
    }{\typeout{OK}}{\typeout{FAIL}}
\makeatother

\begin{document}
\makebox(30pt,30pt){\put(0,0){\circle*{30pt}}}
\makebox(30pt,30pt){\put(0,0){\oval(30pt, 20pt)}}
\begingroup\cstepsfilledovalstrue
\makebox(30pt,30pt){\put(0,0){\oval(30pt, 20pt)}}
\endgroup
\makebox(30pt,30pt){\put(0,0){\oval(30pt, 20pt)}}

\end{document}

如果我手动对文件副本进行修补,它可以工作 --- 但是etoolbox显示如下内容:

[debug] tracing \patchcmd on input line 9
[debug] analyzing '\@oval'
[debug] ++ control sequence is defined
[debug] ++ control sequence is a macro
[debug] ++ macro can be retokenized cleanly
[debug] -- search pattern not found in replacement text
FAIL

但我不明白为什么。我怀疑是 catcode 出了问题,我不明白……

答案1

您正在加载picture,这基本上会重新定义每个pict2e宏。在这种情况下,您需要修补\PcOrg@@oval

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{pict2e, picture}
\usepackage{etoolbox}

\makeatletter
\newif\ifcstepsfilledovals
\@ifpackageloaded{picture}{\patchcmd\PcOrg@@oval}{\patchcmd\@oval}
  {\pIIe@strokeGraph}
  {\ifcstepsfilledovals\pIIe@fillGraph\else\pIIe@strokeGraph\fi}
  {\typeout{OK}}{\typeout{FAIL}}
\makeatother

\begin{document}
\makebox(30pt,30pt){\put(0,0){\circle*{30pt}}}
\makebox(30pt,30pt){\put(0,0){\oval(30pt, 20pt)}}
\begingroup\cstepsfilledovalstrue
\makebox(30pt,30pt){\put(0,0){\oval(30pt, 20pt)}}
\endgroup
\makebox(30pt,30pt){\put(0,0){\oval(30pt, 20pt)}}

\end{document}

在此处输入图片描述

相关内容