我得到了一个小的自动机 tikzpicture,但它越复杂,就越难读。所以我想调整边缘标签的字体大小,但我就是不知道该怎么做。尝试查看 tikzpgf 手册以及此处,但我只找到了节点的 ,而没有找到路径命令中的边缘标签的scale
。fontsize
例如我想让这两条路径中的文本变小一些:
\usepackage{pgfplots}
\usetikzlibrary{automata,positioning,fit,shapes.geometric,backgrounds}
\begin{figure}
\begin{tikzpicture}[node distance=1.5cm]
\node [state, initial] (Neutral) {Neutral};
\node[state]
(UI Popup)
[right=of Neutral]
{Popped UI};
\node[state]
(Sine)
[above right=of UI Popup]
[fill=gray]
{\includegraphics[width=1.8cm]{sinecurve2}};
\node[state, circle split]
(Digital_Off)
[scale=0.75]
[below right=of UI Popup]
{Digital [Off] \nodepart{lower} \includegraphics[width=0.5cm]{pin_off}};
\node[state, circle split]
(Digital_On)
[scale=0.75]
[right=of Digital_Off]
{Digital [On] \nodepart{lower} \includegraphics[width=0.5cm]{pin_on}};
\begin{scope}[on background layer]
\node[fit=(Digital_Off) (Digital_On), rectangle, rounded corners, draw=red, label=above:Digital state] (digital) {};
\end{scope}
\path[->] [line width=0.3mm]
(Neutral) edge [scale=0.2] node [above] {Tap} (UI Popup)
(UI Popup) edge [bend left] node [above left] {Tap and select analog} (Sine)
edge [bend right] node [below left] {Tap and select digital} (Digital_Off)
(Digital_Off) edge [bend left] node [above] {Tap} (Digital_On)
(Digital_On) edge [bend left] node [below] {Tap} (Digital_Off)
%(digital) edge [bend left] node [above] {Tap} (Sine)
(digital) edge [bend right] node [above] {Long click} (UI Popup)
(Sine) edge [bend left] node [below] {Long click} (UI Popup)
;
\end{tikzpicture}
\caption{Input pin behavior}
\end{figure}
编辑:
这个 tikzpicture 位于一个以 \chapter{...} 开头的单独文件中,main.tex 文件如下所示:
%!TEX root = ./main.tex
\documentclass[11pt, a4paper, titlepage]{book}
\include{i10preamble}
\begin{document}
\sloppy
\include{indexAddOn}
\frontmatter
\begin{titlepage}
\AddToShipoutPicture*{
\put(0,0){
\includegraphics[width=\paperwidth]{titlepage_Master_CID}}}
\strut
\end{titlepage}
% Lots of other stuff inside
\end{document}
答案1
同时我等待你的完整mwe,我在我的tikz
测试平台上测试你的图像代码,因此我的序言可能与你在文档中使用的不同...
我将按照以下方式为您的图像编写代码:
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{automata,
fit,
positioning,
quotes,
shapes.multipart
}
\usepackage{graphicx}
\newcommand\greencirc{\tikz\node[circle, draw, thick, fill=green,
minimum size=3ex, node contents={}];}
\newcommand\whitecirc{\tikz\node[circle, draw, thick, fill=white,
minimum size=3ex, node contents={}];}
\begin{document}
\begin{tikzpicture}[
node distance = 8mm and 12mm,
MP/.style = {circle split, draw, inner sep=1pt,
align=center, font=\scriptsize},
state/.append style = {fill=#1, align=center},
state/.default = white,
every edge quotes/.append style={font=\scriptsize, align=center, auto}% style for edge labels
]
\node (Neutral) [state, initial] {Neutral};
\node (UI Popup) [state, right=of Neutral] {Popped\\ UI};
\node (Sine) [state=gray!50, above right=of UI Popup]
{sinecurve2};%{sinecurve2}};
\node (Digital Off) [MP, below right=of UI Popup]
{Digital\\ {[Off]} \nodepart{lower} \\ \whitecirc};
\node (Digital On) [MP, right=of Digital Off]
{Digital\\ {[On]} \nodepart{lower} \\ \greencirc};
%\scoped[on background layer]
\node (digital) [rounded corners, draw=red, label=75:Digital state,
fit=(Digital Off) (Digital On)] {};
\path[thick, ->]
(Neutral) edge ["Tap"] (UI Popup)
(UI Popup) edge [bend left,"Tap and\\ select analog"] (Sine)
edge [bend right,"Tap and\\ select digital" '] (Digital Off)
(Digital Off) edge [bend left,"Tap" '] (Digital On)
(Digital On) edge [bend left,"Tap" '] (Digital Off)
(digital) edge [bend right, "Long\\ click" '] (UI Popup)
(Sine) edge [bend left, "Long\\ click" '] (UI Popup)
;
\end{tikzpicture}
\end{document}
如您所见,所有字体大小均在节点/边引号样式中定义。还用新命令替换了两个图像greencirc
。whitecirc
类似地,可以在灰色节点中对正弦方式进行操作。
答案2
显然scale
确实有效,但我只是在参数的错误部分尝试了它。
我尝试的是
(UI Popup) edge [scale=0.5] [bend left] node [above left] {Tap and select analog} (Sine)
但正确的是
(UI Popup) edge [bend left] node [scale=0.5] [above left] {Tap and select analog} (Sine)