LaTeX formatting practice is well-established and well-supported by existing packages for three common cases relevant in computer science:
- Source code listings
- Established, conventional mathematical notation
- Standard algorithmic pseudocode
I find I often want to describe things like records (a struct
in C parlance) or algebraic data types in a semi-formal notation which is typeset much closer to math mode (proportional fonts, somewhat set off but well integrated with the body text) than source code (fixed-width fonts, jarringly distinct from the body text), but find that general math mode is a mess without imposing a bit more structure and convention.
For example, I might want to describe a concrete instance of some data as a few records:
foo {
field : value
field : value
}
bar {
field : value
field : value
field : value
}
or I might want to sketch an algebraic data type like:
type t = Foo(type, type)
| Bar(type, type, type)
Are there packages, standard features of amsmath
, or even simply examples people like and conventions to follow here?
I'm looking for something that would be at home along side, for example, the algorithmic
environment for formatting pseudocode and simple math mode for describing pure functions. I am imagining something half-way in between a simplified ML-like notation, and full on amsmath
, which is meant to be typeset in a proportional font with high readability, not to look like fixed-width code.
I find my manual attempts are hitting an awkward midpoint where I am making a lot of choices to force raw math mode (or, e.g., the align
environment) to do something reasonable, and that things like the curly braces to delimit collections may be a poor choice. I'm hoping not to have to entirely derive my own notation and macros for it from scratch, but have so far failed to find anything preexisting that feels right.
amsmath
wasn't designed to cater for computer science, and isn't likely to do so in the near future. i hope you can find another compatible package. – barbara beeton Apr 18 '14 at 22:18