Standard align space with CD environment from amscd package

by Onner Irotsab   Last Updated January 16, 2018 16:23 PM

I have the following code:

\begin{align}
foo &=\mydiagram{\text{width width}}       & bar &= \mydiagram{\text{width width width}}
\\[\jot]
foo &=\mydiagram{\text{width width width}} & bar &= \mydiagram{\text{width}}
\end{align}

where \mydiagram{} is a diagram composed with the CD environment from amscd package and it's defined as follows:

\def\mydiagram#1{%
    \begin{CD}
        S^{{\mathcal{W}}_\Lambda}\otimes T
        @>j>>
        T\\
        @V{#1}VV
        @VV{\End P}V\\
        (S\otimes T)/I
        @=
        (Z\otimes T)/J
    \end{CD}%
}

It follows my output:

enter image description here

I have used align environment because it calculates correct spaces between columns by himself, but not in this case. How can I fix spaces in order to have standard align environment behaviour?

MWE

\documentclass[a4paper,11pt]{article}

\usepackage{amsmath}
\usepackage{amscd}

\DeclareMathOperator{\End}{End}

\def\mydiagram#1{%
    \begin{CD}
        S^{{\mathcal{W}}_\Lambda}\otimes T
        @>j>>
        T\\
        @V{#1}VV
        @VV{\End P}V\\
        (S\otimes T)/I
        @=
        (Z\otimes T)/J
    \end{CD}%
}

\begin{document}

\begin{align*}
foo &=\mydiagram{\text{width width}}       & bar &= \mydiagram{\text{width width width}}
\\[\jot]
foo &=\mydiagram{\text{width width width}} & bar &= \mydiagram{\text{width}}
\end{align*}

\end{document}


Answers 1


Putting an \fbox around the CD environment reveals that the label sticks out the bounding box. Therefore add space to your \diagram macro to accommodate the label

Sample output

\documentclass[a4paper,11pt]{article}

\usepackage{amsmath}
\usepackage{amscd}
\usepackage{geometry}

\DeclareMathOperator{\End}{End}

\def\mydiagram#1{%
\hphantom{\scriptstyle #1}\mkern-28mu\begin{CD}
  S^{{\mathcal{W}}_\Lambda}\otimes T
  @>j>>
  T\\
  @V{#1}VV
  @VV{\End P}V\\
  (S\otimes T)/I
  @=
  (Z\otimes T)/J
\end{CD}%
}

\begin{document}

\begin{align*}
foo &=\mydiagram{\text{width width}}       & bar &= \mydiagram{\text{width width width}}
\\[\jot]
foo &=\mydiagram{\text{width width width}} & bar &= \mydiagram{\text{width}}
\end{align*}

\end{document}

Of course the result is too wide for the page, so you should not put too many of these on one line.

Andrew Swann
Andrew Swann
January 16, 2018 16:01 PM

Related Questions


picture align do not working :(

Updated November 20, 2017 07:23 AM

How to align picture to top left corner?

Updated May 27, 2015 00:10 AM


xy diagram: set height of a specific row

Updated March 20, 2017 21:23 PM

Typesetting small inline commutative triangles

Updated October 19, 2017 17:23 PM