Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diagram generator tikZ example could be simplified #213

Open
PeterSommerlad opened this issue Jan 13, 2022 · 0 comments
Open

Diagram generator tikZ example could be simplified #213

PeterSommerlad opened this issue Jan 13, 2022 · 0 comments

Comments

@PeterSommerlad
Copy link

PeterSommerlad commented Jan 13, 2022

The tikZ example uses absolute values to crop the left margin from a picture. However, this is error prone and I think it might depend on the local latex installation. I suggest to add the following to the "additionalpackages" in the example, which will crop the resulting image automatically to its largest dimension, without having to consider any margins added by latex.

\standaloneconfig{varwidth=\paperwidth}

changing the corresponding part of readme.md and sample.md as

```{.tikz caption="This is an image, created by **TikZ i.e. LaTeX**."
     additionalPackages="\usepackage{adjustbox}\standaloneconfig{varwidth=\paperwidth}"}

\usetikzlibrary{arrows}
\tikzstyle{int}=[draw, fill=blue!20, minimum size=2em]
\tikzstyle{init} = [pin edge={to-,thin,black}]

\begin{tikzpicture}[node distance=2.5cm,auto,>=latex']
      \node [int, pin={[init]above:$v_0$}] (a) {$\frac{1}{s}$};
      \node (b) [left of=a,node distance=2cm, coordinate] {a};
      \node [int, pin={[init]above:$p_0$}] at (0,0) (c)
        [right of=a] {$\frac{1}{s}$};
      \node [coordinate] (end) [right of=c, node distance=2cm]{};
      \path[->] (b) edge node {$a$} (a);
      \path[->] (a) edge node {$v$} (c);
      \draw[->] (c) edge node {$p$} (end) ;
\end{tikzpicture}

```

This would have helped me a lot to get started.

Alternatively, this option can be provided directly by the lua filter in its internal template (note this can be changed to a different value as above.)

local tikz_template = [[
\documentclass[varwidth=\paperwidth]{standalone}
\usepackage{tikz}
%% begin: additional packages
%s
%% end: additional packages
\begin{document}
%s
\end{document}
]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant