我有兩張用 TikZ-cd 繪製的圖表,我想將它們並排放置。然而,即使我沒有在兩個圖的程式碼之間留下空行,它們仍然出現在彼此的上方/下方。
這是一個 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}
哪個輸出:
我也嘗試過使用迷你頁面、子浮動(例如兩張圖並排),以及子標題包(例如將 TikZ 繪圖並排放置在小頁面中)來解決問題,但在每種情況下我都會遇到很多錯誤...(也許這些包與 TikZ 兼容但不與 TikZ-cd 兼容?)感謝您的幫助!
答案1
如果您啟用withfloatrow
的替換,則可以使用它 :&
\&
\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}