SATySFi icon indicating copy to clipboard operation
SATySFi copied to clipboard

\ref-theorem command cannot use in stdjareport environment

Open ritosonn opened this issue 3 years ago • 1 comments

On SATySFibook (web, v1) page 22, it says that the users can use \ref-theorem command as a cross reference of theorems, but this file made compile error.

@require: stdjareport
document (|
    title = {sample};
    author = {ritosonn};
|) '<
    +theorem?*?:(`thm`){}
    +proof{
        \ref-theorem(`thm`);
    }
>

error message:

$ satysfi ref.saty

(snip)

  type checking 'ref.saty' ...
! [Type Error] at "ref.saty", line 9, characters 8-20:
    undefined variable '\ref-theorem'.

I checked stdjareport.satyh , \ref-theorem doesn't define in this file. Then I checked https://github.com/xecua/dotfiles/blob/aa4a9c77e26e39888b1712ae2652002d2fbc6de3/satysfi/packages/mylib/stdjareport-ext.satyh and implemented it as follows:

@require: stdjareport
let-inline ctx \ref-theorem label = read-inline ctx {Theorem \ref(`theorem:`^label);} in
document (|
    title = {sample};
    author = {ritosonn};
|) '<
    +theorem?*?:(`thm`){}
    +proof{
        \ref-theorem(`thm`);
    }
>

Questions:

  • Is this implementation the expected ways to refer theorems?
  • How to implement \ref-theorem in the stdjareport (I'm beginner in the SATySFi language)

ritosonn avatar Jun 20 '21 05:06 ritosonn

+theorem?*?:(`xxx`){ ... } command registers the key theorem:xxx, and you can refer to the key with \ref command like this:

    +theorem?*?:(`thm`){}
    +proof{
        Theorem \ref(`theorem:thm`); is ...
    }

You will find the text "Theorem 0.0.1 is ..." in the artifact.

So the command \ref-theorem exists for shortcuts and is not always necessary. If you want to omit the prefixed text "Theorem" and the string theorem: at the beginning of the key, you can define the \ref-theorem with the either of following codes:

let-inline \ref-theorem label = {Theorem \ref(`theorem:`^label);}

or

let-inline ctx \ref-theorem label = read-inline ctx {Theorem \ref(`theorem:`^label);}

Both are legitimate ways to shorten the text Theorem \ref(`theorem:thm`); to the text \ref-theorem(`thm`);.

How to implement \ref-theorem in the stdjareport (I'm beginner in the SATySFi language)

If you plan to modify the stdjareport.satyh you can write like this:

module StdJaReport : sig

    % (... signatures of others ...)

    direct \ref-theorem : [string] inline-cmd

end = struct

    % (... implementations of others ...)

    let-inline \ref-theorem label = {Theorem \ref(`theorem:`^label);}

end

But it is not recommended to edit the local stdjareport.satyh directly, because the changes may cause conflicts or be overridden by future updates. Instead, you can define it locally as in the example you presented, or create your own package file like this file. Or, of course, sending a pull request to this repository is welcome ;)

monaqa avatar Jun 20 '21 07:06 monaqa