asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
431 stars 106 forks source link

tikz extension: missing documentation #369

Open pela9 opened 2 years ago

pela9 commented 2 years ago

Thanks for the tikz extension, works perfectly. I took me however some time to figure out some details in the setup. Some extra documentation will save time for future users.

  1. The preamble option is excellent, but I found no documentation, I had to look in the sources to see how it worked.
  2. The extension adds a small border (2bp) to the generated pictures, which you sometimes don't want (or set differently). This can easily be changed once you understand that the LaTeX document class standalone is used: \standaloneconfig{border=0pt}. But again I had to read the ruby sources to figure this out. (Maybe this can also be a diagram option.)
  3. For some tikz extension libraries, e.g. graphdrawing, lualatex is required instead of pdflatex. I solved this simply by setting -a pdlflatex=/bin/lualatex. This also seems worthwhile to document.
pepijnve commented 2 years ago

Thanks for providing this feedback regarding the documentation. I've been thinking about restructuring the documentation to have a short generic section followed by a section per diagram type. That would provide an excellent place to put diagram type specific details like what you're describing above. I'll make sure to keep your questions in mind when I get around to the documentation rework.

edward-encoord commented 2 years ago

Thanks for the tips on how to use preamble, but I cannot make it work.

I added :tikz-preamble: \input{path/to/preamble.tex}. I'm wondering if you can give more tips.

edward-encoord commented 2 years ago

I found some tips in the change log. I know how to add preamble now.

pela9 commented 2 years ago

As I have understood it, the preamble attribute is instead a Boolean flag which, if true, allows to separate LaTeX stuff for the internal preamble of the generated LaTeX file and the tikz picture using ~~~~ , for example:

[tikz, TikzTest3, pdf, preamble=true, width=30%]
....
\usetikzlibrary{shapes.multipart}
~~~~
\begin{tikzpicture}
\node [circle split,draw,double,fill=red!20]{Upper \nodepart{lower} Lower};
\end{tikzpicture}
....
edward-encoord commented 2 years ago

@pela9 Thanks for the quick reply. This is very helpful.

To include your example as PDF works, but if I try to include as SVG, it's like this:

image

If I convert the generated diagram PDF using pdf2svg manually, the SVG works. So I guess there is something wrong with my AsciiDoctor PDF settings.

So far, I'm using the font settings in the default AsciiDoctor PDF theme:

font:
  catalog:
    # Noto Serif supports Latin, Latin-1 Supplement, Latin Extended-A, Greek, Cyrillic, Vietnamese & an assortment of symbols
    Noto Serif:
      normal: GEM_FONTS_DIR/notoserif-regular-subset.ttf
      bold: GEM_FONTS_DIR/notoserif-bold-subset.ttf
      italic: GEM_FONTS_DIR/notoserif-italic-subset.ttf
      bold_italic: GEM_FONTS_DIR/notoserif-bold_italic-subset.ttf
    # M+ 1mn supports ASCII and the circled numbers used for conums
    M+ 1mn:
      normal: GEM_FONTS_DIR/mplus1mn-regular-subset.ttf
      bold: GEM_FONTS_DIR/mplus1mn-bold-subset.ttf
      italic: GEM_FONTS_DIR/mplus1mn-italic-subset.ttf
      bold_italic: GEM_FONTS_DIR/mplus1mn-bold_italic-subset.ttf

I don't have experience with the font settings so far, so I'm working on it.

edward-encoord commented 2 years ago

@pela9 I just render the same file in Linux. The text inside tikz diagrams works now :-) So I guess it's because I was using Windows.