| eng_pikchr | R Documentation |
A custom knitr engine to render Pikchr diagrams as SVG (HTML output) or PNG (LaTeX, DOCX, and other non-HTML formats). Works with both RMarkdown and Quarto documents.
eng_pikchr(options)
options |
A list of chunk options from knitr. |
The eng_pikchr function allows you to use Pikchr code inside
R Markdown and Quarto documents, rendering it as an image. It supports
options like width, height, fontSize,
fontFamily, and CSS classes to customize the output.
The engine automatically detects the output format.
For HTML-based outputs (html, revealjs, slidy, etc.) the SVG is embedded
inline. For non-HTML outputs (LaTeX/PDF, DOCX, EPUB, Typst, etc.) the SVG
is converted to PNG via rsvg_png.
Rendered output suitable for the target document format.
Standard knitr options:
evalWhether to evaluate the Pikchr code (default TRUE).
echoWhether to display the code in the output (default TRUE).
fig.capFigure caption (supported in both HTML and non-HTML output).
fig.altAlternative text for accessibility (HTML only).
fig.alignFigure alignment: "left", "right", "center", or "default".
out.widthOutput width for non-HTML formats (e.g., "80%").
dpiResolution for PNG conversion in non-HTML output (default 150).
Pikchr-specific options:
widthCSS width of the SVG (default from viewBox, e.g., "80%").
heightCSS height of the SVG (default "auto").
fontSizeFont size for the diagram (default "100%").
fontFamilyFont family for the diagram (default "Jost").
classCSS class for the SVG element (default "pikchr").
cssAdditional inline CSS styles for the SVG.
marginCSS margin around the SVG (default "10px 0 10px 0").
pikchr, knit_engines
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.