[Tex/LaTex] Commutative diagrams side by side using tikz

diagramstikz-pgf

How can I put two commutative diagrams besides each other using the tikz package?

\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{dsfont}
\begin{document} 
\begin{tikzpicture}
  \matrix (m) [matrix of math nodes,row sep=0.8em,column sep=3em,minimum width=2em] {
 \quad & \mathcal{A}\otimes \mathcal{A} \\
 \mathcal{A} & \quad \\
 \quad & \mathcal{A}\otimes \mathcal{A} \\};
 \path[-stealth]
(m-2-1) edge node [above] {$\Delta$} (m-1-2)
(m-2-1) edge node [below] {$\Delta$} (m-3-2)
(m-1-2) edge node [right] {$\sigma$} (m-3-2);
\end{tikzpicture}

\begin{tikzpicture}
 \matrix (m) [matrix of math nodes,row sep=0.8em,column sep=3em,minimum width=2em] {
 \mathcal{A}\otimes \mathcal{A} & \quad \\
 \quad & \mathcal{A} \\
 \mathcal{A}\otimes \mathcal{A} & \quad \\};
  \path[-stealth]
(m-1-1) edge node [above] {$m$} (m-2-2)
(m-3-1) edge node [below] {$m$} (m-2-2)
(m-1-1) edge node [left] {$\sigma$} (m-3-1);
\end{tikzpicture}
\end{document}

Best Answer

You're leaving a blank line, so the second tikzpicture goes to a new line.

Remove it and you'll have what you want.

MWE

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{matrix}


\begin{document}
\begin{tikzpicture}
  \matrix (m) [matrix of math nodes,row sep=0.8em,column sep=3em,minimum width=2em] {
 \quad & \mathcal{A}\otimes \mathcal{A} \\
 \mathcal{A} & \quad \\
 \quad & \mathcal{A}\otimes \mathcal{A} \\};
 \path[-stealth]
(m-2-1) edge node [above] {$\Delta$} (m-1-2)
(m-2-1) edge node [below] {$\Delta$} (m-3-2)
(m-1-2) edge node [right] {$\sigma$} (m-3-2);
\end{tikzpicture}\qquad%
\begin{tikzpicture}
 \matrix (m) [matrix of math nodes,row sep=0.8em,column sep=3em,minimum width=2em] {
 \mathcal{A}\otimes \mathcal{A} & \quad \\
 \quad & \mathcal{A} \\
 \mathcal{A}\otimes \mathcal{A} & \quad \\};
  \path[-stealth]
(m-1-1) edge node [above] {$m$} (m-2-2)
(m-3-1) edge node [below] {$m$} (m-2-2)
(m-1-1) edge node [left] {$\sigma$} (m-3-1);
\end{tikzpicture}
\end{document} 

enter image description here


The same diagram can be easily done with tikz-cd, as well.

\documentclass{article}

\usepackage{tikz-cd}

\tikzcdset{
arrow style=tikz,
diagrams={>={Stealth[scale=0.9]}}
}

\begin{document}
 \[
  \begin{tikzcd}[row sep=0.8em,column sep=3em]
   & \mathcal{A}\otimes \mathcal{A} \arrow[dd,"\sigma"] & \mathcal{A}\otimes \mathcal{A} \arrow[dd,"\sigma"'] \arrow[dr,"m"] \\
   \mathcal{A} \arrow[ur,"\Delta"] \arrow[dr,"\Delta"'] & & & \mathcal{A} \\
   & \mathcal{A}\otimes \mathcal{A} & \mathcal{A}\otimes \mathcal{A} \arrow[ur,"m"'] \\
  \end{tikzcd}
 \]
\end{document} 

enter image description here