3

I would like to have the sloped label long expression for both arrows on the diagonal of my tikz-picture to be parallel to the arrows' direction. By using a longer sloped argument for the Fourier transform, I get this undesidered output, see Fig. 1. The text crosses the arrow in a bad way. Furthermore, I would like both arrows to be distinguishable and spaced in my tikz-picture, like in Fig. 2 and not to overlap. This might be the source of the wrong output.

Here my MWE:

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[xscale=6.5,yscale=4.5]
  \def\is{2.0} % inner seperation of nodes  
  % NODES
  \node[inner sep=\is] (hh) at (0,1) {$h(t,\tau)$};
  \node[inner sep=\is] (SS) at (0,0) {$S(\nu,\tau)$};
  \node[inner sep=\is] (HH) at (1,1) {$H(t,f)$};
  \node[inner sep=\is] (BB) at (1,0) {$B(\nu,f)$};  
  % ARROWS
  \draw[-latex] (hh) -- (HH) node[fill=white,inner sep=3pt,midway, scale=0.9] {$\mathcal{F}$};
  \draw[-latex] (HH) -- (BB) node[fill=white,inner sep=3pt,midway, scale=0.9] {$\mathcal{F}$};
  \draw[-latex] (hh) -- (SS) node[fill=white,inner sep=3pt,midway, scale=0.9] {$\mathcal{F}$};
  \draw[-latex] (SS) -- (BB) node[fill=white,inner sep=3pt,midway, scale=0.9] {$\mathcal{F}$}; % Bad output starts below
  \draw[-latex] (SS) -- (HH) node[midway, sloped, above, scale=0.9] {$\mathcal{F}\{long-expression\}$};
  \draw[-latex] (HH) -- (SS) node[midway, sloped, below, scale=0.9] {$\mathcal{F}^{-1}\{long-expression\}$};  
\end{tikzpicture}
\end{document}

Wrong output (1): Bad output Desidered output (2): Desidered output

1
  • Sloped doesn't play nicely with transformations. You could only apply the transformation for placing the nodes and then just draw the arrows afterwards. But if you're only using it to scale the placement it would be better to use x=6.5cm, y=4.5cm. Or just use a matrix/tikz-cd with the appropriate settings depending on what you're after. Commented Jul 9, 2023 at 23:37

2 Answers 2

4

Edit:
IN first version of answer I overlooked that in diagonal of diagram should be two antiparallel vectors (as noted @Sebastian in his comment). Now this is corrected and both vectors are visible (separated).

With tikz:

\documentclass[tikz, margin=2mm]{standalone}
\usetikzlibrary{arrows.meta,
                positioning,
                quotes}

\begin{document}
    \begin{tikzpicture}[%xscale=6.5,yscale=4.5
    node distance = 45mm and 65mm,
every edge/.style = {draw, -Stealth},
every edge quotes/.style = {fill=white, inner sep=3pt, 
                            font=\footnotesize, sloped, anchor=center},
N/.style = {inner sep=\is pt}
                        ]
\def\is{2.0} % inner seperation of nodes
% NODES
\node (la) [N]              {$h(t,\tau)$};
\node (lb) [N, below=of la] {$S(\nu,\tau)$};
\node (ra) [N, right=of la] {$H(t,f)$};
\node (rb) [N, below=of ra] {$B(\nu,f)$};
% ARROWS
\draw   (la) edge["$\mathcal{F}$"] (ra)
        (lb) edge["$\mathcal{F}$"] (rb)
        (la) edge["$\mathcal{F}$" rotate=90] (lb)
        (ra) edge["$\mathcal{F}$" rotate=90] (rb)
        ([shift={(-1pt,1pt)}] lb.north east) edge["$\mathcal{F}\{long-expression\}$" above] ([shift={(-1pt,1pt)}] ra.south west)
        ([shift={(1pt,-1pt)}] ra.south west) edge["$\mathcal{F}\{long-expression\}$" below] ([shift={(1pt,-1pt)}] lb.north east)
        ;
    \end{tikzpicture}
\end{document}

(I change nodes names, that become more consistent: la for Left Above, etc.)

enter image description here

6
  • 1
    Very kind in the diagonal you need two vectors one going from bottom to top and the other from top to bottom as shown by the user in the second figure. +1
    – Sebastiano
    Commented Jul 9, 2023 at 20:24
  • @Sebastiano How do you suggest to set the two parallel vectors with the sloped labels?
    – Ian
    Commented Jul 9, 2023 at 21:11
  • @Zarko I can't compile your code. I only get an output by eliminating the edges' labels as follows: (la) enge (ra) but this doesn't solve my previous issue at all.
    – Ian
    Commented Jul 9, 2023 at 22:17
  • 1
    @Ian, showed image in answer I produced by compilation of the provided MWE. It works as it is. Tested in my MiKTeX installation as well in Overleaf. If you got errors or different result, than you change code in in proposed solution.
    – Zarko
    Commented Jul 10, 2023 at 1:18
  • 1
    @Sebastiano, oh, I overlooked, that in diagonal should be two vectors. Them is more easy to drawn in tikz.cd as in pure tikz .... corrected now. Thank you to point mi on this (I upvoted your nice answer too).
    – Zarko
    Commented Jul 10, 2023 at 1:33
4

I have not used tikz to draw the commutative diagrams but tikz-cd package. The result is very nice.

\documentclass[a4paper,12pt]{article}
\usepackage{tikz-cd}
\usepackage{amsmath,amssymb}

\begin{document}
\begin{tikzcd}[column sep=5cm,row sep=4cm]
h(t,\tau) \arrow[r,"\mathcal{F}" description] \arrow[d,"\mathcal{F}" description]& \arrow[dl,shift left=.35ex,"\mathcal{F}\{long-expression\}"{sloped, yshift = 5pt, xshift=1pt}] H(t,f) \arrow[d,"\mathcal{F}" description]\\
S(\nu,\tau) \arrow[r,"\mathcal{F}" description] \arrow[ru,shift left=.35ex,"\mathcal{F}^{-1}\{long-expression\}"{sloped, yshift = -20pt, xshift=1pt}] & B(\nu,f)
\end{tikzcd}
\end{document}

enter image description here

4
  • 1
    With pdfLaTeX as a compiler, I got an error message at \end{tikzcd} I already had the quotes library in my preamble as shown in this thread link
    – Ian
    Commented Jul 9, 2023 at 21:36
  • 1
    @Ian Do you use an updated version of your LaTeX distribution? I compiled it with a Papeeria editor with a 2019 pdfLaTeX engine. I have no problems with the compilation of the code that I have put.
    – Sebastiano
    Commented Jul 10, 2023 at 19:47
  • 1
    I'm using Overleaf and your code works fine! I exported the tikzcd as a pdf-file and imported it into my project. Some packages in my preamble might have caused trouble. I have accepted Zarko answer since he used most of my MWE.
    – Ian
    Commented Jul 10, 2023 at 20:38
  • @Ian No problem for the accepted Zarko answer :-)
    – Sebastiano
    Commented Jul 11, 2023 at 10:56

You must log in to answer this question.

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