我有两张用 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}
输出:
我也尝试过使用迷你页面、子浮动(例如两张并排的图表)以及 subcaption 包(例如将 TikZ 绘图并排放置在小页面中) 来解决问题,但在每种情况下我都会收到大量错误......(也许这些包与 TikZ 兼容但与 TikZ-cd 不兼容?)谢谢你的帮助!
答案1
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}