1

I'm trying to fix some hbox errors in the following commutative diagram. Note the symbol strings are simplified here, but what is written is the actual length:

\documentclass{amsart}
\usepackage{tikz-cd}
\begin{document}
\begin{eqnarray*}
\begin{tikzcd}
BAAAAAAAAAAAAAAAAAAAAAAAAAAAA \ar{r} \ar{rd}  & CAAAAAAAAAAAAAAAAAAAAAAAAAAAA   \\
AAAAAAAAAAAAAAAAAAAAAAAAAAAAA  \ar{u}  \ar{r}  &DAAAAAAAAAAAAAAAAAAAAAAAAAAAA \ar{u}
\end{tikzcd}
\end{eqnarray*}
\end{document}

This gives hbox errors (140p or so) and I'm trying to fix it. My first attempt was the following:

\documentclass{amsart}
\usepackage{tikz-cd}
\begin{document}
\begin{eqnarray*}
\begin{tikzcd}
AAAAAAAAAAAAAAAAAAAAAAAAAAAAA  \ar{d} 
\\
BAAAAAAAAAAAAAAAAAAAAAAAAAAAA  \ar{d}  \arrow[bend left=60]{dd} \\
CAAAAAAAAAAAAAAAAAAAAAAAAAAAA  \\
DAAAAAAAAAAAAAAAAAAAAAAAAAAAA  \ar{u}
\end{tikzcd}
\end{eqnarray*}
\end{document}

Here the curved arrow goes through another entry and I'm not sure how to fix that. But there might be a better suggestion anyway. (I don't really want to define four new symbols for the four entries.)

2
  • Please extend your code fragment to complete small document with your commutative diagram. We need to know your page layout.
    – Zarko
    Nov 1 '21 at 3:50
  • 1
    firstly don't use eqnarray but you are asking how to make something fit without any indication of how big it is or how big is the area that you want to fit it in to. Please always make examples complete documents that allow people to see the problem and test answers. Nov 1 '21 at 8:13
1

One of possible ways is break your long expressions into two line. For example by use of multlined math environment defined in the mathtools package:

\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz-cd}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\[
\begin{tikzcd}[sep=large]
\begin{multlined}
    BAAAAAAAAAAAAA \\
    AAAAAAAAAAAAAAA
\end{multlined} \ar{r} \ar{rd} & \begin{multlined}
                                    BAAAAAAAAAAAAA \\
                                    AAAAAAAAAAAAAAA
                                \end{multlined}   \\
\begin{multlined}
    AAAAAAAAAAAAAA \\
    AAAAAAAAAAAAAAA
\end{multlined} \ar{u} \ar{r}  & \begin{multlined}
                                    BAAAAAAAAAAAAA \\
                                    AAAAAAAAAAAAAAA
                                \end{multlined} \ar{u}
\end{tikzcd}
\]
\end{document}

enter image description here

(red lines shows text borders)

Of course, you can use other amsmath environments as are aligned, gathered, split, ...

Addendum (1): Remarks/response to your comment:

Sorry, but we haven't any information about real content of your diagram. However, from my (poor) knowledge of math (it is only my every day tool), any math expression can be broken into two line. If this is not a option for you, than you have the following options:

  • use smaller font,
  • locally enlarge text width,
  • rotate diagram to landscape orientation.

Anyway, I would stick with suggested solution.

Addendum (2): A example of ugly diagram without split math expression:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                positioning}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\[
\begin{tikzpicture}[
node distance = 8mm and 1mm,
every edge/.style = {draw, -{Straight Barb[scale=0.8]}, semithick}
                    ]
\node (a) {AAAAAAAAAAAAAAAAAAAAAAAAAAAAA};
\node (b) [below right=of a.south] {BBBBBBBBBBBBBBBBBBBBBBBBBBBBB};
\node (c) [below left=of b.south]{CCCCCCCCCCCCCCCCCCCCCCCCCCCCC};
\node (d) [below right=of c.south] {DDDDDDDDDDDDDDDDDDDDDDDDDDDDD};
%
\path   (a) edge    (b)
        (a) edge[out=0, in=15, looseness=3.4]     (d)
        (c) edge[bend left]     (a)
        (c) edge    (d)
        (d) edge[bend right]    (b);
 \end{tikzpicture}
\]
\end{document}

enter image description here

3
  • A good idea, but unfortunately the mathematical expressions can not be broken up in that way without mangling them. I was thinking about trying to make the commutative diagram more of a rhombus, but then I was imagining running into problems with arrows intersecting as they do in the second example.
    – user255678
    Nov 1 '21 at 12:37
  • @user255678, see addendum.
    – Zarko
    Nov 1 '21 at 13:14
  • Thanks --- I modified the second so that the BBB was above the AA and the DDD was above the CCC and then the long curly arrow could fit inside and go diagonally, and indeed all arrows are now straight and I think it looks ok!
    – user255678
    Nov 2 '21 at 3:06

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.