我正在尝试使用乳胶中的帕斯卡三角形创建一个有孔的路径网格。还有指南针

我正在尝试使用乳胶中的帕斯卡三角形创建一个有孔的路径网格。还有指南针

下面的图片展示了我正在尝试做的事情。

另外我不确定对于这个特定问题应该使用哪个标签。

新图片

我正在使用的代码:

 \documentclass[28pt]{article}

 \usepackage{fancyhdr}

 \usepackage[includeheadfoot,margin=1.0cm]{geometry} 
 \usepackage{amsmath,amsthm,amssymb}
 \usepackage{enumitem}
 \usepackage{mathtools}
 \usepackage{framed}
 \usepackage{chessfss} %chess figure for HW #2
 \usepackage[english]{babel} %table for problem A.43
 \usepackage{multirow} %table for problem A.43
%\usepackage[table]{xcolor} color certain blocks in a table
%\usepackage[pass,showframe]{geometry}  just to show the margins
 \usepackage[makeroom]{cancel}
 \usepackage{array}  %BETWEEN TWO 2-DIGIT NUMBERS

 \newcommand{\N}{\mathbb{N}}
 \newcommand{\Z}{\mathbb{Z}}
 \newcommand{\thedate}{\today}

 \newtheoremstyle{case}{}{}{}{}{}{:}{ }{}
 \theoremstyle{case}
 \newtheorem{case}{Case}


 \newenvironment{theorem}[2][Theorem]{\begin{trivlist}
 \item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
 \newenvironment{lemma}[2][Lemma]{\begin{trivlist}
 \item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
 \newenvironment{exercise}[2][Exercise]{\begin{trivlist}
 \item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
 \newenvironment{problem}[2][Problem]{\begin{trivlist}
 \item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
 \newenvironment{question}[2][Question]{\begin{trivlist}
 \item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}
 \newenvironment{corollary}[2][Corollary]{\begin{trivlist}
 \item[\hskip \labelsep {\bfseries #1}\hskip \labelsep {\bfseries #2.}]}{\end{trivlist}}

 \begin{document}

 \end{document}

答案1

我认为这样做可以:

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{math}
\begin{document}
\begin{tikzpicture}[x=2cm,y=-2cm, node 0/.style={fill=red!20}]
\tikzmath{%
  int \i, \j, \m, \n, \t;
  \m = 6; \n = 6;
  % Initialise board.
  for \i in {0,...,\m}{
    for \j in {0,...,\n}{
      \t{\i,\j} = 0;
    };
  };
  % Create holes.
  \t{0,3} = -1;
  \t{4,4} = -1;
  \t{5,1} = -1;
  \t{2,5} = -1;
  % Perform calculations.
  for \i1 in {0,...,\m}{
    for \j1 in {0,...,\n}{
      if (\t{\i1,\j1} == -1) then {
          \t{\i1,\j1} = 0;
      } else {
        if (\i1 == 0 || \j1 == 0) then  {
          \t{\i1,\j1} = 1;            
        } else {
          \i2 = \i1 - 1;
          \j2 = \j1 - 1;
          \t{\i1,\j1} = \t{\i2,\j1} + \t{\i1,\j2}; 
        };
      };
    };
  };
  % Draw nodes.
  for \i1 in {0,...,\m}{
    for \j1 in {0,...,\n}{
    { \node [circle, fill=blue!20, minimum size=1cm, node \t{\i1,\j1}/.try] 
        (n-\i1-\j1) at (\j1, \i1) {\t{\i1,\j1}}; };
    };   
  };
  % Draw edges.
  for \i1 in {0,...,\m}{
    for \j1 in {0,...,\n}{
      \i2 = \i1 + 1;
      \j2 = \j1 + 1;
      if (\i1 < \m) then {
        if (\t{\i2,\j1} > 0) then { 
              { \draw [thick, -stealth] (n-\i1-\j1) -- (n-\i2-\j1); };
          }; 
        };
        if (\j1 < \n) then {
        if (\t{\i1,\j2} > 0) then { 
              { \draw [thick, -stealth] (n-\i1-\j1) -- (n-\i1-\j2); };
        }; 
      };
    };
  };
}
\end{tikzpicture}
\end{document}

在此处输入图片描述

如果没有“洞”,就可以做得更简单:

\documentclass[tikz,border=5]{standalone}
\usepackage{xintexpr}
\begin{document}
\begin{tikzpicture}[x=2cm,y=2cm]
\draw [help lines] grid [step=1] (6,-6);
\foreach \x in {0,...,6}
  \foreach \y in {0,...,6}
    \node [circle, fill=blue!20, minimum size=1cm]
      at (\x, -\y) {\xinttheiiexpr binomial(\x+\y,\x)\relax};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容