dylanowen/mdbook-graphviz

How to centre diagram?

xd009642 opened this issue · 4 comments

I might be missing something, I was just wondering if there's an easy way to centre the diagram on the page? I tried applying the center=true attribute in dot itself but it's still left aligned. I also tried placing a <div align="center"></div> around the code block but that didn't work - it caused the graphviz text to be mangled in the body.

For the garbled text I believe you need an empty line after the <div>, this might be a bug on my end or a quirk of common mark.

Using that I was able to center diagrams smaller than the body using <div style="display: block; text-align: center">. I'm sure there is a better way though especially if you want to center diagrams larger than the containing block.

Oh beautiful that worked for my use case, I'm happy with this being closed unless you want to keep it open to track any improvements to the existing behaviour. It would be nice if it just worked but a mention in the readme or a troubleshooting section would also probably work for most users

What if you add a class to the div? So it would be easier to write a css to center all of them. Otherwise, it would be quite annoying to add the same stil for all of them.

I believe this has been resolved but please reopen if needed.