2

I'm trying to make a diagram of diagrams, and so have ended up with something like this diamond shape

\documentclass[a4paper,11pt]{book}%
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{cd}

\begin{document}
    \begin{tikzcd}
        & \mbox{something very long} \arrow[dr] \arrow[dl]&\\
        \mbox{something long} \arrow[dr] && \mbox{something long} \arrow[dl]\\
        & \mbox{something very long}&
    \end{tikzcd}
\end{document}

but (as tikzcd is initially intended for) the middle column of the middle row leaves a large blank space. In my document this is causing issues with flowing over the side margins. By (very) long I'm working with diagrams that fit on a line, so in the sense of width of more than a third of a page but height of one line (so wide but short, so that the empty space feels unnecessarily wide while still being short height-wise) diamond diagram

I'm wondering if there's a way of getting rid of this ghost middle column in tikz, for instance if I can have a 2 column system where I merge the top and bottom rows into a single column

3
  • 1
    Please give us some more details (Edited into your qeustion) about the amount of "very long" content. E.g. can it be half a book? Or are that images? Whatever you do, with A4 paper you'll quickly run out of space, no matter which package you use ... Thank you
    – MS-SPO
    Mar 18 at 18:55
  • 4
    If the 'outer' diagram is indeed as simple as this then you can also make it in TikZ itself, then you have more control over the placement of the nodes which makes it easy to put the left and right nodes more in the center.
    – Marijn
    Mar 18 at 19:40
  • 1
    @MS-SPO I've edited the question to clarify for posterity - the provided answers are more than enough. I meant long in the sense of wide but with short height. It's true that it would be a very different question for things that were taller, thanks.
    – George
    Mar 19 at 19:14

3 Answers 3

3

There is no need to use TikZ directly.
If you like to have your columns closer, just set an appropriate column separator (column sep), it could be also negative.

There is also no need to use \mbox, since you loaded amsmath, you can use \text.

\documentclass[a4paper,11pt]{book}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{cd}

\begin{document}
\[
    \begin{tikzcd}[column sep=-1.5cm]
        & \text{something very long} \arrow[dr] \arrow[dl]&\\
        \text{something long} \arrow[dr] && \text{something long} \arrow[dl]\\
        & \text{something very long}&
    \end{tikzcd}
\]
\end{document}

enter image description here

4
  • Thanks! I used \mbox mostly to get a MWE, in my file they're diagrams that fit on a line
    – George
    Mar 19 at 19:22
  • You might consider \begin{tikzcd}[column sep={2cm,between origins}] instead of using negative column sep. That way diagrams with different text will have the same shape.
    – Sandy G
    Mar 19 at 19:24
  • @SandyG You could add another answer and explain that.
    – CarLaTeX
    Mar 19 at 21:25
  • @George You're welcome! Thank you for accepting my answer.
    – CarLaTeX
    Mar 19 at 21:26
3

Similar to @CarLaTeX's answer, but using column sep={2cm,between origins} instead of column sep=-1.5cm. That way the spacing between cells is set by their centers. Then diagrams with different length cells will have arrows in the same shape, and the arrows will remain symmetric even if the cell contents aren't.

enter image description here

\documentclass[a4paper,11pt]{book}
\usepackage{amsmath}
\usepackage{tikz-cd}

\begin{document}
\[
    \begin{tikzcd}[column sep={2cm,between origins}]
        & \textup{something very long} \arrow[dr] \arrow[dl]&\\
        \textup{something} \arrow[dr] && \textup{something long} \arrow[dl]\\
        & \textup{something very long}&
    \end{tikzcd}
    \hspace{2cm}
    \begin{tikzcd}[column sep={2cm,between origins}]
        & \textup{something very long} \arrow[dr] \arrow[dl]&\\
        \textup{something very long} \arrow[dr] && \textup{something long} \arrow[dl]\\
        & \textup{something very long}&
    \end{tikzcd}
\]
\end{document}
2

Not sure it's more "diamondy" but my trial in cd :

enter image description here

You seem better off with a simple TikZ as mentionned in comment.

enter image description here

\documentclass[a4paper,11pt]{book}
\usepackage{amsmath}
 \usepackage{tikz}
 \usetikzlibrary{cd}
            
\begin{document}
\begin{tikzcd}[column sep=small]
    & \mbox{something very long} \arrow[ddr] \arrow[ddl] & \\
    \\
    \mbox{something long} \arrow[dr] & & \mbox{something long} \arrow[dl] \\
    & \mbox{something very long} & 
\end{tikzcd}
        
        
\begin{tikzpicture}[node distance=2cm]
    % Nodes
    \node (top) at (0,0) {something very long};
    \node (left) at (-2,-1.5) {something long};
    \node (right) at (2,-1.5) {something long};
    \node (bottom) at (0,-3) {something very long};
                    
    % Arrows
    \draw[->] (top) -- (left);
    \draw[->] (top) -- (right);
    \draw[->] (left) -- (bottom);
    \draw[->] (right) -- (bottom);
\end{tikzpicture}
    
\end{document}
1
  • 2
    There is no need to use TikZ directly, see my answer.
    – CarLaTeX
    Mar 19 at 6:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .