% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3c
% of this license or (at your option) any later version.

\documentclass[a4paper,11pt]{article}
\usepackage{statementsp}
\usepackage[margin=1in]{geometry}

\newstatementsp{th}{Theorem}{000000}{B3D9FF}
\newstatementsp{def}{Definition}{000000}{FFB3B3}
\newstatementsp{lem}{Lemma}{000000}{D9EDD9}

\title{The \textsf{statementsp} Package Manual}
\author{Rirai Ikeda}
\date{\today \\ Version 1.0}

\begin{document}

\maketitle

\begin{abstract}
The \textsf{statementsp} package provides a convenient way to create highly customizable theorem and proposition boxes using \textsf{tcolorbox}. It features a unique ``Preview'' and ``Recall'' mechanism, allowing you to display a statement box before or after its actual definition in the document.
\end{abstract}

\tableofcontents
\vspace{1cm}

\section{Counters}
The counters for the statement environments provided by this package are strictly sequential within a section. This means that theorems, definitions, lemmas, and other environments share the same counter (e.g., Definition 1.1, Theorem 1.2, Lemma 1.3). This prevents numbering confusion across different types of mathematical statements.

\section{Using the Environments}
The basic syntax for using the standard numbered statement environment is:
\begin{verbatim}
\begin{statementsp}<prefix>[label](Statement Name)
    Body of the statement...
\end{statementsp}
\end{verbatim}

\subsection{Unnumbered Environments}
If you do not want to assign a number to a statement, you can use the starred version of the environment: \verb|statementsp*|. The syntax remains exactly the same, but the counter will not be incremented and no number will be displayed in the box title.

\begin{verbatim}
\begin{statementsp*}<prefix>[label](Statement Name)
    Body of the unnumbered statement...
\end{statementsp*}
\end{verbatim}

\subsection{Omitting Labels and Titles}
You can choose not to provide a reference label or a specific statement name by leaving the respective brackets or parentheses empty.
\begin{itemize}
    \item \textbf{Empty Label \texttt{[]}:} If the square brackets are empty, the package will not automatically generate a referencing label for this statement.
    \item \textbf{Empty Title \texttt{()}:} If the parentheses are empty, the specific statement name is hidden, leaving only the prefix name (and number, if applicable) in the title.
\end{itemize}

\section{Preview and Recall Features}
One of the key features of \textsf{statementsp} is the ability to show a box before it is defined (Preview) or show it again later (Recall). Use the \verb|\refcallsp{prefix:label}| command.

\subsection{The \texttt{\textbackslash refcallsp} Command}
The \verb|\refcallsp{prefix:label}| command allows you to display a statement box anywhere in your document. The package automatically determines whether the command appears before or after the main definition:
\begin{itemize}
    \item \textbf{Preview:} If you place \verb|\refcallsp| \textit{before} the main definition, it automatically generates a ``Preview'' box.
    \item \textbf{Recall:} If you place it \textit{after} the main definition, it automatically generates a ``Recall'' box.
\end{itemize}
In both cases, the title of the generated box contains a hyperlink that jumps directly to the main definition in the document.

\subsection{Preview Example}
Here is a preview of a theorem that is defined later in Section \ref{sec:main}. Note that clicking the title jumps to the actual definition.

\refcallsp{th:fermat}

\section{Main Definitions} \label{sec:main}
Here is a definition box.

\begin{statementsp}<def>[limit](Limit of a Sequence)
A sequence $(x_n)$ converges to a real number $L$ if, for every $\epsilon > 0$, there exists a natural number $N$ such that for all $n \ge N$, $|x_n - L| < \epsilon$.
\end{statementsp}

Here is the main theorem box that was previewed earlier.

\begin{statementsp}<th>[fermat](Fermat's Last Theorem)
No three positive integers $a$, $b$, and $c$ satisfy the equation $a^n + b^n = c^n$ for any integer value of $n$ greater than 2.
\end{statementsp}

Here is an example of an unnumbered environment using \verb|statementsp*|. Notice that it does not have a sequential number like the theorem and definition above.

\begin{statementsp*}<lem>[zorn](Zorn's Lemma)
Suppose a non-empty partially ordered set $P$ has the property that every chain in $P$ has an upper bound in $P$. Then the set $P$ contains at least one maximal element.
\end{statementsp*}

Here is an example demonstrating empty labels and titles. This definition is numbered, but it cannot be referenced, and it does not have a specific name attached to it.

\begin{statementsp}<def>[]()
A real number is called rational if it can be expressed as the quotient of two integers.
\end{statementsp}

And here is an unnumbered lemma with no label and no title.

\begin{statementsp*}<lem>[]()
This is a simple lemma that only displays its prefix.
\end{statementsp*}

\section{Referencing}
\subsection{Standard Referencing: \texttt{\textbackslash refsp} and \texttt{\textbackslash refnamesp}}
When referencing a statement, you must include the prefix defined in the \verb|\newstatementsp| command. For example, to reference the theorem defined above, you must use the prefix \verb|th| and the label \verb|fermat| like this: \verb|\refsp{th:fermat}|. Like \verb|\refcallsp|, these referencing commands can be used anywhere, before or after the main definition.

If you provided a specific name for the statement (e.g., ``Fermat's Last Theorem''), you can use the \verb|\refnamesp| command to reference both the number and the name together. 

\subsection{Reference Examples}
\begin{itemize}
    \item Using \verb|\refsp|: The famous theorem is \refsp{th:fermat}.
    \item Using \verb|\refnamesp|: The full reference is \refnamesp{th:fermat}.
\end{itemize}

Now we can also recall the definition defined earlier. This will automatically become a ``Recall'' box:

\refcallsp{def:limit}

\end{document}