有理数の可算性:図解
Countability Rationals
解決:
Qrrbrbirlbelがコメントしたように、あなたは使用することができます matrixコマンド。 NS
からの数学ノードの行列オプション
マトリックスライブラリは、各セルで数学モードを自動的にオンにすることで、タイピングを節約します。行列に名前を付けるとき
(m)、構文を使用できます
(m-i-j)行のセルを参照する
iと列
その行列のj。ノードを接続するには、マトリックスの設定後にエッジを描画するだけです。
documentclass {article} usepackage {tikz} usetikzlibrary {matrix} begin {document} begin {tikzpicture} matrix(m)[数学ノードの行列、列sep = 1cm、行sep = 1cm] {s_ {11 }&s_ {12}&s_ {13}&s_ {14}& cdots \ s_ {21}&s_ {22}&s_ {23}&s_ {24}& cdots \ s_ {31}& s_ {32}&s_ {33}&s_ {34}& cdots \ s_ {41}&s_ {42}&s_ {43}& cdots \}; draw [->](m-1-1)edge(m-1-2)(m-1-2)edge(m-2-1)(m-2-1)edge(m-3-1 )(m-3-1)エッジ(m-2-2)(m-2-2)エッジ(m-1-3)(m-1-3)エッジ(m-1-4)(m-1 -4)エッジ(m-2-3)(m-2-3)エッジ(m-3-2)(m-3-2)エッジ(m-4-1); end {tikzpicture} end {document}
これは、エッジを自動的に描画するソリューションです。それらを1つずつ指定する必要はありません!
グラフを好きなだけ大きくすることができます。正の整数の値を変更して、必要なノードの数を指定するだけです。NS。
注:ロードの失敗バベルパッケージと英語オプションはエラーを生成します。詳細については、tikz-umlシーケンス図の「Extra or」エラーを参照してください。
編集 :Qrrbrbirlbelの「チェーン」ソリューションも参照してください。これは私の精神に似ています。
documentclass {article} usepackage [english] {babel} usepackage {etoolbox} usepackage {pgfplots} usetikzlibrary {arrows} begin {document} begin {tikzpicture}%[->、> = stealth '、scale = 2、auto、thick、main node / .style =%{%circle、%fill = blue!20、%draw、font = sffamily Large bfseries、}] pgfmathtruncatemacro N {10} pgfmathtruncatemacro i { 1} pgfmathtruncatemacro j {1} node [main node] at( j、- i)(n1){$ S _ { i j} $}; pgfplotsforeachungrouped current in {1,2、...、 N-1}%{ pgfmathtruncatemacro next { current + 1} ifnum i = 1%(最初の行) ifnumodd { j}%{ %東に行く pgfmathtruncatemacro j { j + 1}} {%南西に行く pgfmathtruncatemacro i { i + 1} pgfmathtruncatemacro j { j-1}} else% ifnum j = 1% (最初の列) ifnumodd { i}%{%北東に移動 pgfmathtruncatemacro i { i-1} pgfmathtruncatemacro j { j + 1}} {%南に移動 pgfmathtruncatemacro i { i + 1 }} else pgfmathtruncatemacro { ijsum} { i + j} ifnumodd { ijsum}%{%南西に行く pgfmathtruncatemacro i { i + 1} pgfmathtruncatemacro j { j-1}} { %Go North East pgfmathtruncatemacro i { i-1} pgfmathtruncatemacro j { j + 1}} fi fi node [main node] at( j、- i)(n next){ $ S _ { i j} $}; draw(n current)-(n next); } end {tikzpicture} end {document}
マトリックス
TikZのようですここでは、 matrixが最も簡単なアプローチです。
と組み合わせるマトリックスを自動的に埋める空のセルで実行し、スタイルを設定するための連続したエッジを使用すると、この図を非常に高速に作成できます。
ただし、矢印は自動化できるパターンに従います。
これはキーで行われますマトリックスコネクタurr(右上、右)およびマトリックス内の名前付きノードに依存する検索アルゴリズムを初期化するマトリックスコネクタldd(左下、下)。
コード
documentclass [tikz、convert = false] {standalone} usetikzlibrary {matrix} makeatletter tikzset {@continous edge to / .style = {insert path = {edge(#1)(#1)}}、continous edge to /.style={@continousedgesto/.list={#1}}、マトリックスコネクタurr / .code args = {#1-#2-#3} {% [メール保護] {[メール保護] @ [メール保護]#1- the numexpr#2-1 Relax- the numexpr#3 + 1 relax} {% [メール保護] {[メール保護] @ [メール保護]#1-# 2- the numexpr#3 + 1 Relax} {} { tikzset {insert path = {(#1-#2-#3)edge(#1-#2- the numexpr#3 + 1 リラックス)}、マトリックスコネクタldd / .expanded = {#1-#2- the numexpr#3 + 1 Relax}}%}%} {% tikzset {insert path = {(#1-#2- #3)エッジ(#1- the numexpr#2-1 Relax- the numexpr#3 + 1 Relax)}、マトリックスコネクタurr / .expanded = {#1- the numexpr#2- 1 Relax- the numexpr#3 + 1 relax}}%}}、マトリックスコネクタldd / .code args = {#1-#2-#3} {% [メール保護] {[メール保護] @ [メール保護]#1- the numexpr#2 + 1 relax- the numexpr#3-1 relax} {% [メール保護] {[メール保護] @ [メール保護d]#1- the numexpr#2 + 1 Relax-#3} {} {% tikzset {insert path = {(#1-#2-#3)edge(#1- the numexpr# 2 + 1 Relax-#3)}、マトリックスコネクタurr / .expanded = {#1- the numexpr#2 + 1 relax-#3}}%}%} {% tikzset {insert path = { (#1-#2-#3)エッジ(#1- the numexpr#2 + 1 Relax- the numexpr#3-1 Relax)}、マトリックスコネクタldd / .expanded = {#1- the numexpr#2 + 1 relax- the numexpr#3-1 relax}}%}}、} makeatother begin {document} begin {tikzpicture} matrix(m)[ノードの行列、ノード= {形状=円、内部sep = +。1667em、%デフォルト値の半分}、空のセルで実行= { node {$ S _ { the pgfmatrixcurrentrow the pgfmatrixcurrentcolumn} $};}、行sep = 2em、列sep = 2em] {&&& \ &&& \ &&& \ &&& \}; path [->、超厚、マトリックスコネクタurr = {m-1-1}]; path [->、white、shorten> = 2 pgflinewidth](m-1-1)[連続エッジto = {m-1-2、m-2-1、m-3-1、m-2- 2、m-1-3、m-1-4、m-2-3、m-3-2、m-4-1}]; end {tikzpicture} end {document}出力
チェーン
Jubobsの回答と同様の代替アプローチは、の配置オプションを使用できるチェーンライブラリポジショニングライブラリ(つまりグリッド上、より優れた制御のためのノード距離)。接続されているノードを配置するためにのみ使用されます。
コード
documentclass [tikz、convert = false] {standalone} usetikzlibrary {chains} newcommand * { subscript} [3] [] {% ifodd#2 the numexpr#2 + 1-#3 Relax#1 #3% else#3#1 the numexpr#2 + 1-#3 Relax fi} tikzset {zigzag / .code 2 args = {% ifnum#1> 1 ifodd#1 ifnum# 2 = 1 def position {below}% else def position {above right}% fi else ifnum#2 = 1 def position {right}% else def position {below left} % fi fi tikzset { position = of tikzchainprevious} fi}、ジグザグ* /。code = {% edef llevel { number tikzchaincount}% pgfmathloop edef testllevel { the numexpr llevel- pgfmathcounter relax}% ifnum1> testllevel relax let level pgfmathcounter else let llevel testllevel repeatpgfmathloop tikzset {zigzag = level llevel}%}}% tikzset {すべてのラベル/.append style = {inner sep = + 0pt、outer sep = + 0pt、font = tiny}、label position =左上、すべての結合/.append style = {-latex}、} begin {document} begin {tikzpicture} [start chain = ch going {zigzag = level llevel}、node distance = .75cm and 1cm、every on chain / .append style = {join、l abel = {( number tikzchaincount)}}] foreach level in {1、...、4} foreach llevel in {1、...、 level} node [on chain = ch] { $ S _ { subscript [、] level llevel} $}; end {tikzpicture} begin {tikzpicture} [グリッド上、ノード距離= 1cmおよび1.5cm、開始チェーン= ch配置ジグザグ*、すべてのチェーン/.appendスタイル= {円、内側のsep = +。1667em、テキストの深さ= + 0pt、テキストの高さ= + 1.5ex、join、label / .expanded = {( noexpand subscript [/] { level} { llevel})}}] foreach cnt in {a、.. .. 、f} node [on chain = ch] { cnt}; foreach cnt in {G、...、M} node [on chain = ch] { cnt}; end {tikzpicture} end {document}出力