3

I'm trying to add custom blocks in addition to the ones already defined by scratch3

I made a top-level file customblocks.sty that currently contains

\ProvidesPackage{customblocks}
\RequirePackage{scratch3}
\definecolor{customcolor}{RGB}{100, 50, 200}
\newcommand*\ovalcustom{\scr_ovalbox0{customcolor}}

I just tried my best to copy and modify from the scratch3.sty definitions, which look like:

\newcommand*\ovalsensing{%
    \scr_ifstar
        {\scr_ovalbox1{scrsensing}}
        {\scr_ovalbox0{scrsensing}}%
}
\def\scr_blocksensing{\scr_normalblock{scrsensing}}
\newcommand*\boolsensing{\scr_boolbox{scrsensing}}

I import my custom package in my preamble

\usepackage{scratch3}
\usepackage{customblocks}

Then I try to use it later on

\ovalcustom{attempting}

But I get lots of errors, I think ultimately caused by

Undefined control sequence.
\ovalcustom ->\scr
_ovalbox0{customcolor}
l.10 \item \ovalcustom
{attempting}

The control sequence at the end of the top line of your error message
was never \def'ed

How can I actually add more blocks on top of the scratch3 package?

1 Answer 1

6

At the top of scratch3.sty you'll see a block of code that (mainly) does

\catcode`\_11

and restores it at the end.

that makes _ a letter so that \scr_normalblock is seen as a command with name scr_normalblock

You are using the code in a scope where _ is a math subscript so
\scr_normalblock is \scr _{n} ormalblock looking for an undefined command \scr

2
  • That makes sense and seems to be what I'm encountering while trying different things in my sty file. So should I copy/paste those relevant definitions from top of scratch3.sty into my file? How much of it is relevant, there are some \long\def... lines following which I cannot follow at all
    – minseong
    Commented Apr 12, 2021 at 19:35
  • @theonlygusti yes it is defing \scr_restorecatcode which you can call right at the end to put everything back to normal. Commented Apr 12, 2021 at 19:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .