0

This question already has an answer here:

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.

marked as duplicate by user156344, Community Mar 5 at 12:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    You can't use figure inside minipage. What should it be for? – egreg Mar 5 at 11:20
  • Try subfigure. – user156344 Mar 5 at 11:20
  • Related: tex.stackexchange.com/q/5769/156344 – user156344 Mar 5 at 11:22
  • @egreg how does one get a caption without? – Polly Mar 5 at 11:56
  • @JouleV thanks! I didn't come across this... – Polly Mar 5 at 11:58
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

Not the answer you're looking for? Browse other questions tagged or ask your own question.