For diagrams... draw.io seems pretty great.
Steps to embed a diagram from there...
- File / Export as / SVG... 2. Selection Only (w/ Cropping) 2. Do not include a copy of my diagram
- Download
- Open the file
2. Copy the
<svg
line (not theDOCTYPE
) 2. Add theviewbox
attribute, documenting the internal canvas size (format is0 0 {width attribute} {height attribute}
) 2. Changingwidth
to be 100%, and remove theheight
attribute. - Reference the SVG from your document using snippet form (e.g.
--8<-- "snippets/diagrams/my-diagram-export.svg"
)
Example of the file change...
# before
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="806px" height="304px" version="1.1"
# after
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 806 304" width="100%" version="1.1"