使用 tikz 时的字体大小

使用 tikz 时的字体大小

我正在尝试为 tikz 中的图表编写代码。我对 tikz 很陌生,所以这可能是一个简单的问题,但还是继续吧。我有一些代码,如下所示:

\begin{tikzpicture}[scale=.95]
\draw [<->, thick] (0,0) coordinate (a_1) -- (2,1.8) coordinate (a_2)node[right]{$\mathcal{M}$};
\draw [<->, thick, color=black!40!blue] (1,0) coordinate (b_1) node[right]{$\mathcal{N}$}-- (1,2) coordinate (b_2);

\coordinate (c) at (intersection of a_1--a_2 and b_1--b_2);
\fill (c) circle (2pt) node[right]{$X$};
\end{tikzpicture}

但我遇到的问题是,在更复杂的图表中,文本标签的字体太大,并与线条相交。如何让标签节点中的字体变小?

答案1

您可以将font密钥作为的可选参数使用tikzpicture

\begin{tikzpicture}[font=\footnotesize]
% ....
\end{tikzpicture}

或者,如果您希望将此用于tikzpicture文档中的所有 s,请将其放在序言中的某个位置:

\tikzset{every picture/.append style={font=\footnotesize}}

答案2

正如您所注意到的,字母位于节点内,因此您可以在每个节点的“字体”属性中指定所需的大小,除此之外,您还可以指定文本的相对位置,下面我附上了您的代码和一些节点字母大小属性:


\begin{tikzpicture}[scale=.95]
\draw [<->, thick] (0,0) coordinate (a_1) -- (2,1.8) coordinate (a_2)node[right, font=\tiny, anchor=270]{$M_{270}$}node[right, font=\tiny, anchor=180]{$M_{180}$}node[right, font=\tiny, anchor=150]{$M_{150}$};
\draw [<->, thick, color=black!40!blue] (1,0) coordinate (b_1) node[right, font=\tiny, anchor=south west]{$\mathcal{N}$}-- (1,2) coordinate (b_2);

\coordinate (c) at (intersection of a_1--a_2 and b_1--b_2);
\fill (c) circle (2pt) node[right, font=\tiny, anchor=east]{$X$};
\end{tikzpicture}

enter image description here

相关内容