Debian Codegraph @

texmf-dist/doc/latex/terminalcode/README.md

raw
1 # terminalcode - Terminal-Style Code Boxes for LaTeX
2
3 A modern LaTeX package providing terminal-style code display with UTF-8 box-drawing characters, ANSI 16-color support, and dark/light themes.
4
5 *This package was developed with AI assistance for rapid prototyping and comprehensive documentation.*
6
7 **Version**: 0.9.0 | **Date**: 2025-11-02 | **License**: MIT | **CTAN Status**: Ready
8
9 ## 📦 Package Info
10
11 | Field | Value |
12 |-------|-------|
13 | **Name** | `terminalcode` |
14 | **Version** | 0.9.0 |
15 | **License** | MIT |
16 | **Author** | LoveElysia1314 |
17 | **Contact** | [email protected] |
18 | **Repository** | [GitHub](https://github.com/LoveElysia1314/terminalcode-sty) |
19
20 ## 🚀 Quick Start
21
22 ```latex
23 \documentclass{article}
24 \usepackage{terminalcode} % dark theme (default)
25
26 \begin{document}
27
28 \begin{termcode}[bash]{Terminal Session}
29 $ echo "Hello, World!"
30 Hello, World!
31 $ python --version
32 Python 3.9.0
33 \end{termcode}
34
35 \end{document}
36 ```
37
38 **Compile with:** `xelatex document.tex` or `lualatex document.tex`
39
40 ## ✨ Features
41
42 - **Terminal-style code boxes** with authentic styling
43 - **ANSI 16-color support** (dark/light themes)
44 - **Theme switching** - `\terminalcodetheme{light}`
45 - **Multi-language** - bash, python, text, etc.
46 - **External file inclusion** - `\terminput{Title}{file}`
47 - **UTF-8 box-drawing** characters
48 - **Line numbers** & automatic wrapping
49 - **LaTeX escape** via `«»` delimiters
50
51 ## 📋 Requirements
52
53 ### Required Compilers
54 - ✅ **XeLaTeX** (recommended)
55 - ✅ **LuaLaTeX**
56 - ❌ **pdfLaTeX** (not supported)
57
58 ### Required Packages
59 - `xcolor`, `tcolorbox` (with `most`), `listings`, `fontspec`, `kvoptions`
60
61 ### Fonts (with fallback)
62 1. **Primary**: DejaVu Sans Mono
63 2. **Fallback**: Latin Modern Mono
64 3. **System default** (with warning)
65
66 ## 🔧 Installation
67
68 ### Local Installation
69 ```latex
70 % Place terminalcode.sty in project directory
71 \usepackage{terminalcode}
72 ```
73
74 ### System Installation
75 **Linux/macOS:**
76 ```bash
77 mkdir -p ~/texmf/tex/latex/terminalcode
78 cp terminalcode.sty ~/texmf/tex/latex/terminalcode/
79 mktexlsr
80 ```
81
82 **Windows (MiKTeX):**
83 ```cmd
84 copy terminalcode.sty "C:\Program Files\MiKTeX\tex\latex\terminalcode\"
85 initexmf --update-fndb
86 ```
87
88 ## 🎯 Usage Examples
89
90 ### Basic with Options
91 ```latex
92 \usepackage[theme=light,monofont=Consolas]{terminalcode}
93 ```
94
95 ### Theme Switching
96 ```latex
97 \usepackage{terminalcode}
98
99 % Dark theme (default)
100 \begin{termcode}[text]{Dark Mode}
101 content
102 \end{termcode}
103
104 % Switch to light
105 \terminalcodetheme{light}
106
107 \begin{termcode}[text]{Light Mode}
108 content
109 \end{termcode}
110 ```
111
112 ### External Files
113 ```latex
114 \terminput[python]{Data Script}{scripts/process.py}
115 % Alias:
116 \termcodefileinput[bash]{Deploy Script}{deploy.sh}
117 ```
118
119 ### ANSI Colors in Code
120 ```latex
121 \begin{termcode}[text]{Colored Output}
122 Normal «\ac{31}»Red Text«\ansireset» Normal
123 «\ac{92}»Bright Green«\ansireset» Normal
124 \end{termcode}
125 ```
126
127 ## 📖 API Reference
128
129 ### Environments
130
131 | Command | Parameters | Description |
132 |---------|------------|-------------|
133 | `termcode[lang]{title}` | `lang`: language (default: text)<br>`title`: box title | Main code environment |
134
135 ### Commands
136
137 | Command | Parameters | Description |
138 |---------|------------|-------------|
139 | `\terminalcodetheme{theme}` | `dark` or `light` | Switch theme |
140 | `\terminput[lang]{title}{file}` | `lang`: language<br>`title`: box title<br>`file`: filename | Include external file |
141 | `\ansicolor{color}` | `color`: ANSI code (30-37, 90-97) | Apply ANSI color |
142 | `\ansireset` | - | Reset formatting |
143
144 **Aliases:** `\tctheme`, `\termcodefileinput`, `\ac`
145
146 ### Package Options
147
148 | Option | Values | Default | Description |
149 |--------|--------|---------|-------------|
150 | `theme` | `dark`, `light` | `dark` | Initial theme |
151 | `monofont` | Font name | `DejaVu Sans Mono` | Monospace font |
152
153 ## 🎨 ANSI Colors
154
155 ### Standard Colors (30-37)
156
157 | Code | Color | Dark Theme | Light Theme |
158 |------|-------|------------|-------------|
159 | 30 | Black | (46,52,54) | (127,140,141) |
160 | 31 | Red | (205,75,69) | (200,55,47) |
161 | 32 | Green | (75,183,72) | (39,174,96) |
162 | 33 | Yellow | (218,165,32) | (214,147,40) |
163 | 34 | Blue | (72,120,200) | (52,152,219) |
164 | 35 | Magenta | (164,84,208) | (142,68,173) |
165 | 36 | Cyan | (55,180,180) | (26,188,156) |
166 | 37 | White | (230,230,230) | (230,230,230) |
167
168 **Bright colors** available with codes 90-97.
169
170 ## ⚠️ Troubleshooting
171
172 ### Common Issues
173
174 **"Requires XeLaTeX or LuaLaTeX"**
175 - **Problem**: Using pdfLaTeX
176 - **Fix**: Compile with `xelatex` or `lualatex`
177
178 **Font warnings**
179 - **Problem**: Requested font not found
180 - **Fix**: Install font or use different `monofont` option
181
182 **Unicode characters not displaying**
183 - **Problem**: UTF-8 encoding issues
184 - **Fix**: Ensure UTF-8 file encoding and use XeLaTeX
185
186 ## 📄 Version History
187
188 ### v0.9.0 (2025-11-02) - Initial Release
189 - Terminal-style code boxes with ANSI colors
190 - Dark/light theme support
191 - External file inclusion
192 - Font fallback mechanism
193 - CTAN-ready structure
194
195 ## 📜 License
196
197 MIT License - See LICENSE file for details.
198
199 ## 🤝 Contributing
200
201 Bug reports and feature requests welcome via [GitHub Issues](https://github.com/LoveElysia1314/terminalcode-sty/issues).
202
203 ---
204
205 **Repository**: [github.com/LoveElysia1314/terminalcode-sty](https://github.com/LoveElysia1314/terminalcode-sty)
206 **CTAN**: [ctan.org/pkg/terminalcode](https://ctan.org/pkg/terminalcode)