2

As you can see in the following example, there is too much empty space between the text and the diagram when I use an arrow with bend left=100, looseness=2.

How can I avoid it?

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{mwe}
\begin{document}
\blindtext As you can see, there is too much empty space here:
\[
\begin{tikzcd}
D\ar[r]\ar[dr, bend left=100, 
    looseness=2]&U\ar[dl]\\
C\ar[r] & K
\end{tikzcd}    
\]
\blindtext
\[
\begin{tikzcd}
D\ar[r]&U\ar[dl]\\
C\ar[r] & K
\end{tikzcd}    
\]
\blindtext
\end{document}

enter image description here

egreg
  • 1,121,712
CarLaTeX
  • 62,716
  • 1
    The control points that TikZ considers part of the bounding box are too far outside. I think there was some code for tight bounding boxes somewhere. – Skillmon Feb 05 '22 at 09:28
  • @Skillmon Maybe \useasboundingbox... – CarLaTeX Feb 05 '22 at 09:35
  • 1
    You could use \useasboundingbox (I have no idea how in tikz-cd as I don't use it), that would be a manual approach to fix this. – Skillmon Feb 05 '22 at 09:37
  • 2
    See https://ctan.org/pkg/tikz-bbox?lang=en. It may help you. – Zarko Feb 05 '22 at 09:49
  • @CarLaTeX, done. – Zarko Feb 05 '22 at 11:39
  • @CarLaTeX you're right. It would be nice if Zarko could add this answer to the other question --- that would be easier for people searching for similar problems – Rmano Feb 05 '22 at 22:21
  • @Rmano, which questions do you mean? The one to which this question is duplicate? It is already answered by marmot (using one of his alias names), so I’m not sure if it’s wise to add there another answer based on his code. I need to rethinking about how to wording the answer, if I will do this. – Zarko Feb 06 '22 at 03:57

1 Answers1

5

Once upon a time @marmot also know as @Schrödinger's cat wrote the interesting TikZ library bbox which solves most problems similar to yours. The library is no longer part of the TikZ bundle (consult marmotghost), but it is available on CTAN nonetheless.

Loading it you can write:

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{bbox}

\usepackage{mwe} \begin{document}

\blindtext As you can see, there is too much empty space here: [ \begin{tikzcd}[bezier bounding box] D\ar[r]\ar[dr, bend left=100, looseness=2]&U\ar[dl]\ C\ar[r] & K \end{tikzcd} ] \blindtext \end{document}

and obtain the following result:

enter image description here

Sebastiano
  • 54,118
Zarko
  • 296,517