0

In overleaf with the code below I got the following figure:

enter image description here

\documentclass[]{beamer} %works also for article

\usepackage[utf8]{inputenc} \usepackage{tikz} \usetikzlibrary{matrix,arrows,decorations.pathmorphing} \begin{document}

% units \newcommand{\myunit}{1 cm} \tikzset{ node style sp/.style={draw,circle,minimum size=\myunit}, node style ge/.style={circle,minimum size=\myunit}, arrow style mul/.style={draw,sloped,midway,fill=white}, arrow style plus/.style={midway,sloped,fill=white}, }

\begin{tikzpicture}[>=latex] % matrices \matrix (A) [matrix of math nodes, nodes = {node style ge}, left delimiter = (, right delimiter = )] at (0,0) { |[node style sp]| a_{11} & |[node style sp]| a_{12} &|[node style sp]| a_{13} \ a_{21} & a_{22} & a_{23} \ }; \node [draw,below=10pt] at (A.south) { $A: 2\times 3$};

\matrix (B) [matrix of math nodes, nodes = {node style ge}, left delimiter = (, right delimiter = )] at (4\myunit,4\myunit) { |[node style sp]| d_{11} & d_{12} \ |[node style sp]| d_{21} & d_{22} \ |[node style sp]| d_{31} & d_{32} \ }; \node [draw,right=50pt] at (B.south) { $D: 3\times 2$}; % matrix result \matrix (C) [matrix of math nodes, nodes = {node style ge}, left delimiter = (, right delimiter = )] at (4*\myunit,0) { |[node style sp,red]| c_{11} & c_{12} \ c_{21} & c_{22} \ }; \node [draw,below=10pt] at (C.south) { $C = AD: 2\times 2$}; % arrow \draw[blue] (A-2-1.north) -- (C-2-1.north); \draw[blue] (A-1-1.north) -- (C-1-1.north); \draw[blue] (B-1-2.west) -- (C-1-1.east); \draw[blue] (B-1-1.west) -- (C-1-1.west); \draw<->,red to[in=180,out=90] node[arrow style mul] (x) {$a_{11}\times d_{11}$} (B-1-1); \draw<->,red to[in=180,out=90] node[arrow style mul] (y) {$a_{12}\times d_{21}$} (B-2-1); \draw<->,red to[in=180,out=90] node[arrow style mul] (z) {$a_{13}\times d_{31}$} (B-3-1); \draw[red,->] (x) to node[arrow style plus] {$+$} (y);% \draw[red,->] (y) to node[arrow style plus] {$+$} (z)% to (C-1-1.north west);

\end{tikzpicture}

\end{document}

However, when I copied the same code in a beamer document class I got overlapped matrix elements. I am trying to figure out what is wrong but I am unable to find what I'm missing and I got the following picture:

enter image description here

Could there be any conflict with any other package/s?

José
  • 687
  • 1
    Basically https://tex.stackexchange.com/questions/15093/single-ampersand-used-with-wrong-catcode-error-using-tikz-matrix-in-beamer?noredirect=1&lq=1 I suppose – Torbjørn T. Jan 30 '24 at 21:18
  • 1
    I don't get overlap with your code. Did you compile often enough? Or is your code really inside of a frame? If yes, than it's a duplicate of the ampersand question. – samcarter_is_at_topanswers.xyz Jan 30 '24 at 21:20
  • 1
    Given that your image shows a frametitle, I suppose your code does not reproduce your problem... The code as it is in your question would give https://i.stack.imgur.com/nbnmc.png – samcarter_is_at_topanswers.xyz Jan 30 '24 at 21:24
  • It worked with ampersand question and changing the & by adding \&. Thnks! – José Jan 31 '24 at 08:14

0 Answers0