2

I have two diagrams – drawn in TikZ-cd – which I'd like to have side-by-side. However, even though I haven't left a blank line between the code for the two diagrams, they still appear above/below one another.

Here's a MWE:

\documentclass[12pt]{article}

\usepackage[margin=20mm]{geometry} %changes margins \usepackage{mathrsfs} % fancy maths latters \usepackage{amsmath} %improves equation environment

\usepackage{tikz-cd} %diagrams

\usepackage{subcaption} %side by side diagrams \usepackage{caption} %customises captions

\title{Side-by-Side Diagrams MWE}

\begin{document}

\maketitle

Here are two diagrams that I would like to have side-by-side:

\begin{figure}[h!] \centering \begin{tikzcd}[column sep=small] \mathscr{L}{1} & & \mathscr{L}{2}\ & p_{1} \arrow[lu] \arrow[ru] &\ & \text{Argument} \arrow[u] &\ \end{tikzcd} \caption{Many-one pluralism.} \begin{tikzcd}[column sep=small] \mathscr{L}{1} & & \mathscr{L}{2}\ p_{1} \arrow[u] & & p_{2} \arrow[u]\ & \text{Argument} \arrow[lu] \arrow[ru] &\ \end{tikzcd} \caption{One-many pluralism.} \end{figure}

\end{document}

Which outputs:

enter image description here

I've also tried using mini-pages, sub-floats (e.g. Two diagrams side by side), and the subcaption package (e.g. Placing TikZ drawings in a minipage side by side) to solve the problem, but in each case I get loads of errors... (Maybe these packages are compatible with TikZ but not TikZ-cd?) Thanks for your help!

1 Answers1

3

You can have it with floatrow, if you enable the replacement of & with \&:

\documentclass[12pt]{article}

\usepackage[margin=20mm]{geometry} %changes margins \usepackage{mathrsfs} % fancy maths latters \usepackage{amsmath} %improves equation environment \usepackage{tikz-cd} %diagrams

\usepackage{subcaption} %side by side diagrams \usepackage{caption} %customises captions \usepackage{floatrow} \title{Side-by-Side Diagrams MWE} \author{I. Ego} \begin{document}

\maketitle

Here are two diagrams that I would like to have side-by-side:

\begin{figure}[h!] \tikzset{column sep=small, ampersand replacement=&} \begin{floatrow} \centering \ffigbox{\begin{tikzcd} \mathscr{L}{1} & & \mathscr{L}{2}\ & p_{1} \arrow[lu] \arrow[ru] &\ & \text{Argument} \arrow[u] &\ \end{tikzcd}}{\caption{Many-one pluralism.}} \ffigbox{\begin{tikzcd} \mathscr{L}{1}& & \mathscr{L}{2}\ p_{1} \arrow[u] & & p_{2} \arrow[u]\ & \text{Argument} \arrow[lu] \arrow[ru] &\ \end{tikzcd}}{\caption{One-many pluralism.}} \end{floatrow} \end{figure}

\end{document}

enter image description here

Bernard
  • 271,350