# rotate wide commutative diagram tikzcd

I have a very large commutative diagram that is too big for the margins. I have shortened the names of the objects as much as possible. I have tried using the option [cramped] and setting the column sep to be smaller. It's just too big. Is there a way to rotate the entire diagram 90 degrees?


\documentclass{article}

\usepackage{tikz-cd}

\begin{document}

$\begin{tikzcd} ObjectWithLongName \arrow[r] & ObjectWithLongName \arrow[r] & ObjectWithLongName \arrow[r] & ObjectWithLongName \\ \end{tikzcd}$

\end{document}



You put the diagram in a \rotatebox. Because the catcode of & will be fixed when passed as an argument, you have to use ampersand replacement. Otherwise you will get uninformative errors like

! Undefined control sequence.
<argument> \pgf@matrix@last@nextcell@options

\documentclass{article}

\usepackage{tikz-cd}

\begin{document}

$\rotatebox{90}{% \begin{tikzcd}[ampersand replacement=\&] ObjectWithLongName \arrow[r] \& ObjectWithLongName \arrow[r] \& ObjectWithLongName \arrow[r] \& ObjectWithLongName \\ \end{tikzcd} }$

\end{document}


You can always change

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
ObjectWithLongName \arrow[r]
& ObjectWithLongName \arrow[r]
& ObjectWithLongName \arrow[r]
& ObjectWithLongName
\end{tikzcd}
\end{document}


which can't fit the page margin

to

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
ObjectWithLongName \arrow[d]\\
ObjectWithLongName \arrow[d]\\
ObjectWithLongName \arrow[d]\\
ObjectWithLongName
\end{tikzcd}
\end{document}


The latter code above will produce