| 1 | # fox-listings — Listings language definition for COSYScript (COSY INFINITY) |
| 2 | |
| 3 | A LaTeX package providing `listings` language support for |
| 4 | COSYScript, the programming language of |
| 5 | [COSY INFINITY](https://cosyinfinity.org), a beam dynamics code |
| 6 | using high-order differential-algebraic (DA) transfer maps and |
| 7 | methods. COSYScript source files use the `.fox` extension; this |
| 8 | package uses `FOX` as the `listings` language identifier. |
| 9 | |
| 10 | ## Features |
| 11 | |
| 12 | - Complete keyword coverage: control flow, intrinsic functions, |
| 13 | DA procedures, beam physics commands, graphics, constants |
| 14 | - Case-insensitive matching (FOX is case-insensitive) |
| 15 | - Nested `{...}` comment support |
| 16 | - Single-quoted string literals |
| 17 | - Two predefined styles: `FOXcolor` (screen) and `FOXmono` (print) |
| 18 | - Six keyword groups with independent styling |
| 19 | |
| 20 | ## Usage |
| 21 | |
| 22 | ```latex |
| 23 | \usepackage{fox-listings} |
| 24 | |
| 25 | \begin{lstlisting}[style=FOXcolor] |
| 26 | INCLUDE 'COSY' ; |
| 27 | VARIABLE X 1 ; |
| 28 | X := SIN(0.5) ; |
| 29 | WRITE 6 X ; |
| 30 | END ; |
| 31 | \end{lstlisting} |
| 32 | ``` |
| 33 | |
| 34 | Or with just the language (bring your own style): |
| 35 | |
| 36 | ```latex |
| 37 | \begin{lstlisting}[language=FOX] |
| 38 | ... |
| 39 | \end{lstlisting} |
| 40 | ``` |
| 41 | |
| 42 | ## Installation |
| 43 | |
| 44 | **From CTAN** (when available): Install via your TeX distribution's package |
| 45 | manager (`tlmgr install fox-listings`). |
| 46 | |
| 47 | **Manual install**: Copy `fox-listings.sty` to your local texmf tree and |
| 48 | refresh the filename database: |
| 49 | |
| 50 | ``` |
| 51 | cp fox-listings.sty $(kpsewhich -var-value=TEXMFHOME)/tex/latex/fox-listings/ |
| 52 | texhash |
| 53 | ``` |
| 54 | |
| 55 | **Per-project**: Place `fox-listings.sty` alongside your `.tex` file — no |
| 56 | installation needed. |
| 57 | |
| 58 | ## Requirements |
| 59 | |
| 60 | - `listings` package |
| 61 | - `xcolor` package (loaded automatically) |
| 62 | |
| 63 | ## Known limitations |
| 64 | |
| 65 | The `listings` package does not highlight in-code numbers for user-defined |
| 66 | languages. Fortran-style `D`-exponent notation (e.g., `1.5D-3`) and |
| 67 | standard decimal literals (`0.5`, `1E-3`) are rendered in the base style. |
| 68 | This is a `listings` limitation, not a `fox-listings` bug. |
| 69 | |
| 70 | The `listings` tokenizer has no scope or context awareness, so a user variable |
| 71 | that shares its name with a keyword (e.g., `OV`, `MQ`, `CR`) will be |
| 72 | highlighted as a keyword. |
| 73 | |
| 74 | ## License |
| 75 | |
| 76 | This material is subject to the LaTeX Project Public License 1.3c. |
| 77 | See https://www.latex-project.org/lppl/lppl-1-3c/ |
| 78 | |
| 79 | ## Author |
| 80 | |
| 81 | Eremey Valetov — https://github.com/evvaletov |
| 82 | |
| 83 | ## Links |
| 84 | |
| 85 | - COSY INFINITY: https://cosyinfinity.org |
| 86 | - foxkernel (Jupyter kernel for FOX): https://github.com/evvaletov/foxkernel |
| 87 | - cosy-vim (Vim/Neovim syntax): https://github.com/evvaletov/cosy-vim |