artisticat1 / obsidian-tikzjax

Render LaTeX and TikZ diagrams in your notes
MIT License
395 stars 23 forks source link

Image very small #42

Open Masacroso opened 1 year ago

Masacroso commented 1 year ago

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}
GuoHaoyang17295 commented 1 year ago

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

GuoHaoyang17295 commented 1 year ago

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!

jacobhenn commented 1 year ago

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}
Masacroso commented 1 year ago

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.

mayurankv commented 7 months ago

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!
Masacroso commented 6 months ago

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.

abhmul commented 5 months ago

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
}
Masacroso commented 5 months ago

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.