Sơ đồ TikZ-cd Song song

Nov 09 2020

Tôi có hai sơ đồ - được vẽ bằng TikZ-cd - mà tôi muốn đặt cạnh nhau. Tuy nhiên, ngay cả khi tôi không để lại dòng trống giữa mã cho hai sơ đồ, chúng vẫn xuất hiện trên / dưới nhau.

Đây là một 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}

Kết quả đầu ra:

Tôi cũng đã thử sử dụng mini-page, sub-float (ví dụ: Hai sơ đồ cạnh nhau ) và gói mã phụ (ví dụ: Đặt các bản vẽ TikZ trong một minipage cạnh nhau ) để giải quyết vấn đề, nhưng trong mỗi trường hợp, tôi nhận được tải lỗi ... (Có thể các gói này tương thích với TikZ nhưng không tương thích với TikZ-cd?) Cảm ơn sự giúp đỡ của bạn!

Trả lời

2 Bernard Nov 09 2020 at 19:02

Bạn có thể có nó với floatrow, nếu bạn cho phép thay thế &bằng \&:

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