![无法修补 pict2e 以形成可填充的椭圆形](https://linux22.com/image/406115/%E6%97%A0%E6%B3%95%E4%BF%AE%E8%A1%A5%20pict2e%20%E4%BB%A5%E5%BD%A2%E6%88%90%E5%8F%AF%E5%A1%AB%E5%85%85%E7%9A%84%E6%A4%AD%E5%9C%86%E5%BD%A2.png)
我正在尝试“即时”修补,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}