\documentclass[a4paper,1pt]{article}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage{geometry}
\usepackage{xcolor}
\usepackage{hyperref}
\usepackage{tcolorbox}
\usepackage{listings}
\usepackage{bussproofs}
\usepackage{bussproofs-colorful}

\geometry{margin=2.5cm}

\title{\textbf{bussproofs-colorful}\\
\large Color extension for the \texttt{bussproofs} package}
\author{Julian}
\date{Version \bussproofscolorfulVersion{} — \today}

\lstset{
    basicstyle=\ttfamily\small,
    breaklines=true,
    columns=fullflexible,
}

\hypersetup{
  colorlinks=true,
  linkcolor=black,
  urlcolor=blue,
  citecolor=blue,
  pdftitle={The bussproofs-colorful package},
  pdfauthor={Julian}
}

\begin{document}
\maketitle

\begin{abstract}
\texttt{bussproofs-colorful} is a small extension to the
\texttt{bussproofs} package that adds color control for proof trees.
It allows users to customize the colors of nodes (formulas), inference
lines, and rule labels via package options and runtime commands, while
preserving the original layout and spacing of \texttt{bussproofs}.
\end{abstract}

\tableofcontents

\section{Introduction}

The \texttt{bussproofs} package by Sam Buss is a tool for typesetting
natural deduction and sequent-style proof trees in \LaTeX.
By default, all elements of a proof tree - formulas, inference lines,
and rule labels - are typeset in the surrounding text color.

The \texttt{bussproofs-colorful} package provides a thin layer of
color-awareness on top of \texttt{bussproofs}. It introduces:

\begin{itemize}
  \item user-level color options for nodes, inference lines, and labels,
  \item a small theme system,
  \item runtime commands to change colors locally,
  \item a convenience environment for local color blocks.
\end{itemize}

The design goal is \emph{minimal invasion}: the original layout logic
of \texttt{bussproofs} is preserved. Only selected macros are
redefined to wrap their output in color commands.

\section{Installation}

\subsection{Files}

This work currently consists of a single file:
\begin{itemize}
  \item \texttt{bussproofs-colorful.sty}
\end{itemize}

Place this file somewhere in your \TeX{} tree where \LaTeX{} can find
it, for example, in a local directory searched by your distribution or
in the same directory as your document.

\subsection{Loading the package}

Load \texttt{bussproofs} and then \texttt{bussproofs-colorful}:

\begin{verbatim}
\usepackage{bussproofs}
\usepackage{bussproofs-colorful}
\end{verbatim}

You may also pass options to \texttt{bussproofs-colorful}, as
described in Section~\ref{sec:options}.

\section{Package options}
\label{sec:options}

The package uses \texttt{kvoptions} to provide key--value options.
All options are optional; sensible defaults are applied if they are
not specified.

\subsection{Color options}

The following options control the default colors at package load time:

\begin{description}
  \item[\texttt{nodecolor=color}]
    Sets the default color for nodes (formulas) in proof trees.
    Example:
\begin{verbatim}
\usepackage[nodecolor=red]{bussproofs-colorful}
\end{verbatim}

  \item[\texttt{linecolor=color}]
    Sets the default color for inference lines.
\begin{verbatim}
\usepackage[linecolor=blue]{bussproofs-colorful}
\end{verbatim}

  \item[\texttt{labelcolor=color}]
    Sets the default color for rule labels.
\begin{verbatim}
\usepackage[labelcolor=gray]{bussproofs-colorful}
\end{verbatim}
\end{description}

If any of these options are omitted, the default is \texttt{black}.

\subsection{Theme option}
\label{sec:options:theme}

The \texttt{theme} option provides a small set of built-in presets:

\begin{description}
  \item[\texttt{theme=classic}] (default)
    All colors are black.

  \item[\texttt{theme=dark}]
    White nodes, gray lines, yellow labels.

  \item[\texttt{theme=pastel}]
    Blue-ish nodes, purple-ish lines, teal-ish labels.

  \item[\texttt{theme=highcontrast}]
    Black nodes, red lines, blue labels.
\end{description}

Example:

\begin{verbatim}
\usepackage[theme=dark]{bussproofs-colorful}
\end{verbatim}

Themes set the \emph{package defaults}. Runtime colors can still be changed later using the runtime commands described
in Section~\ref{sec:commands}.

\subsection{Patch toggles}

The following boolean options control which parts of
\texttt{bussproofs} are patched:

\begin{description}
  \item[\texttt{patchnodes=true/false}]
    Enable or disable coloring of nodes (formulas).

  \item[\texttt{patchlines=true/false}]
    Enable or disable coloring of inference lines.

  \item[\texttt{patchlabels=true/false}]
    Enable or disable coloring of rule labels.
\end{description}

All three default to \texttt{true}. For example, to color only lines:

\begin{verbatim}
\usepackage[
  patchnodes=false,
  patchlabels=false,
  linecolor=red
]{bussproofs-colorful}
\end{verbatim}

\subsection{Debug option}

The \texttt{debug} option enables informational messages about which
patches are applied:

\begin{verbatim}
\usepackage[debug=true]{bussproofs-colorful}
\end{verbatim}

Messages are printed through \verb|\PackageInfo| and can be useful when
inspecting interactions with other packages.

\section{Runtime commands}
\label{sec:commands}

In addition to package options, \texttt{bussproofs-colorful} provides
commands to change colors at runtime.

\subsection{\texorpdfstring{\texttt{\textbackslash SetNodeColor}}{SetNodeColor}}

\begin{verbatim}
\SetNodeColor{<color>}
\end{verbatim}

Sets the node (formula) color for subsequent proof trees or within the
current scope.

\subsection{\texorpdfstring{\texttt{\textbackslash SetLineColor}}{SetLineColor}}

\begin{verbatim}
\SetLineColor{<color>}
\end{verbatim}

Sets the inference line color.

\subsection{\texorpdfstring{\texttt{\textbackslash SetLabelColor}}{SetLabelColor}}

\begin{verbatim}
\SetLabelColor{<color>}
\end{verbatim}

Sets the color of the label.

\subsection{\texorpdfstring{\texttt{\textbackslash ResetProofColors}}{ResetProofColors}}

\begin{verbatim}
\ResetProofColors
\end{verbatim}

Resets the runtime colors back to the package-level defaults (as
determined by options and theme).

\subsection*{Loading themes at runtime}
\begin{lstlisting}
\LoadProofTheme{<theme>}
\end{lstlisting}

For available themes see Section~\ref{sec:options:theme}.

This updates the runtime colors but does not modify package defaults.

\section{Environments and scoping}

\subsection{\texttt{prooftree} scoping}

The package ensures that color changes are scoped to each
\texttt{prooftree} environment. Colors set inside a proof tree do not
leak into subsequent proof trees or the surrounding document, unless
you explicitly change them outside.

\subsection{\texttt{ProofColors} environment}

The \texttt{ProofColors} environment provides a convenient way to
apply local colors to a block of content, typically a single proof
tree:

\begin{verbatim}
\begin{ProofColors}[node=red, line=blue, label=green]
  ... content ...
\end{ProofColors}
\end{verbatim}

The optional argument accepts a comma-separated list of key--value
pairs:

\begin{description}
  \item[\texttt{node=<color>}] local node color
  \item[\texttt{line=<color>}] local line color
  \item[\texttt{label=<color>}] local label color
  \item[\texttt{theme=<theme>}] local theme
\end{description}

These settings are scoped to the environment and do not affect colors
outside of it.
\section{Examples}

This section demonstrates the functionality of
\texttt{bussproofs-colorful} using side-by-side examples.  
Each example shows the \LaTeX{} source on the left and the rendered
output on the right. All examples assume that
\texttt{bussproofs} and \texttt{bussproofs-colorful} are loaded.

\subsection{Basic usage}

\begin{tcolorbox}[
  colback=white,
  colframe=black,
  sidebyside,
  sidebyside align=center seam,
  title={Basic proof tree}
]
\begin{lstlisting}
\begin{prooftree}
  \AxiomC{A}
  \RightLabel{B}
  \UnaryInfC{C}
\end{prooftree}
\end{lstlisting}
\tcblower
\begin{prooftree}
  \AxiomC{A}
  \RightLabel{B}
  \UnaryInfC{C}
\end{prooftree}
\end{tcolorbox}

\subsection{Setting colors at package load time}

\begin{tcolorbox}[
  colback=white,
  colframe=black,
  sidebyside,
  sidebyside align=center seam,
  title={Setting colors at package load time}
]
\begin{lstlisting}
\usepackage[
  nodecolor=red,
  linecolor=blue,
  labelcolor=gray
]{bussproofs-colorful}

\begin{prooftree}
  \AxiomC{A}
  \RightLabel{B}
  \UnaryInfC{C}
\end{prooftree}
\end{lstlisting}
\tcblower
% Simulated output
\begin{prooftree}
  \SetNodeColor{red}
  \SetLineColor{blue}
  \SetLabelColor{gray}
  \AxiomC{A}
  \RightLabel{B}
  \UnaryInfC{C}
\end{prooftree}
\end{tcolorbox}

\subsection{Changing colors inside a proof}

\begin{tcolorbox}[
  colback=white,
  colframe=black,
  sidebyside,
  sidebyside align=center seam,
  title={Changing colors inside a proof}
]
\begin{lstlisting}
\begin{prooftree}
  \SetLineColor{red}
  \AxiomC{A}

  \SetLabelColor{blue}
  \RightLabel{R}

  \SetLabelColor{green}
  \LeftLabel{L}

  \SetNodeColor{orange}
  \UnaryInfC{B}
\end{prooftree}
\end{lstlisting}
\tcblower
\begin{prooftree}
  \SetLineColor{red}
  \AxiomC{A}

  \SetLabelColor{blue}
  \RightLabel{R}

  \SetLabelColor{green}
  \LeftLabel{L}

  \SetNodeColor{orange}
  \UnaryInfC{B}
\end{prooftree}
\end{tcolorbox}

\subsection{Using themes}

\begin{tcolorbox}[
  colback=white,
  colframe=black,
  sidebyside,
  sidebyside align=center seam,
  title={Using themes}
]
\begin{lstlisting}
\usepackage[
theme=highcontrast
]{bussproofs-colorful}

\begin{prooftree}
  \AxiomC{A}
  \RightLabel{B}
  \UnaryInfC{C}
\end{prooftree}
\end{lstlisting}
\tcblower
% Simulated theme=dark output
\begin{prooftree}
  \LoadProofTheme{highcontrast}
  \AxiomC{A}
  \RightLabel{B}
  \UnaryInfC{C}
\end{prooftree}
\end{tcolorbox}

\subsection{Combining themes with manual overrides}

\begin{tcolorbox}[
  colback=white,
  colframe=black,
  sidebyside,
  sidebyside align=center seam,
  title={Combining themes with manual overrides}
]
\begin{lstlisting}
\LoadProofTheme{pastel}

\SetNodeColor{red}
\SetLabelColor{blue}

\begin{prooftree}
  \AxiomC{A}
  \RightLabel{B}
  \UnaryInfC{C}
\end{prooftree}
\end{lstlisting}
\tcblower
\LoadProofTheme{pastel}
\SetNodeColor{red}
\SetLabelColor{blue}

\begin{prooftree}
  \AxiomC{A}
  \RightLabel{B}
  \UnaryInfC{C}
\end{prooftree}
\end{tcolorbox}

\subsection{Switching themes mid-document}

\begin{tcolorbox}[
  colback=white,
  colframe=black,
  sidebyside,
  sidebyside align=center seam,
  title={Switching themes mid-document}
]
\begin{lstlisting}
\LoadProofTheme{classic}

\begin{prooftree}
  \AxiomC{A}
  \UnaryInfC{B}
\end{prooftree}

\LoadProofTheme{pastel}

\begin{prooftree}
  \AxiomC{C}
  \UnaryInfC{D}
\end{prooftree}
\end{lstlisting}
\tcblower
\LoadProofTheme{classic}
\begin{prooftree}
  \AxiomC{A}
  \UnaryInfC{B}
\end{prooftree}

\LoadProofTheme{pastel}
\begin{prooftree}
  \AxiomC{C}
  \UnaryInfC{D}
\end{prooftree}
\end{tcolorbox}

\subsection{Local color blocks}

\begin{tcolorbox}[
  colback=white,
  colframe=black,
  sidebyside,
  sidebyside align=center seam,
  title={Local color blocks with \texttt{ProofColors}}
]
\begin{lstlisting}
\begin{ProofColors}[node=red,
line=gray]
  \begin{prooftree}
    \AxiomC{A}
    \UnaryInfC{B}
  \end{prooftree}
\end{ProofColors}
\end{lstlisting}
\tcblower
\begin{ProofColors}[node=red, line=gray]
  \begin{prooftree}
    \AxiomC{A}
    \UnaryInfC{B}
  \end{prooftree}
\end{ProofColors}
\end{tcolorbox}

\subsection{Nested \texttt{ProofColors} blocks}

\begin{tcolorbox}[
  colback=white,
  colframe=black,
  sidebyside,
  sidebyside align=center seam,
  title={Nested \texttt{ProofColors} blocks}
]
\begin{lstlisting}
\begin{ProofColors}[node=red]
  \begin{prooftree}
    \AxiomC{A}
    \UnaryInfC{B}
  \end{prooftree}

  \begin{ProofColors}[node=blue]
    \begin{prooftree}
      \AxiomC{C}
      \UnaryInfC{D}
    \end{prooftree}
  \end{ProofColors}

  \begin{prooftree}
    \AxiomC{E}
    \UnaryInfC{F}
  \end{prooftree}
\end{ProofColors}
\end{lstlisting}
\tcblower
\begin{ProofColors}[node=red]
  \begin{prooftree}
    \AxiomC{A}
    \UnaryInfC{B}
  \end{prooftree}

  \begin{ProofColors}[node=blue]
    \begin{prooftree}
      \AxiomC{C}
      \UnaryInfC{D}
    \end{prooftree}
  \end{ProofColors}

  \begin{prooftree}
    \AxiomC{E}
    \UnaryInfC{F}
  \end{prooftree}
\end{ProofColors}
\end{tcolorbox}

\subsection{Local theme override inside \texttt{ProofColors}}

\begin{tcolorbox}[
  colback=white,
  colframe=black,
  sidebyside,
  sidebyside align=center seam,
  title={Local theme override inside \texttt{ProofColors}}
]
\begin{lstlisting}
\LoadProofTheme{classic}

\begin{ProofColors}[theme=pastel]
  \begin{prooftree}
    \AxiomC{A}
    \UnaryInfC{B}
  \end{prooftree}
\end{ProofColors}

\begin{prooftree}
  \AxiomC{C}
  \UnaryInfC{D}
\end{prooftree}
\end{lstlisting}
\tcblower
\LoadProofTheme{classic}

\begin{ProofColors}[theme=pastel]
  \begin{prooftree}
    \AxiomC{A}
    \UnaryInfC{B}
  \end{prooftree}
\end{ProofColors}

\begin{prooftree}
  \AxiomC{C}
  \UnaryInfC{D}
\end{prooftree}
\end{tcolorbox}

\subsection{Resetting colors}

\begin{tcolorbox}[
  colback=white,
  colframe=black,
  sidebyside,
  sidebyside align=center seam,
  title={Resetting colors}
]
\begin{lstlisting}
\SetNodeColor{red}
\SetLineColor{blue}

\begin{prooftree}
  \AxiomC{A}
  \UnaryInfC{B}
\end{prooftree}

\ResetProofColors

\begin{prooftree}
  \AxiomC{A}
  \UnaryInfC{B}
\end{prooftree}
\end{lstlisting}
\tcblower
\SetNodeColor{red}
\SetLineColor{blue}

\begin{prooftree}
  \AxiomC{A}
  \UnaryInfC{B}
\end{prooftree}

\ResetProofColors

\begin{prooftree}
  \AxiomC{A}
  \UnaryInfC{B}
\end{prooftree}
\end{tcolorbox}

\subsection{Resetting inside a local block}

\begin{tcolorbox}[
  colback=white,
  colframe=black,
  sidebyside,
  sidebyside align=center seam,
  title={Resetting inside a local block}
]
\begin{lstlisting}
\begin{ProofColors}[node=red]
  \SetNodeColor{green}

  \begin{prooftree}
    \AxiomC{A}
    \UnaryInfC{B}
  \end{prooftree}

  \ResetProofColors

  \begin{prooftree}
    \AxiomC{C}
    \UnaryInfC{D}
  \end{prooftree}
\end{ProofColors}
\end{lstlisting}
\tcblower
\begin{ProofColors}[node=red]
  \SetNodeColor{green}
  \begin{prooftree}
    \AxiomC{A}
    \UnaryInfC{B}
  \end{prooftree}

  \ResetProofColors
  \begin{prooftree}
    \AxiomC{C}
    \UnaryInfC{D}
  \end{prooftree}
\end{ProofColors}
\end{tcolorbox}

\subsection{Full workflow example}

\begin{tcolorbox}[
  colback=white,
  colframe=black,
  sidebyside,
  sidebyside align=center seam,
  title={Full workflow example}
]
\begin{lstlisting}
\LoadProofTheme{pastel}

\begin{prooftree}
  \AxiomC{A}
  \UnaryInfC{B}
\end{prooftree}

\SetNodeColor{red}

\begin{prooftree}
  \AxiomC{C}
  \UnaryInfC{D}
\end{prooftree}

\ResetProofColors

\begin{ProofColors}[line=gray]
  \begin{prooftree}
    \AxiomC{E}
    \UnaryInfC{F}
  \end{prooftree}
\end{ProofColors}
\end{lstlisting}
\tcblower
\LoadProofTheme{pastel}

\begin{prooftree}
  \AxiomC{A}
  \UnaryInfC{B}
\end{prooftree}

\SetNodeColor{red}
\begin{prooftree}
  \AxiomC{C}
  \UnaryInfC{D}
\end{prooftree}

\ResetProofColors
\begin{ProofColors}[line=gray]
  \begin{prooftree}
    \AxiomC{E}
    \UnaryInfC{F}
  \end{prooftree}
\end{ProofColors}
\end{tcolorbox}

\section{Implementation notes}

The patching strategy used in \texttt{bussproofs-colorful} follows a
minimal-invasion approach:

\begin{itemize}
  \item Most patched macros are direct copies of the corresponding
        \texttt{bussproofs} definitions, with only color insertion
        points added.
  \item No structural changes are made to the original layout logic,
        dimensions, or spacing algorithms.
  \item The \texttt{bussproofs} package itself is not modified; only
        selected macros are redefined locally.
\end{itemize}

This design aims to preserve full compatibility with
\texttt{bussproofs} while enabling color customization.

\section{Known limitations}

\begin{itemize}
  \item If other packages or user code also redefine the same
        \texttt{bussproofs} macros, the order of loading may matter.
  \item The package assumes the standard \texttt{bussproofs} interface;
        heavily customized setups may require additional patching.
  \item Colors are applied via \texttt{xcolor}; any limitations of
        \texttt{xcolor} (e.g.\ unsupported color models) also apply
        here.
\end{itemize}

\section{License and maintenance}

This work may be distributed and/or modified under the conditions of
the \emph{\LaTeX{} Project Public License} (LPPL), version 1.3c or any
later version. The latest version of this license is available at:
\begin{center}
  \url{https://www.latex-project.org/lppl/}
\end{center}

This work has the LPPL maintenance status \emph{maintained}. The
current maintainer of this work is Julian (lambdaphoenix).

This work consists of the file \texttt{bussproofs-colorful.sty} and
this documentation.

\section{Project Information}

The \texttt{bussproofs-colorful} package is developed openly on GitHub.
Users are encouraged to report issues, request features, or contribute
improvements.

\subsection*{Repository}

\begin{itemize}
  \item Project page: \url{https://github.com/lambdaphoenix/bussproofs-colorful}
  \item Issue tracker: \url{https://github.com/lambdaphoenix/bussproofs-colorful/issues}
\end{itemize}

The repository contains:

\begin{itemize}
  \item the package source file \texttt{bussproofs-colorful.sty}
  \item the documentation source and PDF
\end{itemize}

\subsection*{Bug reports and feature requests}

If you encounter unexpected behavior, incompatibilities, or missing
features, please open an issue on GitHub. When reporting a problem,
include:

\begin{itemize}
  \item a minimal working example (MWE)
  \item your \LaTeX{} distribution and version
  \item the package version number
\end{itemize}

\subsection*{Contributing}

Contributions are welcome. Pull requests should follow the existing code
style and include examples when appropriate.

\section{Change log}

\subsection*{v1.0 (2026/01/27)}

\begin{itemize}
  \item Initial public version.
  \item Color control for nodes, inference lines, and labels.
  \item Theme system (\texttt{classic}, \texttt{dark}, \texttt{pastel},
        \texttt{highcontrast}).
  \item Runtime commands and \texttt{ProofColors} environment.
\end{itemize}

\end{document}
