tikz 风格边框

tikz 风格边框
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\tikzstyle{rec} = [rectangle, rounded corners , minimum height=1.5cm,text centered, draw,fill={rgb,255:red,255; green,255; blue,225}]

\begin{document}
\begin{tikzpicture}[node distance=2cm]

\node (start) [rec] {\textbf{M3 Cortex MCU \\STM32F103}};
\end{tikzpicture}
\end{document}

在此处输入图片描述

所以我尝试创建如下所示的样式,但我无法添加阴影、边框,也无法使文本像这样。有什么建议吗:( 2

答案1

我对 了解甚少tikz。但我知道如果你搜索这个网站,你通常可以通过找到类似的例子来解决你的问题。对 OP 代码的修改涉及边框、阴影、节点中的堆叠文本、inner sep\sffamily等。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage[usestackEOL]{stackengine}
\usetikzlibrary{shapes.geometric, arrows}
\usetikzlibrary{fadings}
\usetikzlibrary{shadows.blur}
\newlength{\borderwidth}
\setlength{\borderwidth}{2mm}
\tikzstyle{rec} = [rectangle, rounded corners , minimum height=1.5cm,
  text centered, border = blue!70!red, inner sep=10pt,
  blur shadow={shadow blur steps=5},
  draw,fill={rgb,255:red,255; green,255; blue,225}]

\tikzset{
border/.style = {
    postaction = {clip, postaction = {draw = #1, solid, 
    line width = \borderwidth, path fading=west, 
    postaction={draw, path fading = north}},
    }
}}

\begin{document}
\begin{tikzpicture}[node distance=2cm]
\node (start) [rec] {\sffamily\bfseries
  \Centerstack{M3 Cortex MCU \\STM32F103}};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

如果不将此盒子放置在 内,则可以用来tikzpicture构建它。tcboxtcolorbox

或多或少:

\documentclass{article}
\usepackage{lmodern}
\usepackage[most]{tcolorbox}
\usetikzlibrary{shadings}

\newtcbox{nicebox}[1][]{%
    enhanced, notitle, boxrule=2mm, fontupper=\sffamily\bfseries,
    frame style={upper left=red!70!blue!50!white, 
    upper right=red!70!blue!40!white,
    lower left=red!60!blue!40!white,
    lower right=red!50!blue!30!white},
    drop fuzzy shadow,
    colback={rgb,255:red,255; green,255; blue,225},
    tikznode,
    #1
}

\begin{document}

\nicebox{M3 Cortex MCU\\STM32F103}

\end{document}

在此处输入图片描述

相关内容