
何らかの理由で、おそらく私のドキュメント内の他の部分を壊さずに修正するには作業量が多すぎるでしょうが、Tikzcd は、マニュアルによると「ラベルの引用符構文が登場する前に使用されていた」「矢印の代替構文」との互換モードでのみ私のドキュメント内で動作します。
つまり、次のようなコードになります:
\arrow[r, Rightarrow, "\phi"]
私の文書では機能しません。次のように記述する必要があります。
\arrow[Rightarrow]{r}{\phi}
意図した結果を得るため。
では、次のような式はどのように記述すればよいでしょうか[from=A,to=B]
:
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
A \arrow[r, bend left=50, ""{name=U, below, draw=red}]
\arrow[r, bend right=50, ""{name=D, draw=red}]
& B
\arrow[Rightarrow, from=U, to=D]
\end{tikzcd}
\end{document}
具体的には、次の表現が機能するようにしました。
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
\mathcal{C}
\ar[bend left=47, pos=0.5]{r}{F}
\ar[bend right=47, pos=0.5]{r}[swap]{G}
\arrow[phantom,bend left=40, shift right=0.2ex, name=U]{r}
\arrow[phantom,bend right=38.4, shift left=0.2ex, swap, name=D]{r}
& \mathcal{D}
\arrow[Rightarrow]{from=U,to=D}{N}
\end{tikzcd}
\end{document}
しかし、上の矢印の中央から下の矢印の中央に向かって下向きに進むはずの最後の矢印はエラーになり、わずかに上向きに傾いた左向きの矢印として誤って表示されます。つまり、私が得る結果は次のようになります。
次のようなものを希望する場合:
もちろん他の名前も表示されます。
答え1
によるtikz-cd
マニュアル、関連するセル内の オプションを介して割り当てることができるノード名を使用する以外に(以下の 2 番目の例を参照)、およびオプションを使用するときに矢印の開始と終了を示すalias
構文を使用することもできます(以下の最初の例を参照)。ただし、これらのオプションはオプションの引数内に配置する必要があります。または を使用して矢印をさらにシフトすることもできます。<row number>-<column number>
from
to
xshift
yshift
\documentclass[border=10pt, tikz]{standalone}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
\mathcal{C}
\arrow[bend left=47, pos=0.5]{r}{F}
\arrow[bend right=47, pos=0.5]{r}[swap]{G}
& \mathcal{D}
\arrow[Rightarrow, from=1-2, to=1-1, yshift=0.5pt]{}{N}
\end{tikzcd}
\end{document}
\documentclass[border=10pt, tikz]{standalone}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
|[alias=R]| \mathcal{C}
\arrow[bend left=47, pos=0.5]{r}{F}
\arrow[bend right=47, pos=0.5]{r}[swap]{G}
& |[alias=L]| \mathcal{D}
\arrow[Rightarrow, from=L, to=R, yshift=0.5pt]{}{N}
\end{tikzcd}
\end{document}
どちらのコード スニペットも出力は同じになります。
下向き矢印を追加するのは簡単ではありません。矢印の始点と終点を表す 2 つの座標は、上記の方法で選択できるセルではないからです。ただし、次の例のように、マトリックスを少し拡張することはできます。
\documentclass[border=10pt, tikz]{standalone}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
& {} & \\
\mathcal{O}(X)^{op}
\arrow[bend left=47, pos=0.5]{rr}{\Lambda A}
\arrow[bend right=47, pos=0.5]{rr}[swap]{\Lambda A'}
& & \textbf{Set} \\
& {} &
\arrow[Rightarrow, from=1-2, to=3-2,
shorten >=5pt, shorten <=5pt, xshift=-3.5pt]
{}{\Lambda f}
\end{tikzcd}
\end{document}
start anchor
あるいは、およびオプションを使用することもできますend anchor
が、なぜか下の曲がった矢印のラベルが小さいサイズでは間違って配置されます。
\documentclass[border=10pt, tikz]{standalone}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
|[alias=R]| \mathcal{O}(X)^{op}
\arrow[bend left=47, pos=0.5]{r}{\Lambda A}
\arrow[bend right=47, pos=0.5]{r}[swap]{\Lambda A'}
& |[alias=L]| \textbf{Set}
\arrow[Rightarrow, from=L, to=L,
start anchor={[xshift=-1cm]north}, end anchor={[xshift=-1cm]south}]
{}{\Lambda f}
\end{tikzcd}
\end{document}
ラベルの位置は、\strut
各セルに を追加して均等な大きさにすることで固定できます。
\documentclass[border=10pt, tikz]{standalone}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
|[alias=R]| \mathcal{O}(X)^{op}\strut
\arrow[bend left=47, pos=0.5]{r}{\Lambda A}
\arrow[bend right=47, pos=0.5]{r}[swap]{\Lambda A'}
& |[alias=L]| \textbf{Set}\strut
\arrow[Rightarrow, from=L, to=L,
start anchor={[xshift=-1cm]north}, end anchor={[xshift=-1cm]south}]
{}{\Lambda f}
\end{tikzcd}
\end{document}
答え2
次のことが可能な別のルートを提案します:
tikz-cd
最新バージョンに対応していないドキュメントで作業する- 最新
tikz-cd
バージョンを使用している間
このアプローチは、要件を空間的に分離することです。つまり、これを 1 つの場所に、それを別の場所に配置します。
- メイン文書で作業するには、
incompatible documentclass
standalone
クラスに基づいて、それぞれ1つの図を表すドキュメントをいくつでも操作します。
さぁ行こう:
矢印.texこれは、投稿したコードに少し手を加えたものです。コンパイルするだけで、arrows.pdf
すぐに戻ってきます。
\documentclass[10pt,border=3mm]{standalone}
%\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
A \arrow[r, bend left=50, ""{name=U, below, draw=red}]
\arrow[r, bend right=50, ""{name=D, draw=red}]
& B
\arrow[Rightarrow, from=U, to=D]
\end{tikzcd}
\end{document}
メイン.texは、珍しいドキュメントクラスを使用します。たとえばscreenplay
、 : これは、 との連携に関してメインクラスが持つと思われる相違点、欠点、非互換性などを模倣しますtikz-cd
。
スクリプトは tikz-cd でも動作するかもしれませんが、確認していません。しかし、動作しないものと仮定しましょう。ご覧のとおり、スクリプトは Tikz 方言をまったく使用していません...
関連するコード行は次のとおりです。
...
\usepackage{graphicx} % without tikz showing tikz-cd diagram
...
\includegraphics[width=.3\textwidth]{arrows}% i.e. arrows.pdf
...
\documentclass{screenplay}[2012/06/30] % just an alian class
\usepackage{graphicx} % without tikz showing tikz-cd diagram
% ~~~ some shortcuts ~~~~~~~~~~~~
\newcommand\di[2]{\begin{dialogue}{#1}#2\end{dialogue}}
\newcommand\dia[3]{\begin{dialogue}[#2]{#1}#3\end{dialogue}}
\newcommand\newch[1]{\MakeUppercase{#1}}
\newcommand\pr[0]{Proggi}
\newcommand\ld[0]{Lad}
% ~~~ some redefine ~~~~~~~~~~~
\renewcommand\emph{***}
% ~~~~~~~~~~~~~~~~~~~~~~~
\begin{document}
\title{An arrows drama}
\author{MS-SPO}
\maketitle
% ~~~ Characters ~~~~~~~~~~~~~~~~~~~~~~
\newch{Proggi}, a programmer, full of energy.
\newch{Lad}, a nice document creating language, with some bells and whistles.
% ~~~ Let the drama begin ~~~~~~~~~~~
\fadein
\intslug[Night]{A stubborn documentclass}
\pr{} spent already endless hours, while \ld{} keeps being stubborn.
\dia{\pr}{impatient}{Why can't you just do what I'm telling you to do! Why can't you?}
\dia{\ld}{amused}{You did read the manuals, did you?}
\dia{\pr}{about to burst}{Yours, yeah \dots other ones?}
\dia{\ld}{whispering}{Yes: about \emph{standalone} and \emph{graphicx} \dots There you go \dots}
\begin{center}
\includegraphics[width=.3\textwidth]{arrows} % <<<
\end{center}
\fadeout
\end{document}