使用投影仪在二维网格中编号,并将幻灯片分成两半,如图所示

使用投影仪在二维网格中编号,并将幻灯片分成两半,如图所示

在此处输入图片描述

你好,

我正在尝试按如下方式对网格中的元素进行编号。我想知道我是否可以得到一些帮助。谢谢。我对写逻辑感到困惑。

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage[document]{ragged2e}
\usepackage{utopia} %font utopia imported
\usepackage{graphicx} %package to manage images
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{blkarray, bigstrut}
\usepackage[utf8]{inputenc}%codification of the document
\usepackage{tikz}
\usetheme{Warsaw}
\usecolortheme{beaver}
\usetikzlibrary{decorations.markings}

\title[Module 8]{MODULE 8 \\ Data Matrix : Generation }
\author[aa]{by\\aa
}
% START add slide number
\newcommand*\oldmacro{}%
\let\oldmacro\insertshorttitle%
\renewcommand*\insertshorttitle{%
  \oldmacro\hfill%
  \insertframenumber\,/\,\inserttotalframenumber}
% END add slide number


\date

\begin{document}


%1
%Here begins the body of the document
\begin{frame}
\titlepage
\end{frame}
%13
\begin{frame}
\frametitle{Re-numbered 2-D grid}
\begin{center}
\begin{tikzpicture}[thick,scale=0.4, every node/.style={scale=0.6}]

\draw (0,0) grid[step=2cm] (6,8);
\foreach \X [count=\x] in {0,...,3} 
{\foreach \Y [count=\y] in {0,...,4}
 {
 \ifnum\Y=0
  \node[anchor=north west] at (2*\X,2*\Y) {\x};
 \else
  \ifnum\Y=1
    {
   \node[anchor=south east] at (2*\X,2*\Y) {\number\numexpr\x+4};
    }
 \else
  \ifnum\Y=2
    {
   \node[anchor=south east] at (2*\X,2*\Y) {\number\numexpr\x+8};
    }
 \else
  \ifnum\Y=3
   {
   \node[anchor=south east] at (2*\X,2*\Y) {\number\numexpr\x+12};
    }
  \else
  {
   \node[anchor=south east] at (2*\X,2*\Y) {\number\numexpr\x+16};
  }
  \fi
 \fi
 \fi
 \fi
 }
}
\end{tikzpicture}
\end{center}
\end{frame}

答案1

要将幻灯片分成两半,只需将两tikzpicture半并排放置即可。

关于您的代码的一些其他评论:

  • \usepackage{utopia}这个包已经过时了

  • 你不需要\usepackage{graphicx}使用投影仪

  • 请不要多次加载同一个包,例如\usepackage[utf8]{inputenc}

  • 而不是这种复杂的结构

    % START add slide number
    \newcommand*\oldmacro{}%
    \let\oldmacro\insertshorttitle%
    \renewcommand*\insertshorttitle{%
     \oldmacro\hfill%
     \insertframenumber\,/\,\inserttotalframenumber}
    % END add slide number
    

    你可以简单地使用\setbeamertemplate{page number in head/foot}[totalframenumber]

  • 在你的 tikz 代码中,你可以通过使用\x+\Y*4


\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{ragged2e}
%\usepackage{utopia} %font utopia imported
%\usepackage{graphicx} %package to manage images
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{blkarray, bigstrut}
%\usepackage[utf8]{inputenc}%codification of the document
\usepackage{tikz}
\usetheme{Warsaw}
\usecolortheme{beaver}
\usetikzlibrary{decorations.markings}

\title[Module 8]{MODULE 8 \\ Data Matrix : Generation }
\author[aa]{by\texorpdfstring{\\}{}aa}
\setbeamertemplate{page number in head/foot}[totalframenumber]


\begin{document}

\begin{frame}
\frametitle{Re-numbered 2-D grid}
\begin{center}
\begin{tikzpicture}[thick,scale=0.4, every node/.style={scale=0.6}]

\draw (0,0) grid[step=2cm] (6,8);
\foreach \X [count=\x] in {0,...,3} 
{\foreach \Y [count=\y] in {0,...,4}
 {
 \ifnum\Y=0
  \node[anchor=north west] at (2*\X,2*\Y) {\x};
 \else
   \node[anchor=south east] at (2*\X,2*\Y) {\number\numexpr\x+\Y*4};
 \fi
 }
}
\end{tikzpicture}
\hspace{3cm}
\begin{tikzpicture}[thick,scale=0.4, every node/.style={scale=0.6}]

\draw (0,0) grid[step=2cm] (6,8);
\foreach \X [count=\x] in {0,...,3} 
{\foreach \Y [count=\y] in {0,...,4}
 {
 \ifnum\Y=0
  \node[anchor=north west] at (2*\X,2*\Y) {\number\numexpr(\x-1)*5+1};
 \else
  \node[anchor=south east] at (2*\X,2*\Y) {\number\numexpr(\x-1)*5+\Y+1};
 \fi
 }
}
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}

在此处输入图片描述

相关内容