我想写如下图所示

我想写如下图所示
\documentclass[12pt]{report}
\usepackage{lmodern}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage[french]{babel}
\usepackage[utf8]{inputenc}

\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{enumitem}
\usepackage{csquotes}
\usepackage[x11names]{xcolor}
\usepackage{framed, etoolbox}
\colorlet{framecolor}{VioletRed4}
\colorlet{shadecolor}{LavenderBlush2!60}
\usepackage{thmtools} %
\usepackage{sectsty}
\chapterfont{\color{Firebrick2}}  % sets colour of chapters
\sectionfont{\color{Chartreuse4}}
\subsectionfont{\color{blue}}
%talwin majzo2at
%\usepackage{sectsty}%
%\chapterfont{\color{Firebrick2}}
%\usepackage{titlesec}%%%%%% <---------addendum
%\titleformat{\section}%%%%%% <---------addendum
%{\color{Chartreuse4}\normalfont\Large\bfseries}%%%%%% <---------addendum
%{\color{Chartreuse4}\thesection}{1.5em}{}%%%%%% <---------addendum


%\titleformat{\subsection}%%%%%% <---------addendum
%{\color{Firebrick3}\normalfont\Large\bfseries}%%%%%% <---------addendum
%{\color{Firebrick3}\thesection}{1.5em}{}%%%%%% <---------addendum


\makeatletter
\define@key{thmdef}{frame}[{}]{%
 \thmt@trytwice{}{%
 \RequirePackage{framed}%
 \RequirePackage{thm-patch}%
    \def\FrameCommand{\fcolorbox{framecolor}{shadecolor}}
 \addtotheorempreheadhook[\thmt@envname]{%
 \begin{framed}}%
 \addtotheorempostfoothook[\thmt@envname]{\end{framed}}%
 }%
}
\makeatother




\usepackage{thmtools}
\declaretheoremstyle[
    spaceabove=-6pt, 
    spacebelow=6pt, 
    headfont=\normalfont\bfseries, 
    bodyfont = \normalfont,
    postheadspace=1em, 
    qed=$\blacksquare$, 
    headpunct={:}]{myproofstyle} %<---- change this name
\declaretheorem[name={Proof}, style=myproofstyle, unnumbered]{Proof}

\declaretheoremstyle[
    spaceabove=6pt, 
    spacebelow=6pt, 
    headfont=\normalfont\bfseries,
    notefont=\mdseries\bfseries, 
    notebraces={(}{)}, 
    bodyfont=\normalfont\itshape,
    postheadspace=1em,
    headpunct={:}]{mystyle}

    \declaretheoremstyle[
    spaceabove=6pt, 
    spacebelow=6pt, 
    headfont=\normalfont\bfseries,
    notefont=\mdseries\bfseries, 
    notebraces={(}{)}, 
    bodyfont=\normalfont,
    postheadspace=1em,
    postheadhook = {\hspace{0mm}\newline},
    headpunct={:},]{myst}

\declaretheorem[name={Théorème}, style=mystyle,numberwithin=section]{thm}
\declaretheorem[name={Lemme}, style=mystyle,numberwithin=section]{lema}
\declaretheorem[frame,name={Définition}, style=mystyle,numberwithin=section]{defi}
\declaretheorem[frame,name={Corollaire}, style=mystyle,numberwithin=section]{coro}
\declaretheorem[frame,name={Proposition}, style=mystyle,numberwithin=section]{props}
\declaretheorem[frame,name={Vocabulaire}, style=mystyle,numberwithin=section]{voc}
\declaretheorem[name={Preuve}, style=myst,numbered=no]{preuve}
\declaretheorem[name={Remarque}, style=myst,numberwithin=section]{remark}
\declaretheorem[name={Remarques}, style=mystyle,numberwithin=section]{remarks}
\declaretheorem[name={Exemple}, style=myst,numberwithin=section]{exemple}
\declaretheorem[name={Exemples}, style=myst,numberwithin=section]{exemples}
\declaretheorem[name={Méthode}, style=mystyle,numberwithin=section]{methode}
\declaretheorem[name={Méthodes}, style=mystyle,numbered=no]{methodes}
\declaretheorem[name={Notation}, style=mystyle,numbered=no]{notation}











\AtBeginEnvironment{defi}{\colorlet{framecolor}{black}
    \colorlet{shadecolor}{orange!15}}
\newcommand{\myarrow}[1][1cm]{\mathrel{%
   \hbox{\rule[\dimexpr\fontdimen22\textfont2-.2pt\relax]{#1}{.4pt}}%
   \mkern-4mu\hbox{\usefont{U}{lasy}{m}{n}\symbol{41}}}}
   \AtBeginEnvironment{voc}{\colorlet{framecolor}{black}
    \colorlet{shadecolor}{LightSkyBlue2!25}}
    \AtBeginEnvironment{props}{\colorlet{framecolor}{black}
    \colorlet{shadecolor}{Yellow1!15}}
     \AtBeginEnvironment{coro}{\colorlet{framecolor}{black}
    \colorlet{shadecolor}{Yellow1!15}}

\makeatletter

\setbox0\hbox{$\xdef\scriptratio{\strip@pt\dimexpr
    \numexpr(\sf@size*65536)/\f@size sp}$}

\newcommand{\myscriptarrow}[1][1cm]{{%
    \hbox{\rule[\scriptratio\dimexpr\fontdimen22\textfont2-.2pt\relax]
               {\scriptratio\dimexpr#1\relax}{\scriptratio\dimexpr.4pt\relax}}%
   \mkern-4mu\hbox{\let\f@size\sf@size\usefont{U}{lasy}{m}{n}\symbol{41}}}}

\makeatother
\newcommand*{\QED}{\hfill\ensuremath{\blacksquare}}%Heron
\usepackage{tikz-cd}
\begin{document}


\center{\begin{tikzcd}[row sep=5em,column sep=5em,sep=large]

A \arrow[r, "\phi"]

C \arrow[r, red, "\eta" blue]
& D
\end{tikzcd}

\end{document}

答案1

我猜你喜欢画这样的东西:

在此处输入图片描述

\documentclass[12pt]{report}
\usepackage[top=2cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{tikz-cd}

\begin{document}
    \begin{center}  % <---
\begin{tikzcd}[row sep=5em,column sep=5em,sep=large]
A \arrow[r, "\phi"]
    &   C \arrow[r, red, "\eta" blue] % <---
        &   D
\end{tikzcd}
    \end{center} % <---
\end{document}

您的图像代码有更多错误: -\center{未被关闭} - `\center 也是未知命令 - 错过的是一个 & 符号

然而,也许我错了。

下次再有问题时,请提供一个小文档(MWE),其中的序言中仅加载了针对您的问题所需的软件包。

答案2

来自这个答案和此链接的评论如何使用 xy/xymatrix 包为标签和箭头着色可以使用最佳用户 @Zarko 的xy软件包重现相同的代码。请参阅我的MWE

在此处输入图片描述

\documentclass[a4paper,12pt]{article} 
\usepackage{xcolor} 
\usepackage[color,cmtip,all]{xy} 
\begin{document} 
\xymatrix@R+1pc@C+1pc{ A \ar[r]^{\phi}& C \ar@[red][r]^{\color{blue}\eta} & D\\ }
\end{document} 

相关内容