TikZ-cd図を並べて

Nov 09 2020

TikZ-cdで描かれた2つの図があり、それらを並べて表示したいと思います。ただし、2つの図のコードの間に空白行を残していなくても、それらは互いに上下に表示されます。

これが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}

どの出力:

また、ミニページ、サブフロート(2つの図を並べて表示するなど)、サブキャプションパッケージ(TikZ図面をミニページに並べて配置するなど)を使用して問題を解決しようとしましたが、いずれの場合も負荷がかかりますエラーの...(多分これらのパッケージはTikZと互換性がありますが、TikZ-cdとは互換性がありませんか?)あなたの助けに感謝します!

回答

2 Bernard Nov 09 2020 at 19:02

あなたがそれを持つことができfloatrowますが、交換可能ならば、&との\&

\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}