A am looking for a package or a simple method for typesetting blocks of pseudocode or just pre-formatted text. I know about the multitude of packages for typesetting algorithms, but all I need is a way to control the indentation and line breaks. Being able to mark indented blocks with a vertical line would be nice too (this one is done with algorithm2e): enter image description here

I do not want to use an extra level of indirection by defining LaTeX commands for all pseudocode terms I am going to use (\If, \While, \ExtractNextElementFrom, etc), I want to write algorithms as plain nested prose.

It should also be possible to use basic formatting (like emphasis) and math mode inside.

I would also like to be able to strip an equal amount of indentation from all lines (to distinguish source indentation from the layout indentation).

I am currently wondering if I can achieve this with some tabulating environment, or by defining my own environment for inserting an indented block inside another indented block... Is there a better way?

1 Answer 1


No vertical lines but simple to set up:

enter image description here



if \textbf{this}
  set $x$ to $y^2$
  if \textbf{that}
    while $z <0$ do
  • Nice! Could you provide some links to the documentation of \@vobeyspaces, \obeylines, and maybe other relevant links, please?
    – Alexey
    May 4, 2018 at 13:58
  • \obeylines is documented in the texbook, \@vobeyspaces is a version of \obeyspaces in the latex format, both are used in the definition of the standard verbatim environment, so texdoc source2e May 4, 2018 at 14:00
  • Though, i wonder how to strip some equal amount of indentation from all lines. I will edit the question.
    – Alexey
    May 4, 2018 at 14:00
  • @Alexey set \leftskip to some possibly negative value in the definition of zzz May 4, 2018 at 14:06
  • Can i automatically detect the current width of one space, to negate a specific number of spaces?
    – Alexey
    May 4, 2018 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.