Debian Codegraph @

texmf-dist/doc/latex/bussproofs-colorful/bussproof-colorful-manual.tex

raw
1 \documentclass[a4paper,1pt]{article}
2
3 \usepackage[T1]{fontenc}
4 \usepackage{lmodern}
5 \usepackage{microtype}
6 \usepackage{geometry}
7 \usepackage{xcolor}
8 \usepackage{hyperref}
9 \usepackage{tcolorbox}
10 \usepackage{listings}
11 \usepackage{bussproofs}
12 \usepackage{bussproofs-colorful}
13
14 \geometry{margin=2.5cm}
15
16 \title{\textbf{bussproofs-colorful}\\
17 \large Color extension for the \texttt{bussproofs} package}
18 \author{Julian}
19 \date{Version \bussproofscolorfulVersion{} — \today}
20
21 \lstset{
22 basicstyle=\ttfamily\small,
23 breaklines=true,
24 columns=fullflexible,
25 }
26
27 \hypersetup{
28 colorlinks=true,
29 linkcolor=black,
30 urlcolor=blue,
31 citecolor=blue,
32 pdftitle={The bussproofs-colorful package},
33 pdfauthor={Julian}
34 }
35
36 \begin{document}
37 \maketitle
38
39 \begin{abstract}
40 \texttt{bussproofs-colorful} is a small extension to the
41 \texttt{bussproofs} package that adds color control for proof trees.
42 It allows users to customize the colors of nodes (formulas), inference
43 lines, and rule labels via package options and runtime commands, while
44 preserving the original layout and spacing of \texttt{bussproofs}.
45 \end{abstract}
46
47 \tableofcontents
48
49 \section{Introduction}
50
51 The \texttt{bussproofs} package by Sam Buss is a tool for typesetting
52 natural deduction and sequent-style proof trees in \LaTeX.
53 By default, all elements of a proof tree - formulas, inference lines,
54 and rule labels - are typeset in the surrounding text color.
55
56 The \texttt{bussproofs-colorful} package provides a thin layer of
57 color-awareness on top of \texttt{bussproofs}. It introduces:
58
59 \begin{itemize}
60 \item user-level color options for nodes, inference lines, and labels,
61 \item a small theme system,
62 \item runtime commands to change colors locally,
63 \item a convenience environment for local color blocks.
64 \end{itemize}
65
66 The design goal is \emph{minimal invasion}: the original layout logic
67 of \texttt{bussproofs} is preserved. Only selected macros are
68 redefined to wrap their output in color commands.
69
70 \section{Installation}
71
72 \subsection{Files}
73
74 This work currently consists of a single file:
75 \begin{itemize}
76 \item \texttt{bussproofs-colorful.sty}
77 \end{itemize}
78
79 Place this file somewhere in your \TeX{} tree where \LaTeX{} can find
80 it, for example, in a local directory searched by your distribution or
81 in the same directory as your document.
82
83 \subsection{Loading the package}
84
85 Load \texttt{bussproofs} and then \texttt{bussproofs-colorful}:
86
87 \begin{verbatim}
88 \usepackage{bussproofs}
89 \usepackage{bussproofs-colorful}
90 \end{verbatim}
91
92 You may also pass options to \texttt{bussproofs-colorful}, as
93 described in Section~\ref{sec:options}.
94
95 \section{Package options}
96 \label{sec:options}
97
98 The package uses \texttt{kvoptions} to provide key--value options.
99 All options are optional; sensible defaults are applied if they are
100 not specified.
101
102 \subsection{Color options}
103
104 The following options control the default colors at package load time:
105
106 \begin{description}
107 \item[\texttt{nodecolor=color}]
108 Sets the default color for nodes (formulas) in proof trees.
109 Example:
110 \begin{verbatim}
111 \usepackage[nodecolor=red]{bussproofs-colorful}
112 \end{verbatim}
113
114 \item[\texttt{linecolor=color}]
115 Sets the default color for inference lines.
116 \begin{verbatim}
117 \usepackage[linecolor=blue]{bussproofs-colorful}
118 \end{verbatim}
119
120 \item[\texttt{labelcolor=color}]
121 Sets the default color for rule labels.
122 \begin{verbatim}
123 \usepackage[labelcolor=gray]{bussproofs-colorful}
124 \end{verbatim}
125 \end{description}
126
127 If any of these options are omitted, the default is \texttt{black}.
128
129 \subsection{Theme option}
130 \label{sec:options:theme}
131
132 The \texttt{theme} option provides a small set of built-in presets:
133
134 \begin{description}
135 \item[\texttt{theme=classic}] (default)
136 All colors are black.
137
138 \item[\texttt{theme=dark}]
139 White nodes, gray lines, yellow labels.
140
141 \item[\texttt{theme=pastel}]
142 Blue-ish nodes, purple-ish lines, teal-ish labels.
143
144 \item[\texttt{theme=highcontrast}]
145 Black nodes, red lines, blue labels.
146 \end{description}
147
148 Example:
149
150 \begin{verbatim}
151 \usepackage[theme=dark]{bussproofs-colorful}
152 \end{verbatim}
153
154 Themes set the \emph{package defaults}. Runtime colors can still be changed later using the runtime commands described
155 in Section~\ref{sec:commands}.
156
157 \subsection{Patch toggles}
158
159 The following boolean options control which parts of
160 \texttt{bussproofs} are patched:
161
162 \begin{description}
163 \item[\texttt{patchnodes=true/false}]
164 Enable or disable coloring of nodes (formulas).
165
166 \item[\texttt{patchlines=true/false}]
167 Enable or disable coloring of inference lines.
168
169 \item[\texttt{patchlabels=true/false}]
170 Enable or disable coloring of rule labels.
171 \end{description}
172
173 All three default to \texttt{true}. For example, to color only lines:
174
175 \begin{verbatim}
176 \usepackage[
177 patchnodes=false,
178 patchlabels=false,
179 linecolor=red
180 ]{bussproofs-colorful}
181 \end{verbatim}
182
183 \subsection{Debug option}
184
185 The \texttt{debug} option enables informational messages about which
186 patches are applied:
187
188 \begin{verbatim}
189 \usepackage[debug=true]{bussproofs-colorful}
190 \end{verbatim}
191
192 Messages are printed through \verb|\PackageInfo| and can be useful when
193 inspecting interactions with other packages.
194
195 \section{Runtime commands}
196 \label{sec:commands}
197
198 In addition to package options, \texttt{bussproofs-colorful} provides
199 commands to change colors at runtime.
200
201 \subsection{\texorpdfstring{\texttt{\textbackslash SetNodeColor}}{SetNodeColor}}
202
203 \begin{verbatim}
204 \SetNodeColor{<color>}
205 \end{verbatim}
206
207 Sets the node (formula) color for subsequent proof trees or within the
208 current scope.
209
210 \subsection{\texorpdfstring{\texttt{\textbackslash SetLineColor}}{SetLineColor}}
211
212 \begin{verbatim}
213 \SetLineColor{<color>}
214 \end{verbatim}
215
216 Sets the inference line color.
217
218 \subsection{\texorpdfstring{\texttt{\textbackslash SetLabelColor}}{SetLabelColor}}
219
220 \begin{verbatim}
221 \SetLabelColor{<color>}
222 \end{verbatim}
223
224 Sets the color of the label.
225
226 \subsection{\texorpdfstring{\texttt{\textbackslash ResetProofColors}}{ResetProofColors}}
227
228 \begin{verbatim}
229 \ResetProofColors
230 \end{verbatim}
231
232 Resets the runtime colors back to the package-level defaults (as
233 determined by options and theme).
234
235 \subsection*{Loading themes at runtime}
236 \begin{lstlisting}
237 \LoadProofTheme{<theme>}
238 \end{lstlisting}
239
240 For available themes see Section~\ref{sec:options:theme}.
241
242 This updates the runtime colors but does not modify package defaults.
243
244 \section{Environments and scoping}
245
246 \subsection{\texttt{prooftree} scoping}
247
248 The package ensures that color changes are scoped to each
249 \texttt{prooftree} environment. Colors set inside a proof tree do not
250 leak into subsequent proof trees or the surrounding document, unless
251 you explicitly change them outside.
252
253 \subsection{\texttt{ProofColors} environment}
254
255 The \texttt{ProofColors} environment provides a convenient way to
256 apply local colors to a block of content, typically a single proof
257 tree:
258
259 \begin{verbatim}
260 \begin{ProofColors}[node=red, line=blue, label=green]
261 ... content ...
262 \end{ProofColors}
263 \end{verbatim}
264
265 The optional argument accepts a comma-separated list of key--value
266 pairs:
267
268 \begin{description}
269 \item[\texttt{node=<color>}] local node color
270 \item[\texttt{line=<color>}] local line color
271 \item[\texttt{label=<color>}] local label color
272 \item[\texttt{theme=<theme>}] local theme
273 \end{description}
274
275 These settings are scoped to the environment and do not affect colors
276 outside of it.
277 \section{Examples}
278
279 This section demonstrates the functionality of
280 \texttt{bussproofs-colorful} using side-by-side examples.
281 Each example shows the \LaTeX{} source on the left and the rendered
282 output on the right. All examples assume that
283 \texttt{bussproofs} and \texttt{bussproofs-colorful} are loaded.
284
285 \subsection{Basic usage}
286
287 \begin{tcolorbox}[
288 colback=white,
289 colframe=black,
290 sidebyside,
291 sidebyside align=center seam,
292 title={Basic proof tree}
293 ]
294 \begin{lstlisting}
295 \begin{prooftree}
296 \AxiomC{A}
297 \RightLabel{B}
298 \UnaryInfC{C}
299 \end{prooftree}
300 \end{lstlisting}
301 \tcblower
302 \begin{prooftree}
303 \AxiomC{A}
304 \RightLabel{B}
305 \UnaryInfC{C}
306 \end{prooftree}
307 \end{tcolorbox}
308
309 \subsection{Setting colors at package load time}
310
311 \begin{tcolorbox}[
312 colback=white,
313 colframe=black,
314 sidebyside,
315 sidebyside align=center seam,
316 title={Setting colors at package load time}
317 ]
318 \begin{lstlisting}
319 \usepackage[
320 nodecolor=red,
321 linecolor=blue,
322 labelcolor=gray
323 ]{bussproofs-colorful}
324
325 \begin{prooftree}
326 \AxiomC{A}
327 \RightLabel{B}
328 \UnaryInfC{C}
329 \end{prooftree}
330 \end{lstlisting}
331 \tcblower
332 % Simulated output
333 \begin{prooftree}
334 \SetNodeColor{red}
335 \SetLineColor{blue}
336 \SetLabelColor{gray}
337 \AxiomC{A}
338 \RightLabel{B}
339 \UnaryInfC{C}
340 \end{prooftree}
341 \end{tcolorbox}
342
343 \subsection{Changing colors inside a proof}
344
345 \begin{tcolorbox}[
346 colback=white,
347 colframe=black,
348 sidebyside,
349 sidebyside align=center seam,
350 title={Changing colors inside a proof}
351 ]
352 \begin{lstlisting}
353 \begin{prooftree}
354 \SetLineColor{red}
355 \AxiomC{A}
356
357 \SetLabelColor{blue}
358 \RightLabel{R}
359
360 \SetLabelColor{green}
361 \LeftLabel{L}
362
363 \SetNodeColor{orange}
364 \UnaryInfC{B}
365 \end{prooftree}
366 \end{lstlisting}
367 \tcblower
368 \begin{prooftree}
369 \SetLineColor{red}
370 \AxiomC{A}
371
372 \SetLabelColor{blue}
373 \RightLabel{R}
374
375 \SetLabelColor{green}
376 \LeftLabel{L}
377
378 \SetNodeColor{orange}
379 \UnaryInfC{B}
380 \end{prooftree}
381 \end{tcolorbox}
382
383 \subsection{Using themes}
384
385 \begin{tcolorbox}[
386 colback=white,
387 colframe=black,
388 sidebyside,
389 sidebyside align=center seam,
390 title={Using themes}
391 ]
392 \begin{lstlisting}
393 \usepackage[
394 theme=highcontrast
395 ]{bussproofs-colorful}
396
397 \begin{prooftree}
398 \AxiomC{A}
399 \RightLabel{B}
400 \UnaryInfC{C}
401 \end{prooftree}
402 \end{lstlisting}
403 \tcblower
404 % Simulated theme=dark output
405 \begin{prooftree}
406 \LoadProofTheme{highcontrast}
407 \AxiomC{A}
408 \RightLabel{B}
409 \UnaryInfC{C}
410 \end{prooftree}
411 \end{tcolorbox}
412
413 \subsection{Combining themes with manual overrides}
414
415 \begin{tcolorbox}[
416 colback=white,
417 colframe=black,
418 sidebyside,
419 sidebyside align=center seam,
420 title={Combining themes with manual overrides}
421 ]
422 \begin{lstlisting}
423 \LoadProofTheme{pastel}
424
425 \SetNodeColor{red}
426 \SetLabelColor{blue}
427
428 \begin{prooftree}
429 \AxiomC{A}
430 \RightLabel{B}
431 \UnaryInfC{C}
432 \end{prooftree}
433 \end{lstlisting}
434 \tcblower
435 \LoadProofTheme{pastel}
436 \SetNodeColor{red}
437 \SetLabelColor{blue}
438
439 \begin{prooftree}
440 \AxiomC{A}
441 \RightLabel{B}
442 \UnaryInfC{C}
443 \end{prooftree}
444 \end{tcolorbox}
445
446 \subsection{Switching themes mid-document}
447
448 \begin{tcolorbox}[
449 colback=white,
450 colframe=black,
451 sidebyside,
452 sidebyside align=center seam,
453 title={Switching themes mid-document}
454 ]
455 \begin{lstlisting}
456 \LoadProofTheme{classic}
457
458 \begin{prooftree}
459 \AxiomC{A}
460 \UnaryInfC{B}
461 \end{prooftree}
462
463 \LoadProofTheme{pastel}
464
465 \begin{prooftree}
466 \AxiomC{C}
467 \UnaryInfC{D}
468 \end{prooftree}
469 \end{lstlisting}
470 \tcblower
471 \LoadProofTheme{classic}
472 \begin{prooftree}
473 \AxiomC{A}
474 \UnaryInfC{B}
475 \end{prooftree}
476
477 \LoadProofTheme{pastel}
478 \begin{prooftree}
479 \AxiomC{C}
480 \UnaryInfC{D}
481 \end{prooftree}
482 \end{tcolorbox}
483
484 \subsection{Local color blocks}
485
486 \begin{tcolorbox}[
487 colback=white,
488 colframe=black,
489 sidebyside,
490 sidebyside align=center seam,
491 title={Local color blocks with \texttt{ProofColors}}
492 ]
493 \begin{lstlisting}
494 \begin{ProofColors}[node=red,
495 line=gray]
496 \begin{prooftree}
497 \AxiomC{A}
498 \UnaryInfC{B}
499 \end{prooftree}
500 \end{ProofColors}
501 \end{lstlisting}
502 \tcblower
503 \begin{ProofColors}[node=red, line=gray]
504 \begin{prooftree}
505 \AxiomC{A}
506 \UnaryInfC{B}
507 \end{prooftree}
508 \end{ProofColors}
509 \end{tcolorbox}
510
511 \subsection{Nested \texttt{ProofColors} blocks}
512
513 \begin{tcolorbox}[
514 colback=white,
515 colframe=black,
516 sidebyside,
517 sidebyside align=center seam,
518 title={Nested \texttt{ProofColors} blocks}
519 ]
520 \begin{lstlisting}
521 \begin{ProofColors}[node=red]
522 \begin{prooftree}
523 \AxiomC{A}
524 \UnaryInfC{B}
525 \end{prooftree}
526
527 \begin{ProofColors}[node=blue]
528 \begin{prooftree}
529 \AxiomC{C}
530 \UnaryInfC{D}
531 \end{prooftree}
532 \end{ProofColors}
533
534 \begin{prooftree}
535 \AxiomC{E}
536 \UnaryInfC{F}
537 \end{prooftree}
538 \end{ProofColors}
539 \end{lstlisting}
540 \tcblower
541 \begin{ProofColors}[node=red]
542 \begin{prooftree}
543 \AxiomC{A}
544 \UnaryInfC{B}
545 \end{prooftree}
546
547 \begin{ProofColors}[node=blue]
548 \begin{prooftree}
549 \AxiomC{C}
550 \UnaryInfC{D}
551 \end{prooftree}
552 \end{ProofColors}
553
554 \begin{prooftree}
555 \AxiomC{E}
556 \UnaryInfC{F}
557 \end{prooftree}
558 \end{ProofColors}
559 \end{tcolorbox}
560
561 \subsection{Local theme override inside \texttt{ProofColors}}
562
563 \begin{tcolorbox}[
564 colback=white,
565 colframe=black,
566 sidebyside,
567 sidebyside align=center seam,
568 title={Local theme override inside \texttt{ProofColors}}
569 ]
570 \begin{lstlisting}
571 \LoadProofTheme{classic}
572
573 \begin{ProofColors}[theme=pastel]
574 \begin{prooftree}
575 \AxiomC{A}
576 \UnaryInfC{B}
577 \end{prooftree}
578 \end{ProofColors}
579
580 \begin{prooftree}
581 \AxiomC{C}
582 \UnaryInfC{D}
583 \end{prooftree}
584 \end{lstlisting}
585 \tcblower
586 \LoadProofTheme{classic}
587
588 \begin{ProofColors}[theme=pastel]
589 \begin{prooftree}
590 \AxiomC{A}
591 \UnaryInfC{B}
592 \end{prooftree}
593 \end{ProofColors}
594
595 \begin{prooftree}
596 \AxiomC{C}
597 \UnaryInfC{D}
598 \end{prooftree}
599 \end{tcolorbox}
600
601 \subsection{Resetting colors}
602
603 \begin{tcolorbox}[
604 colback=white,
605 colframe=black,
606 sidebyside,
607 sidebyside align=center seam,
608 title={Resetting colors}
609 ]
610 \begin{lstlisting}
611 \SetNodeColor{red}
612 \SetLineColor{blue}
613
614 \begin{prooftree}
615 \AxiomC{A}
616 \UnaryInfC{B}
617 \end{prooftree}
618
619 \ResetProofColors
620
621 \begin{prooftree}
622 \AxiomC{A}
623 \UnaryInfC{B}
624 \end{prooftree}
625 \end{lstlisting}
626 \tcblower
627 \SetNodeColor{red}
628 \SetLineColor{blue}
629
630 \begin{prooftree}
631 \AxiomC{A}
632 \UnaryInfC{B}
633 \end{prooftree}
634
635 \ResetProofColors
636
637 \begin{prooftree}
638 \AxiomC{A}
639 \UnaryInfC{B}
640 \end{prooftree}
641 \end{tcolorbox}
642
643 \subsection{Resetting inside a local block}
644
645 \begin{tcolorbox}[
646 colback=white,
647 colframe=black,
648 sidebyside,
649 sidebyside align=center seam,
650 title={Resetting inside a local block}
651 ]
652 \begin{lstlisting}
653 \begin{ProofColors}[node=red]
654 \SetNodeColor{green}
655
656 \begin{prooftree}
657 \AxiomC{A}
658 \UnaryInfC{B}
659 \end{prooftree}
660
661 \ResetProofColors
662
663 \begin{prooftree}
664 \AxiomC{C}
665 \UnaryInfC{D}
666 \end{prooftree}
667 \end{ProofColors}
668 \end{lstlisting}
669 \tcblower
670 \begin{ProofColors}[node=red]
671 \SetNodeColor{green}
672 \begin{prooftree}
673 \AxiomC{A}
674 \UnaryInfC{B}
675 \end{prooftree}
676
677 \ResetProofColors
678 \begin{prooftree}
679 \AxiomC{C}
680 \UnaryInfC{D}
681 \end{prooftree}
682 \end{ProofColors}
683 \end{tcolorbox}
684
685 \subsection{Full workflow example}
686
687 \begin{tcolorbox}[
688 colback=white,
689 colframe=black,
690 sidebyside,
691 sidebyside align=center seam,
692 title={Full workflow example}
693 ]
694 \begin{lstlisting}
695 \LoadProofTheme{pastel}
696
697 \begin{prooftree}
698 \AxiomC{A}
699 \UnaryInfC{B}
700 \end{prooftree}
701
702 \SetNodeColor{red}
703
704 \begin{prooftree}
705 \AxiomC{C}
706 \UnaryInfC{D}
707 \end{prooftree}
708
709 \ResetProofColors
710
711 \begin{ProofColors}[line=gray]
712 \begin{prooftree}
713 \AxiomC{E}
714 \UnaryInfC{F}
715 \end{prooftree}
716 \end{ProofColors}
717 \end{lstlisting}
718 \tcblower
719 \LoadProofTheme{pastel}
720
721 \begin{prooftree}
722 \AxiomC{A}
723 \UnaryInfC{B}
724 \end{prooftree}
725
726 \SetNodeColor{red}
727 \begin{prooftree}
728 \AxiomC{C}
729 \UnaryInfC{D}
730 \end{prooftree}
731
732 \ResetProofColors
733 \begin{ProofColors}[line=gray]
734 \begin{prooftree}
735 \AxiomC{E}
736 \UnaryInfC{F}
737 \end{prooftree}
738 \end{ProofColors}
739 \end{tcolorbox}
740
741 \section{Implementation notes}
742
743 The patching strategy used in \texttt{bussproofs-colorful} follows a
744 minimal-invasion approach:
745
746 \begin{itemize}
747 \item Most patched macros are direct copies of the corresponding
748 \texttt{bussproofs} definitions, with only color insertion
749 points added.
750 \item No structural changes are made to the original layout logic,
751 dimensions, or spacing algorithms.
752 \item The \texttt{bussproofs} package itself is not modified; only
753 selected macros are redefined locally.
754 \end{itemize}
755
756 This design aims to preserve full compatibility with
757 \texttt{bussproofs} while enabling color customization.
758
759 \section{Known limitations}
760
761 \begin{itemize}
762 \item If other packages or user code also redefine the same
763 \texttt{bussproofs} macros, the order of loading may matter.
764 \item The package assumes the standard \texttt{bussproofs} interface;
765 heavily customized setups may require additional patching.
766 \item Colors are applied via \texttt{xcolor}; any limitations of
767 \texttt{xcolor} (e.g.\ unsupported color models) also apply
768 here.
769 \end{itemize}
770
771 \section{License and maintenance}
772
773 This work may be distributed and/or modified under the conditions of
774 the \emph{\LaTeX{} Project Public License} (LPPL), version 1.3c or any
775 later version. The latest version of this license is available at:
776 \begin{center}
777 \url{https://www.latex-project.org/lppl/}
778 \end{center}
779
780 This work has the LPPL maintenance status \emph{maintained}. The
781 current maintainer of this work is Julian (lambdaphoenix).
782
783 This work consists of the file \texttt{bussproofs-colorful.sty} and
784 this documentation.
785
786 \section{Project Information}
787
788 The \texttt{bussproofs-colorful} package is developed openly on GitHub.
789 Users are encouraged to report issues, request features, or contribute
790 improvements.
791
792 \subsection*{Repository}
793
794 \begin{itemize}
795 \item Project page: \url{https://github.com/lambdaphoenix/bussproofs-colorful}
796 \item Issue tracker: \url{https://github.com/lambdaphoenix/bussproofs-colorful/issues}
797 \end{itemize}
798
799 The repository contains:
800
801 \begin{itemize}
802 \item the package source file \texttt{bussproofs-colorful.sty}
803 \item the documentation source and PDF
804 \end{itemize}
805
806 \subsection*{Bug reports and feature requests}
807
808 If you encounter unexpected behavior, incompatibilities, or missing
809 features, please open an issue on GitHub. When reporting a problem,
810 include:
811
812 \begin{itemize}
813 \item a minimal working example (MWE)
814 \item your \LaTeX{} distribution and version
815 \item the package version number
816 \end{itemize}
817
818 \subsection*{Contributing}
819
820 Contributions are welcome. Pull requests should follow the existing code
821 style and include examples when appropriate.
822
823 \section{Change log}
824
825 \subsection*{v1.0 (2026/01/27)}
826
827 \begin{itemize}
828 \item Initial public version.
829 \item Color control for nodes, inference lines, and labels.
830 \item Theme system (\texttt{classic}, \texttt{dark}, \texttt{pastel},
831 \texttt{highcontrast}).
832 \item Runtime commands and \texttt{ProofColors} environment.
833 \end{itemize}
834
835 \end{document}