0

My goal is to have two commutative diagrams beside each other (but together centered) and with two captions.

I tried the following code:

\documentclass[twoside,12pt]{scrartcl}
\usepackage{amsmath}  
\usepackage{amssymb}
\usepackage{enumerate}
\usepackage[utf8]{inputenc}
\usepackage[thmmarks,amsmath,noconfig,amsthm]{ntheorem}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{cd}

\geometry{tmargin=30mm,bmargin=40mm,lmargin=30mm,rmargin=30mm}
\setlength{\headsep}{15mm}

\begin{document}

\begin{minipage}[t]{0.5\textwidth}
\begin{figure}
\begin{tikzcd} 
A \rar["B"] \dar["C"'] \& A \otimes B  \\
A \rar["\mathrm{id}"'] \& B \arrow[u, "\phi"']
\end{tikzcd}
\caption{} \label{fig: MonFun2}
\end{figure}
\end{minipage}

\begin{minipage}[t]{0.5\textwidth}
\begin{figure}
\begin{tikzcd}
A \rar["B"] \dar["C"'] \& A \otimes B  \\
A \rar["\mathrm{id}"'] \& B \arrow[u, "\phi"']
\end{tikzcd}
\caption{} \label{fig: MonFun3}
\end{figure}
\end{minipage}

\end{document}

(where I already change "&" to "\&" as it said somewhere). This gives me several errors:

  • ! LaTeX Error: Not in outer par mode.
  • ! Undefined control sequence. @xfloat ...@fltovf \fi \global \setbox @currbox
  • ! Missing number, treated as zero.
  • ! Package pgf Error: No shape named tikz@f@1-1-2 is known.

The last error occurs several times. Can someone maybe help me?

Thanks in advance!

P.S. My minimal example is not the shortest possible, but I wanted to include packages as geometry as I was not sure if that has any influence.

Polly
  • 123

1 Answers1

0

Loading the floatrow package seems to solve the problem:

\documentclass[twoside,12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{enumerate}
\usepackage{geometry}
\geometry{tmargin=30mm,bmargin=40mm,hmargin=30mm, headsep=15mm, showframe}

\usepackage[thmmarks,amsmath,noconfig,amsthm]{ntheorem}
\usepackage{tikz-cd}
\usepackage{caption, floatrow}

\begin{document}

\hfill
\begin{minipage}[t]{0.4\textwidth}
\centering
\begin{figure}[H]
\begin{tikzcd}[ampersand replacement=\&]
A \rar["B"] \dar["C"'] \& A \otimes B \\
A \rar["\mathrm{id}"'] \& B \arrow[u, "\phi"']
\end{tikzcd}
\caption{} \label{fig: MonFun2}
\end{figure}
\end{minipage}
\begin{minipage}[t]{0.4\textwidth}
\centering
\begin{figure}[H]
\begin{tikzcd}[ampersand replacement=\&]
A \rar["B"] \dar["C"'] \& A \otimes B \\
A \rar["\mathrm{id}"'] \& B \arrow[u, "\phi"']
\end{tikzcd}
\caption{} \label{fig: MonFun3}
\end{figure}
\end{minipage}
\hfill\null

\end{document} 

enter image description here

Bernard
  • 271,350