如何使用 tikz 自定义背景颜色

如何使用 tikz 自定义背景颜色

有人知道如何去除背景中产生的黑色吗?

期望输出

\documentclass{beamer}
\usetheme{Hannover}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{pgfmath}
\usetikzlibrary{decorations.text, arrows.meta,calc,shadows.blur,shadings}

\begin{document}

\begin{frame}
    \begin{adjustbox}{max totalsize={.95\textwidth}{.8\textheight},center}
        \begin{tikzpicture}[
            % Environment Cfg
            font=\bf \footnotesize,
            % Styles
            myarrow/.style={
                thick,
                -latex,
            },
            Center/.style ={
                circle,
                fill=GRIS!10,
                text=black,
                align=center,
                font =\footnotesize\bf,
                inner sep=9pt,          
            },
            RO/.style ={
                text=black,
                color=black,
                thick,
                fill=RO!90,
                blur shadow, %Tikzedt not suport online view
            },
            RM/.style ={
                color=black,
                thick,
                fill=RM!90,
                blur shadow, %Tikzedt not suport online view
            },
            RC/.style ={
                color=black,
                thick,
                fill=RC!80,
                blur shadow, %Tikzedt not suport online view
            },
            AO/.style ={
                text=black,
                color=black,
                thick,
                fill=AO!90,
                blur shadow, %Tikzedt not suport online view
            },
            AM/.style ={
                color=black,
                thick,
                fill=AM!90,
                blur shadow, %Tikzedt not suport online view
            },
            AC/.style ={
                color=black,
                thick,
                fill=AC!90,
                blur shadow, %Tikzedt not suport online view
            },
            VO/.style ={
                text=black,
                color=black,
                thick,
                fill=VO!90,
                blur shadow, %Tikzedt not suport online view
            },
            VM/.style ={
                color=black,
                thick,
                fill=VM!70,
                blur shadow, %Tikzedt not suport online view
            },
            VC/.style ={
                color=black,
                thick,
                fill=VC!70,
                blur shadow, %Tikzedt not suport online view
            },
            OO/.style ={
                color=GRIS,
                thick,
                fill=OO!90,
                blur shadow, %Tikzedt not suport online view
            },
            OM/.style ={
                color=GRIS,
                thick,
                fill=OM!90,
                blur shadow, %Tikzedt not suport online view
            },
            OC/.style ={
                color=GRIS,
                thick,
                fill=OC!90,
                blur shadow, %Tikzedt not suport online view
            },
            ]
            
            % Drawing the center
            \node[Center](SOSA) at (0,0) { HYDROLOGICAL\\  IMPACT  UNDER \\  FUTURE  CLIMATE };
            \coordinate (SOSA-R) at (1.5:1.5); % To make compatible with \arcarrow macro.
            
            % Drawing the Tex Artyle][box-height](radious)(start-angl)(end-angl){|text-styles| Text}cs
            %\Arctext[ID][box-s
            \arctext[ST][RO][9pt](5.5)(88)(2){|\footnotesize\bf\color{white}| I.  STUDY AREA};
            \arctext[L][RM][9pt](4.5)(88)(2){|\footnotesize| Location};
            \arctext[C][RC][9pt](3.5)(88)(2){|\footnotesize| Clima};
            
            \arctext[IM][VO][9pt](5.5)(178)(92){|\footnotesize\bf\color{white}| II.  IMPROVMENT OF DAILY SERIES};
            \arctext[IN][VM][9pt](4.5)(178)(92){|\footnotesize|  TRMM-TMPA Validation over UCB};    
            \arctext[TR][VC][9pt](3.5)(178)(92){|\footnotesize| Interpolation techniques};
            
            \arctext[FC][OO][9pt](5.5)(182)(268){|\footnotesize\bf\color{white}| III. FUTURE  CLIMA PROJECTION};
            \arctext[GC][OM][9pt](4.5)(182)(268){|\footnotesize| GCM Selection};
            \arctext[DS][OC][9pt](3.5)(182)(268){|\footnotesize| Downscalling Method};
            
            \arctext[HM][AO][9pt](5.5)(272)(358){|\footnotesize\bf\color{white}| IV. HYDROLOGICAL MODELLING };
            \arctext[CAL][AM][9pt](4.5)(272)(358){|\footnotesize|Calibration };
            \arctext[VAL][AC][9pt](3.5)(272)(358){|\footnotesize| Validation};
{|\footnotesize\bf\color{white}| THESIS STRUCTURE};
            
            
            \arcarrow(below TR)(SOSA-R)[45];
            \arcarrow(below C)(SOSA-R)[45];
            \arcarrow(below DS)(SOSA-R)[315];
            \arcarrow(below VAL)(SOSA-R)[315];
            
            
            
        \end{tikzpicture}
        
    \end{adjustbox}
    
    
\end{frame}
\end{document}

答案1

没有答案,因为您没有提供可以编译的代码,但可能是打字错误。

需要以 开头\documentclass并以 结尾的示例代码来回答问题。\end{document}

当我补齐一些缺失的代码并在 TexLive2020 中的 Lualatex 下运行时,它编译成功 - 这意味着黑色的原因很可能在您的代码中,或者因为包等未更新,或者因为 PDF 查看器(或这些的组合)。或者可能是其他原因。

因此:为了得到一个可行的例子,我所做的是这样的 - 我随机制定了一些颜色定义,\acrarrow从这里复制了定义在 tikz 中创建具有多个连接环的环形图的最简单方法?,以及arctext来自其他地方我记不清的定义,添加了adjustbox包,......:

弧箭

平均能量损失

\documentclass{beamer}
\usepackage{tikz}
\usetheme{Hannover}
\usepackage{xcolor}
\usepackage{pgfmath}
\usetikzlibrary{decorations.text, arrows.meta,calc,shadows.blur,shadings}
\usepackage{graphicx}
\usepackage{adjustbox}

\definecolor{RO}{RGB}{226,0,116}
\definecolor{RM}{RGB}{116,0,226}
\definecolor{RC}{RGB}{116,226,16}
\definecolor{VO}{RGB}{16,226,116}
\definecolor{VM}{RGB}{160,126,6}
\definecolor{OO}{RGB}{6,126,106}
\definecolor{VC}{RGB}{60,226,80}
\definecolor{OM}{RGB}{60,246,0}
\definecolor{OC}{RGB}{0,226,80}
\definecolor{AO}{RGB}{250,12,10}
\definecolor{AM}{RGB}{25,122,210}
\definecolor{AC}{RGB}{25,212,10}

\newcommand*{\mytextstyle}{\sffamily\Large\bfseries\color{black!85}}

%arcarrow, this is mine, for beerware purpose...
%Function: Draw an arrow from arctex coordinate specific nodes to another 
%Arrow start at the start of arctext box and could be shifted to change the position
%to avoid go over another box.
%Var: 1:Start coordinate 2:End coordinate 3:angle to shift from acrtext box  
\def\arcarrow(#1)(#2)[#3]{
    \draw[thick,->,>=latex] 
        let \p1 = (#1), \p2 = (#2), % To access cartesian coordinates x, and y.
            \n1 = {veclen(\x1,\y1)}, % Distance from the origin
            \n2 = {veclen(\x2,\y2)}, % Distance from the origin
            \n3 = {atan2(\y1,\x1)} % Angle where acrtext starts.
        in (\n3-#3: \n1) -- (\n3-#3: \n2); % Draw the arrow.
}

%%%%%\newcommand{\arcarrow}[3]{%
%%%%%   % inner radius, middle radius, outer radius, start angle,
%%%%%   % end angle, tip protusion angle, options, text
%%%%%   \pgfmathsetmacro{\rin}{1.7}
%%%%%   \pgfmathsetmacro{\rmid}{2.2}
%%%%%   \pgfmathsetmacro{\rout}{2.7}
%%%%%   \pgfmathsetmacro{\astart}{#1}
%%%%%   \pgfmathsetmacro{\aend}{#2}
%%%%%   \pgfmathsetmacro{\atip}{5}
%%%%%   \fill[green!20, very thick] (\astart+\atip:\rin)
%%%%%                         arc (\astart+\atip:\aend:\rin)
%%%%%      -- (\aend-\atip:\rmid)
%%%%%      -- (\aend:\rout)   arc (\aend:\astart+\atip:\rout)
%%%%%      -- (\astart:\rmid) -- cycle;
%%%%%   \path[
%%%%%      decoration = {
%%%%%         text along path,
%%%%%         text = {|\mytextstyle|#3},
%%%%%         text align = {align = center},
%%%%%         raise = -1.0ex
%%%%%      },
%%%%%      decorate
%%%%%   ](\astart+\atip:\rmid) arc (\astart+\atip:\aend+\atip:\rmid);
%%%%%}

%%%\newcommand{\arcarrow}[3]{%
%%%   % inner radius, middle radius, outer radius, start angle,
%%%   % end angle, tip protusion angle, options, text
%%%   \pgfmathsetmacro{\rin}{1.7}
%%%   \pgfmathsetmacro{\rmid}{2.2}
%%%   \pgfmathsetmacro{\rout}{2.7}
%%%   \pgfmathsetmacro{\astart}{#1}
%%%   \pgfmathsetmacro{\aend}{#2}
%%%   \pgfmathsetmacro{\atip}{5}
%%%   \fill[mygray, very thick] (\astart+\atip:\rin)
%%%                         arc (\astart+\atip:\aend:\rin)
%%%      -- (\aend-\atip:\rmid)
%%%      -- (\aend:\rout)   arc (\aend:\astart+\atip:\rout)
%%%      -- (\astart:\rmid) -- cycle;
%%%   \path[
%%%      decoration = {
%%%         text along path,
%%%         text = {|\mytextstyle|#3},
%%%         text align = {align = center},
%%%         raise = -1.0ex
%%%      },
%%%      decorate
%%%   ](\astart+\atip:\rmid) arc (\astart+\atip:\aend+\atip:\rmid);
%%%}
% arctext from Andrew code with modifications:
%Variables: 1: ID, 2:Style 3:box height 4: Radious 5:start-angl 6:end-angl 7:text {format along path} 
\def\arctext[#1][#2][#3](#4)(#5)(#6)#7{
\draw[
    color=white,
    thick,
    line width=1.3pt,
    fill=#2
]
(#5:#4cm+#3) coordinate (above #1) arc (#5:#6:#4cm+#3)
-- (#6:#4) coordinate (right #1) -- (#6:#4cm-#3) coordinate (below right #1) 
arc (#6:#5:#4cm-#3) coordinate (below #1)
-- (#5:#4) coordinate (left #1) -- cycle;
\def\a#1{#4cm+#3}
\def\b#1{#4cm-#3}
\path[
    decoration={
        raise = -0.5ex, % Controls relavite text height position.
        text  along path,
        text = {#7},
        text align = center,        
    },
    decorate
    ]
    (#5:#4) arc (#5:#6:#4);
}
\begin{document}

\begin{frame}
    \begin{adjustbox}{max totalsize={.95\textwidth}{.8\textheight},center}
        \begin{tikzpicture}[
            % Environment Cfg
            font=\bf \footnotesize,
            % Styles
            myarrow/.style={
                thick,
                -latex,
            },
            Center/.style ={
                circle,
                fill=blue!10,
                text=black,
                align=center,
                font =\footnotesize\bf,
                inner sep=9pt,          
            },
            RO/.style ={
                text=black,
                color=black,
                thick,
                fill=RO!90,
                blur shadow, %Tikzedt not suport online view
            },
            RM/.style ={       color=black,
                thick,
                fill=RM!90,
                blur shadow, %Tikzedt not suport online view
            },
            RC/.style ={
                color=black,
                thick,
                fill=RC!80,
                blur shadow, %Tikzedt not suport online view
            },
            AO/.style ={
                text=black,
                color=black,
                thick,
                fill=AO!90,
                blur shadow, %Tikzedt not suport online view
            },
            AM/.style ={
                color=black,
                thick,
                fill=AM!90,
                blur shadow, %Tikzedt not suport online view
            },
            AC/.style ={
                color=black,
                thick,
                fill=AC!90,
                blur shadow, %Tikzedt not suport online view
            },
            VO/.style ={
                text=black,
                color=black,
                thick,
                fill=VO!90,
                blur shadow, %Tikzedt not suport online view
            },
            VM/.style ={
                color=black,
                thick,
                fill=VM!70,
                blur shadow, %Tikzedt not suport online view
            },
            VC/.style ={
                color=black,
                thick,
                fill=VC!70,
                blur shadow, %Tikzedt not suport online view
            },
            OO/.style ={
                color=blue,
                thick,
                fill=OO!90,
                blur shadow, %Tikzedt not suport online view
            },
            OM/.style ={
                color=blue,
                thick,
                fill=OM!90,
                blur shadow, %Tikzedt not suport online view
            },
            OC/.style ={
                color=blue,
                thick,
                fill=OC!90,
                blur shadow, %Tikzedt not suport online view
            },
            ]
            
            % Drawing the center
            \node[Center](SOSA) at (0,0) { HYDROLOGICAL\\  IMPACT  UNDER \\  FUTURE  CLIMATE };
            \coordinate (SOSA-R) at (1.5:1.5); % To make compatible with \arcarrow macro.
            
%            % Drawing the Tex Artyle][box-height](radious)(start-angl)(end-angl){|text-styles| Text}cs
%            %\Arctext[ID][box-s
            \arctext[ST][RO][9pt](5.5)(88)(2){|\footnotesize\bf\color{white}| I.  STUDY AREA};
            \arctext[L][RM][9pt](4.5)(88)(2){|\footnotesize| Location};
            \arctext[C][RC][9pt](3.5)(88)(2){|\footnotesize| Clima};
%            
            \arctext[IM][VO][9pt](5.5)(178)(92){|\footnotesize\bf\color{white}| II.  IMPROVMENT OF DAILY SERIES};
            \arctext[IN][VM][9pt](4.5)(178)(92){|\footnotesize|  TRMM-TMPA Validation over UCB};    
            \arctext[TR][VC][9pt](3.5)(178)(92){|\footnotesize| Interpolation techniques};
%            
            \arctext[FC][OO][9pt](5.5)(182)(268){|\footnotesize\bf\color{white}| III. FUTURE  CLIMA PROJECTION};
            \arctext[GC][OM][9pt](4.5)(182)(268){|\footnotesize| GCM Selection};
            \arctext[DS][OC][9pt](3.5)(182)(268){|\footnotesize| Downscalling Method};
%            
            \arctext[HM][AO][9pt](5.5)(272)(358){|\footnotesize\bf\color{white}| IV. HYDROLOGICAL MODELLING };
            \arctext[CAL][AM][9pt](4.5)(272)(358){|\footnotesize|Calibration };
            \arctext[VAL][AC][9pt](3.5)(272)(358){|\footnotesize| Validation};
%{|\footnotesize\bf\color{white}| THESIS STRUCTURE};
%            
%            
            \arcarrow(below TR)(SOSA-R)[45];
%%   \arcarrow{ 85}{  3}{ PLAN  }
%%   \arcarrow{270}{357}{ DO    }
%%   \arcarrow{182}{269}{ CHECK }
%%   \arcarrow{176}{ 96}{ ACT   }
            
            \arcarrow(below C)(SOSA-R)[45];
            \arcarrow(below DS)(SOSA-R)[315];
            \arcarrow(below VAL)(SOSA-R)[315];
%            
            
            
        \end{tikzpicture}
        
    \end{adjustbox}
    
    
\end{frame}
\end{document}

相关内容