3

Is there a package, tool, or method you would recommend for automatically drawing a large, complex, hierarchically nested box diagram, such as the sample below? example of hierarchically nested box diagram

I'd like to provide the input in textual format (so that I can easily perform large changes) and get the result in vector format (e.g. PDF), suitable for using within LaTeX. These are the alternatives I am considering, but all require significant work to get the result I need.

  • GNU pic with some macros
  • Write a Processing program
  • Write a script to generate nested LaTeX tables from simple textual input
  • 1
    See tex.stackexchange.com/questions/362307/… for some ideas. – John Kormylo May 2 '17 at 20:19
  • LaTeX is one option (specifically the famous TikZ), another is a CAD program, something like Blender or OpenSCAD, though those might be overkill. Or something like Dia might fit the bill, though that is much more limited in what it can do. But I don't think Dia is scriptable, so that probably won't work for you. – Faheem Mitha May 10 '17 at 15:18
7

I ended up designing and implementing a small domain-specific language for representing such figures. The language allows you to define

  • horizontal, and vertical framed boxes (hbox, vbox)
  • plain (unframed) composite boxes (pbox)
  • horizontal and vertical labels (hl, vl)

Boxes are put side by side; a blank line continues the layout on the next line.

The Python script generates a stand-alone LaTeX document. You can find the script and examples in this GitHub repository. Below is an example of an image and the corresponding code.

Hierarchical block diagram sample

hbox {
  hl Kernel Space
  hbox {
    hl System Call Interface
    vl break
    vl cemt
    vl ...
    vl unlink
    vl wait
    vl write
  }
  hbox Boot Loader

  vbox {
    hl Kernel Utility Functions
    vl alloc
    vl free
    vl wakeup
    vl mget
    vl access
    vl iget
  }
  pbox {
    hbox {
      hl I/O Subsystem
      hbox {
        pbox { # Special devices, named, and sockets
          hbox {
            hl Special Devices
            vl Line discipline
            vl Raw character
            vl Raw disk
          }
      hbox {
        hl Filesystem

        hbox inode layer

        hbox block layer
        }
      }

      hbox {
        hl Device Drivers
        hbox {
          hl Character Devices
          vl Keyboard
          vl Printer
          vl Paper tape
          vl ...
        }
    hbox {
      hl Block Devices
      vl rk: RK03 disk
      vl rf: RF11 disk
      vl mem
    }
      }
    }
  }
  hbox {
    hl Process Control Subsystem
    vl Scheduler
    vl Swap manager
    vl Memory manager
    vl ...
  }
}
1

I saw one that looked just like that many years ago. A quick Google shows it still exists. Still looks close to your requirements. I have no idea what its quality, features, etc are past it being a visual coding system w/ diagrams.

http://www.tersus.com/#Id=24

  • Welcome to TeX.SX! Interesting, but not TeX related. – egreg May 13 '17 at 22:58

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.