
摘自 PGF 手冊,
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,3);
\coordinate (a) at (rnd,rnd);
\coordinate (b) at (3-rnd,3-rnd);
\draw (a) -- (b);
\node (c) at (1,2) {x};
\draw let \p1 = ($ (a)!(c)!(b) - (c) $),
\n1 = {veclen(\x1,\y1)}
in circle [at=(c), radius=\n1];
\end{tikzpicture}
我想增加 的大小x
。問題是我在同一個圖中有多個圓圈。其中一些需要更大尺寸的字體,而另一些則預設即可。我該怎麼做呢?
答案1
您可以像在普通 LaTeX 中一樣更改 tikZ 節點內的字體大小 - 使用以下其中之一:
\tiny
\scriptsize
\footnotesize
\small
\normalsize
\large
\Large
\LARGE
\huge
\Huge
例如
\node (c) at (1,2) {\large x};
或者
\node (c) at (1,2) {\large $x$}; %note the \large *outside* the inline math
編輯: 更改字體大小裡面在數學模式下,LaTeX 提供了以下指令:
\displaystyle
\textstyle
\scriptstyle
\scriptscriptstyle
使用 tikZ/pgf 提供的縮放演算法(例如scale=...
)可以縮放“整個角色”,因此如果使用太多縮放,它可能看起來很難看。如果使用上述指令設定字體大小,LaTeX 會為不同的字體大小選擇不同的符號。這確保了字體可讀並具有足夠的“細節”。如果您想要更極端的縮放,請使用scale=3.0
節點選項。
答案2
設定一個新的樣式,以便日後可以使用。
例如:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{relsize}
\tikzset{fontscale/.style = {font=\relsize{#1}}
}
\begin{document}
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,3);
\coordinate (a) at (rnd,rnd);
\coordinate (b) at (3-rnd,3-rnd);
\draw (a) -- (b);
\node (c) at (1,2) [fontscale=4] {x};
\draw let \p1 = ($ (a)!(c)!(b) - (c) $),
\n1 = {veclen(\x1,\y1)}
in circle [at=(c), radius=\n1];
\end{tikzpicture}
\end{document}
答案3
在最上面寫
\begin{tikzpicture}[thick,scale=1, every node/.style={scale=1.3}]
\draw [help lines] (0,0) grid (3,3);
\coordinate (a) at (rnd,rnd);
\coordinate (b) at (3-rnd,3-rnd);
\draw (a) -- (b);
\node (c) at (1,2) {x};
\draw let \p1 = ($ (a)!(c)!(b) - (c) $),
\n1 = {veclen(\x1,\y1)}
in circle [at=(c), radius=\n1];
\end{tikzpicture}
粗細改變你的箭頭,第一個比例改變你的繪圖的比例,但第二個參數改變你的節點的大小,大概是你有文字的地方。所有節點的情況都會改變。
答案4
您可以使用font
該命令的選項\node
。此font
選項接受典型的字體指令,例如\node[font = {\Huge\bfseries\sffamily}, red]
(大字體、粗體、無襯線)。
(摘自手動的.)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,3);
\coordinate (a) at (rnd,rnd);
\coordinate (b) at (3-rnd,3-rnd);
\draw (a) -- (b);
\node[font = {\normalfont}, red] (c) at (1,2) {x}; % <=== See here!
\draw let \p1 = ($ (a)!(c)!(b) - (c) $),
\n1 = {veclen(\x1,\y1)}
in circle [at=(c), radius=\n1];
\end{tikzpicture}
\begin{tikzpicture}
\draw [help lines] (0,0) grid (3,3);
\coordinate (a) at (rnd,rnd);
\coordinate (b) at (3-rnd,3-rnd);
\draw (a) -- (b);
\node[font = {\Huge\bfseries\sffamily}, red] (c) at (1,2) {x}; % <=== See here!
\draw let \p1 = ($ (a)!(c)!(b) - (c) $),
\n1 = {veclen(\x1,\y1)}
in circle [at=(c), radius=\n1];
\end{tikzpicture}
\end{document}
\tiny
\scriptsize
\footnotesize
\small
\normalsize
\large
\Large
\LARGE
\huge
\Huge
(摘自手動的.)