There exists a number of pseudo-code packages for LaTeX. Can any of these describe things like a linked-list node in C:
struct Node
{
Node* parent;
// other stuff
};
or do I have to invent some custom macros
packagespseudocode
There exists a number of pseudo-code packages for LaTeX. Can any of these describe things like a linked-list node in C:
struct Node
{
Node* parent;
// other stuff
};
or do I have to invent some custom macros
Best Answer
One possible approach with
algorithm2e
. I defined a "program-like" blockMyStruct
that begins with the keywordStruct
, then typesets the structure name, then outputs keywordcontains
, and the end of the structure is denoted with keywordend
:All of this can be customized to your heart's content.
Usage within an algorithm is something like:
Here's a complete simple example and output:
This definition respects the global package options and also local switches, so you could use for example
[noend,noline]
as package options to disable typesetting of theend
keyword(s) and the vertical line delimiting the block: