4

Is there a way to use a multiline environment in a cell of an \xymatrix?

I am trying to produce something that looks like this:

\[
\left\{ \begin{gathered}\text{text 1}\\
\text{text 2}\\
A=B
\end{gathered}
\right\} \rightleftarrows\left\{ \begin{gathered}\text{some text here}\\
\text{and here}
\end{gathered}
\right\} ,
\]

enter image description here,

Only I was hoping to get slightly longer curved arrows. I attempted to use \xymatrix but this causes two problems: (1) I get an error message when I try to include multiline environments (e.g. \gathered) in the cells, and (2) the arrow ends get positioned above/below the cell content, rather than to its side:

\[
\xymatrix{\left\{ \text{text}\right\} \ar@/^{1pc}/[r] & \ar@/^{1pc}/[l]\left\{ \text{more text}\right\} }
\]

enter image description here

Any suggestions? Thanks!

  • What if you try the Bmatrix environment in the place of gathered? Also did you really put gathered within \[ \]? – Bernard May 28 '18 at 8:56
4

The trick is to brace the complex objects:

\documentclass{article}
\usepackage{amsmath}
\usepackage[all,cmtip]{xy}

\begin{document}

\[
\xymatrix{
  {\begin{Bmatrix}\text{text a}\\\text{text b}\end{Bmatrix}}
  \ar@/^{1pc}/[r] &
  {\begin{Bmatrix}\text{text a}\\\text{text b}\\\text{text c}\end{Bmatrix}}
  \ar@/^{1pc}/[l]
}
\]

\end{document}

enter image description here

3

Coherently with the tag assigned by the user I propose two alternatives; the first with xy package and the second with tikz-cd.

FIRST OPTION:

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools}
\usepackage[all]{xy}
\begin{document}

\xymatrix@C=3pc{{\left\{\begin{aligned}
\text{text a}\\
\text{text b}
\end{aligned}\right\}
} \ar@/^{1.5pc}/[r] & \ar@/^{1.5pc}/[l]{\left\{\begin{aligned}
\text{text a}\\
\text{text b}\\
\text{text c}\\
\end{aligned}\right\}
}}
\end{document}

SECOND OPTION: Is there also a chance to get the same result using the package tikz-cd

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{tikz-cd}
\usepackage{amsmath}
\begin{document}
\begin{tikzcd}
\left\{\begin{array}{lr} \text{text a} \\    \text{text b} \\     \end{array}\right\}   \arrow[r, bend left=15] & \left\{\begin{array}{lr} \text{text a} \\    \text{text b} \\    \text{text c} \\ \end{array}\right\} \arrow[l, bend left=15]
\end{tikzcd}
\end{document}
2

Remake of the second example in the @Sebastiano answer:

\documentclass[a4paper,12pt]{article}
\usepackage{tikz-cd}

\begin{document}
{\setlength\tabcolsep{0pt}
 \renewcommand\arraystretch{0.84}
\begin{tikzcd}[bend angle=20]
\left\{\begin{tabular}{lr} 
        text a\\ text b
       \end{tabular}\right\}    \arrow[r, bend left] 
       &    \left\{\begin{tabular}{lr}
                text a\\ text b\\ text c
            \end{tabular}\right\}   \arrow[l, bend left]
\end{tikzcd}
}
\end{document}

enter image description here

  • Great dear friend :-). Best nice answer. – Sebastiano May 29 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.