I'm currently writing my masters thesis and I'm using algorithm2e to write pseudocode. I regularly use SetKwData to display data types. However I would slighty like to change how this is displayed when using arguments.

If I for example would like to display a key value map data type that is polymorphic in both the key, and data I would write something like this


\Dmap{\DFoo, DBar}

Then the compiled document would look something like

Map(Foo, Bar)

In my opinion this looks too much like a function call. I would like to change the parenthesis to something like Map<Foo, Bar>.

1 Answer 1


In the example below, based on how \SetKwData{Kw}{the text} is defined in algorithm2e.sty, a generalized macro \SetKwMetaData{Kw}{the text}{left delimiter}{right delimiter} is provided, which allows you to specify the delimiters. These delimiters were hard coded to be ( and ) in \SetKwData.


% \SetKwMetaData{Kw}{the text}{left delimiter}{right delimiter}
    \@ifnextchar\bgroup{\csname @#1\endcsname}{\DataSty{#2}\xspace}}%


  \DMap{\DFoo, \DBar}

enter image description here

  • Thank you, i tried something similar but without the \makeatletter, and \makeatother. Not sure why they are required but it works! thank you
    – Casper
    Jun 13, 2021 at 13:37
  • This pair of macros change and restore the catcode of @ character, so @ can be used as part of the name of control sequence, directly and locally (for example in \algocf@newcommand). Find more explanation in, e.g. tex.stackexchange.com/questions/106174/makeatletter-explained . Jun 13, 2021 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .