obsidian-tikzjax icon indicating copy to clipboard operation
obsidian-tikzjax copied to clipboard

Image very small

Open Masacroso opened this issue 2 years ago • 8 comments

testing the package with some commutative diagrams, using the tikz-cd library I see that embedded SVG is very tiny. I tried to zoom it using some LaTeX command, by example the option \begin{tikzcd}[scale=10] or the solutions shown here but they don't work.

My code of example is this:

\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
G \arrow[rr, "f"] \arrow[rd, "c"] &  & H \\ & G/N \arrow[ru, "u"] &  
\end{tikzcd}
\end{document}

Masacroso avatar May 14 '23 23:05 Masacroso

I agree. The diagrams are so small, and it seems no commands are responsible for altering the size of it.

GuoHaoyang17295 avatar May 28 '23 05:05 GuoHaoyang17295

I found a way to manually adjust the size of a commutative diagram in the tikzcd environment: when you are making a diagram you always need to use & symbol to space two objects out. For example, if you want to make a triangle diagram, you probably need to insert:


\begin{tikzcd} G \arrow[rr, "f"] \arrow[rd, "c"] & & H \ & G/N \arrow[ru, "u"] & \end{tikzcd}

This shows how you made an inverted triangle.

Instead of just inserting the necessarily many of & symbol, you can try to add more &. Still using the convention above, but this time you try:


\begin{tikzcd} G \arrow[rrrr, "f"] \arrow[rrdd, "c"] & & & & H \ & & & & \ & & G/N \arrow[rruu, "u"] & & \end{tikzcd}

to make the diagram bigger. Don't forget to change the command for directions meanwhile.

I think this would be helpful!

GuoHaoyang17295 avatar May 29 '23 03:05 GuoHaoyang17295

if like me you're looking to literally scale everything and not just space them out, do something like this (taken from this se post):

\usepackage{tikz-cd}

% -- IMPORTANT HERE
\tikzcdset{scale cd/.style={every label/.append style={scale=#1},
    cells={nodes={scale=#1}}}}

\begin{document}

% -- "scale cd" defined above (adjust paramater for scales other than 2x)
\begin{tikzcd}[scale cd=2]
Fc && Gc \\ \\ {Fc'} && {Gc'} \arrow["Ff"', from=1-1, to=3-1] \arrow["{\alpha_c}", from=1-1, to=1-3] \arrow["Gf", from=1-3, to=3-3] \arrow["{\alpha_{c'}}"', from=3-1, to=3-3]
\end{tikzcd}
\end{document}

jacobhenn avatar Aug 10 '23 01:08 jacobhenn

It does some scaling, unfortunately not too much. However it scales the text more than the arrows, what can be seen if you change the scale from 2 to 5. Anyway it is the best temporary solution. But this problem must be solved scaling the DIV where the diagram is, that is, out of LaTeX.

Masacroso avatar Aug 10 '23 12:08 Masacroso

This scaling can be done by css, it could be resolved by adding some parsing for width and height settings in the codeblock:

i.e.

```tikz width:300px height:200px
<code here>
```

And then the plugin parsing that and applying the css to the relevant svg. @artisticat1, If you can provide a direction on how you'd like to fix this, I'd be happy to take a go at it!

mayurankv avatar Feb 23 '24 17:02 mayurankv

This scaling can be done by css, it could be resolved by adding some parsing for width and height settings in the codeblock:

i.e.

```tikz width:300px height:200px
<code here>

And then the plugin parsing that and applying the css to the relevant svg. @artisticat1, If you can provide a direction on how you'd like to fix this, I'd be happy to take a go at it!

This would be very nice. As now there is little tools to plot commutative diagrams in obsidian, I must rely on creating png with other programs and paste it inside the document.

Masacroso avatar Mar 06 '24 14:03 Masacroso

For those looking for a simple workaround that doesn't require changing any code in tikz blocks already written, you can add a CSS snippet as mentioned here

.markdown-rendered .block-language-tikz svg {
    zoom:2
}

abhmul avatar Apr 10 '24 22:04 abhmul

For those looking for a simple workaround that doesn't require changing any code in tikz blocks already written, you can add a CSS snippet as mentioned here

.markdown-rendered .block-language-tikz svg {
    zoom:2
}

This works nicely! Thank you very much.

Masacroso avatar Apr 11 '24 07:04 Masacroso