TransWikia.com

Python list slices

TeX - LaTeX Asked by Poor Standard on November 17, 2020

I’d like to typeset something like this

0   1   2   3   4   5 ...
+---+---+---+---+---+
| h | e | l | l | o  ...
+---+---+---+---+---+

to show slicing in Python lists.

Well, this tt solution works !

I looked at the bytefield package but I didn’t see how to have the indices put at column separators.

One Answer

You can use lapbox to move the bitheaders:

documentclass{article}
usepackage{bytefield}
usepackage{adjustbox}
makeatletter
newcommand*{centerbitheader}[1]{%
  lapbox{-.5bf@bitwidth}{#1}
}
makeatother
begin{document}
    begin{bytefield}{6}
      bitheader[bitformatting={tinycenterbitheader}]{0-5} 
          bitboxes{1}{HELLO}
       end{bytefield}
end{document}

enter image description here

Correct answer by DG' on November 17, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP