Why can't I use the sagesilent environment in AtBeginDocument?

asked 2019-01-14 21:47:30 -0600

done_with_fish gravatar image

I'm trying to write a latex sty file to change the default behavior of sagetex.

My file is

\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{examplepackage}[2018/12/24 examplepackage]

\RequirePackage{sagetex}
\RequirePackage{etoolbox}

\AtBeginDocument{%
  \begin{sagesilent}
    A = 3
  \end{sagesilent}
}

\endinput

However, attempting to use this sty file in the following latex file produces the error ! File ended while scanning use of \next.

\documentclass[12pt]{article}

\usepackage{stupid}

\begin{document}
hello world!
\end{document}

What's wrong with my sty file?

edit retag flag offensive close merge delete