減小 tikz 箭袋圖的大小

減小 tikz 箭袋圖的大小

以下 tikz quiver 程式碼在 Latex 中編譯時顯得太大。有辦法減少嗎?

謝謝

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}

\[\begin{tikzcd}[cramped]
    &&&&&&&&&&& {v_7} \\
    \\
    &&&&&&&&&&& {v_1} \\
    \\
    &&&&&&&&&&& {v_4} \\
    \\
    &&&&&&&&&&& {v_{10}} \\
    \\
    &&&&&&&&& {v_{11}} &&&& {v_{12}} \\
    &&&&&& {v_5} &&&&&&&&&& {v_6} \\
    &&& {v_2} &&&&&&&&&&&&&&&& {v_3} \\
    {v_8} &&&&&&&&&&&&&&&&&&&&&& {v_9}
    \arrow[no head, from=7-12, to=9-10]
    \arrow[no head, from=7-12, to=9-14]
    \arrow[no head, from=9-10, to=9-14]
    \arrow[no head, from=5-12, to=10-7]
    \arrow[no head, from=5-12, to=10-17]
    \arrow[no head, from=10-7, to=10-17]
    \arrow[no head, from=3-12, to=11-4]
    \arrow[no head, from=3-12, to=11-20]
    \arrow[no head, from=11-4, to=11-20]
    \arrow[no head, from=1-12, to=12-23]
    \arrow[no head, from=1-12, to=12-1]
    \arrow[no head, from=12-1, to=12-23]
\end{tikzcd}\]

\end{document}

在此輸入影像描述

答案1

\documentclass[tikz, border=1cm]{standalone}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[cramped, sep=tiny]
&&&&&&&&&&& {v_7} \\
\\
&&&&&&&&&&& {v_1} \\
\\
&&&&&&&&&&& {v_4} \\
\\
&&&&&&&&&&& {v_{10}} \\
\\
&&&&&&&&& {v_{11}} &&&& {v_{12}} \\
&&&&&& {v_5} &&&&&&&&&& {v_6} \\
&&& {v_2} &&&&&&&&&&&&&&&& {v_3} \\
{v_8} &&&&&&&&&&&&&&&&&&&&&& {v_9}
\arrow[no head, from=7-12, to=9-10]
\arrow[no head, from=7-12, to=9-14]
\arrow[no head, from=9-10, to=9-14]
\arrow[no head, from=5-12, to=10-7]
\arrow[no head, from=5-12, to=10-17]
\arrow[no head, from=10-7, to=10-17]
\arrow[no head, from=3-12, to=11-4]
\arrow[no head, from=3-12, to=11-20]
\arrow[no head, from=11-4, to=11-20]
\arrow[no head, from=1-12, to=12-23]
\arrow[no head, from=1-12, to=12-1]
\arrow[no head, from=12-1, to=12-23]
\end{tikzcd}
\end{document}

三角累積圖

答案2

這是另一種方法。

結果

最後的程式碼僅顯示一個三角形,如果您在環境中使用它,它可以工作tikzpicture

% ~~~ just one triangle ~~~~~~~~~~~~~~~~~~~~~~~
    \draw ( 90:1) node[txt]{$v_1$} -- 
          (200:2) node[txt]{$v_2$} -- 
          (340:2) node[txt]{$v_3$} -- cycle;
  • 使用極座標
  • 從 (90:1) 繪製到 (200:2) 到 (340:2) 並關閉並結束 ( ;) 這條路徑
  • node每次到達下一個位置時都放置一個(注意丟失的\
  • 為此節點使用一個樣式,該樣式僅填充一些白色
  • 在數學模式下放置一些文本$ .. $

繪製第二個並從重構角度思考,使用 TeX 巨集似乎是合理的:

  • Tikz傾向於偏愛\def\newcommand當然是有原因的
  • 為了讓事情足夠簡單,我只傳遞垂直長度和 3 個索引(這當然可以進一步細化)
  • 它將同一個三角形抽象化為:
\def\triag#1#2#3#4{% y-length, 3 indices
    \draw ( 90:#1  ) node[txt]{$v_{#2}$} -- %
          (200:2*#1) node[txt]{$v_{#3}$} -- %
          (340:2*#1) node[txt]{$v_{#4}$} -- cycle;}%

最後,只需在環境中對這些三角形進行任意多次呼叫即可tikzpicture,該環境將擴展為一系列所述\draw ... ;路徑:

\documentclass[10pt,border=3mm,tikz]{standalone}

\def\triag#1#2#3#4{% y-length, 3 indices
    \draw ( 90:#1  ) node[txt]{$v_{#2}$} -- %
          (200:2*#1) node[txt]{$v_{#3}$} -- %
          (340:2*#1) node[txt]{$v_{#4}$} -- cycle;}%

\begin{document}
 \begin{tikzpicture}[
    txt/.style={fill=white},
 ]
    \triag{.5}{10}{11}{12}
    \triag{1  }{4}{5}{6}
    \triag{1.5}{1}{2}{3}
    \triag{2  }{7}{8}{9}
 \end{tikzpicture}
\end{document}

% ~~~ just one triangle ~~~~~~~~~~~~~~~~~~~~~~~
%   \draw ( 90:1) node[txt]{$v_1$} -- 
%         (200:2) node[txt]{$v_2$} -- 
%         (340:2) node[txt]{$v_3$} -- cycle;

% ~~~ later refactored using a TeX macro \triag ~~~

相關內容