2

I am trying to patch "on the fly" pict2e.sty so that I can have filled ovals (this comes from here: https://github.com/Rmano/circledsteps/issues/5). I tried this:

\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}

If I do the patch by hand, on a copy of the file, it works --- but etoolbox is saying this:

[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

And I fail to see why. I suspect a catcode thing that I don't understand...

2
1

You're loading picture, which basically redefines every pict2e macro. In this case you need to patch \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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.