Tikz-cd 箭头提示

Tikz-cd 箭头提示

我将 LaTeX 文档中的交换图从 xypic 更改为 tikz-cd。我必须补充一点,我也有一些带箭头的 tikz 图(例如,Dynkin 图)。最初,我在匹配 tikz 图和 tikz-cd 图的箭头时遇到了一些问题,但多亏了下面的评论,我才得以解决这个问题。

我现在的问题是如何将箭头尖全局设置为更适合我的东西,例如

\tikzset{>=Straight Barb}

(我不确定箭头的名称)

根据以下评论,我能够获得带有 CM 箭头提示的最小运行示例:

\documentclass{amsart} 
\usepackage[usenames,dvipsnames]{xcolor} 
\usepackage{tikz} 
%\tikzset{>=latex}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}%
\tikzcdset{arrow style=tikz}

\begin{document}
\begin{equation*}
\begin{tikzcd}
A \arrow{r}{f} \arrow[two heads]{d}[swap]{x} & C\arrow[two heads]{d} \\
B \arrow{r}[swap]{g}   &  D
\end{tikzcd}
\end{equation*}
\bigskip

\begin{center}
\begin{tikzpicture}[scale=1.2]
\draw[red, thick,->] (2,0) -- (3,0);
\draw[thick,-] (2,0) -- (2,1);
\draw[thick,-] (2,0) -- (1,0);
\draw[thick,-] (2,0) -- (2,-1);
\draw[fill=red] (2,0) circle(.02);  
\draw[red, thick,->] (2,0) -- (2.707,0.707);
\draw[red,thick,->] (2,0) -- (2.707,-0.707);
\draw[thick,->] (2,0) -- (1.293,0.707);
\draw[thick,->] (2,0) -- (1.293,-0.707);
\end{tikzpicture} 
\end{center}
\end{document}

答案1

我怀疑您有以下情况:

在此处输入图片描述

为了改变图表中的箭头,tikz-cd您需要定义类似这样的内容(用于文档序言中的全局设置):

\tikzcdset{arrow style=tikz,
           diagrams={>=Straight Barb}
           }

对于 s 中的类似更改tikzpicture,您需要\tikzset在文档前言中定义它们以进行全局设置,或将其放在tikzpicture本地设置的选项中,如以下 MWE 中所示:

\documentclass[usenames, dvipsnames]{amsart}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta,        
                decorations.pathmorphing,
                matrix}%
\tikzcdset{arrow style=tikz,
           diagrams={>=Straight Barb}
           }
           

\begin{document}
    \[
\begin{tikzcd}
A   \ar[r,"f"]    
    \ar[d,two heads,"x"]    &   C   \ar[d, two heads, "d"]   \\
B   \ar[r,"g"]              &   D
\end{tikzcd}
    \]
\bigskip
    \[
    \begin{tikzpicture}[scale=1.2,
  arr/.style = {draw=#1, thick, -Straight Barb},
arr/.default = red
                        ]
\draw[arr]  (2,0) -- (3,0);
\draw[thick]    (2,1) -- (2,-1)
                (2,0) -- (1,0);
\draw[arr]  (2,0) -- (2.707,0.707);
\draw[arr]  (2,0) -- (2.707,-0.707);
\draw[arr=black] (2,0) -- (1.293,0.707);
\draw[arr=black] (2,0) -- (1.293,-0.707);
\fill[red]  (2,0) circle[radius=1mm];
    \end{tikzpicture}
    \]
\end{document}

附录:

箭头类型的定义可以是全局的(在文档的前言中使用样式定义),也可以是局部的(如果它们是图形的一部分)。以下 MWE 中存在全局和局部设置组合的示例:

\documentclass[usenames, dvipsnames]{amsart}
\usepackage{tikz-cd}
\usetikzlibrary{arrows.meta,        
                decorations.pathmorphing,
                matrix}%
\tikzcdset{arrow style=tikz,
           diagrams={>=Straight Barb}
           }    % global setting for arrow heads in tikz-cd diagrams
\tikzset{>=Straight Barb
           }    % global settings for arrow heads in tikzpicturres
           

\begin{document}
    \[
\begin{tikzcd}
A   \ar[r,"f"]    
    \ar[d,two heads,"x"]    &   C   \ar[d, two heads, "d"]   \\
B   \ar[r,"g"]              &   D
\end{tikzcd}
    \]
\bigskip
    \[
    \begin{tikzpicture}[
% local settings use global and if needed overwrite global one
       scale = 1.2,
  arr/.style = {draw=#1, thick, ->}, % for the arrowheads is used global setting  
arr/.default = red
                        ]
\draw[arr]  (2,0) -- (3,0);
\draw[thick]    (2,1) -- (2,-1)
                (2,0) -- (1,0);
\draw[arr]  (2,0) -- (2.707,0.707);
\draw[arr]  (2,0) -- (2.707,-0.707);
\draw[arr=black] (2,0) -- (1.293,0.707);
\draw[arr=black] (2,0) -- (1.293,-0.707);
\fill[red]  (2,0) circle[radius=1mm];
    \end{tikzpicture}
    \]
\end{document}

结果和以前一样。

相关内容