`tikz` 中的字体变化

`tikz` 中的字体变化

我有这个代码:

\documentclass[tikz,border=10pt]{standalone}
\begin{document}

\newcommand{\pythagwidth}{3cm}
\newcommand{\pythagheight}{2cm}
\begin{tikzpicture}

  \coordinate [label={below right:$A$}] (A) at (0, 0);
  \coordinate [label={above right:$B$}] (B) at (0, \pythagheight);
  \coordinate [label={below left:$C$}] (C) at (-\pythagwidth, 0);

  \coordinate (D1) at (-\pythagheight, \pythagheight + \pythagwidth);
  \coordinate (D2) at (-\pythagheight - \pythagwidth, \pythagwidth);

  \draw [thick,red] (A) -- (C) -- (B) -- (A);

  \newcommand{\ranglesize}{0.3cm}
  \draw [red] (A) -- ++ (0, \ranglesize) -- ++ (-\ranglesize, 0) -- ++ (0, -\ranglesize);

  \draw [help lines] (A) -- node [below] {$b$} ++ (-\pythagwidth, 0)
            -- node [right] {$b$} ++ (0, -\pythagwidth)
            -- node [above] {$b$} ++ (\pythagwidth, 0)
            -- node [left]  {$b$} ++ (0, \pythagwidth);

  \draw [help lines] (A) -- node [right] {$c$} ++ (0, \pythagheight)
            -- node [below] {$c$} ++ (\pythagheight, 0)
            -- node [left]  {$c$} ++ (0, -\pythagheight)
            -- node [above] {$c$} ++ (-\pythagheight, 0);

  \draw [help lines] (C) -- node [above left]  {$a$} (B)
                 -- node [below left]  {$a$} (D1)
                 -- node [below right] {$a$} (D2)
                 -- node [above right] {$a$} (C);
\end{tikzpicture}
\end{document}

我想将标签的字体更改为 Biolinum,这是包中的无衬线字体libertine。我尝试了\usepackage{libertine}\sffamily,但没有成功。我还尝试libertine在文档类上声明为选项。那也没有用。我应该怎么做?

答案1

您的标签是在数学模式下设置的。您只发出了影响文本字体的命令。但是,如果您希望标签采用默认的sffamily,那么最简单的方法就是不使用数学模式,因为您不需要它来排版普通字母,除非您希望它们来自数学字母表,而您不需要。所以只需写 ega而不是$a$

\documentclass[tikz,border=10pt]{standalone}
\usepackage{libertine}
\begin{document}

\newcommand{\pythagwidth}{3cm}
\newcommand{\pythagheight}{2cm}
\begin{tikzpicture}[font=\sffamily]

  \coordinate [label={below right:A}] (A) at (0, 0);
  \coordinate [label={above right:B}] (B) at (0, \pythagheight);
  \coordinate [label={below left:C}] (C) at (-\pythagwidth, 0);

  \coordinate (D1) at (-\pythagheight, \pythagheight + \pythagwidth);
  \coordinate (D2) at (-\pythagheight - \pythagwidth, \pythagwidth);

  \draw [thick,red] (A) -- (C) -- (B) -- (A);

  \newcommand{\ranglesize}{0.3cm}
  \draw [red] (A) -- ++ (0, \ranglesize) -- ++ (-\ranglesize, 0) -- ++ (0, -\ranglesize);

  \draw [help lines] (A) -- node [below] {b} ++ (-\pythagwidth, 0)
            -- node [right] {b} ++ (0, -\pythagwidth)
            -- node [above] {b} ++ (\pythagwidth, 0)
            -- node [left]  {b} ++ (0, \pythagwidth);

  \draw [help lines] (A) -- node [right] {c} ++ (0, \pythagheight)
            -- node [below] {c} ++ (\pythagheight, 0)
            -- node [left]  {c} ++ (0, -\pythagheight)
            -- node [above] {c} ++ (-\pythagheight, 0);

  \draw [help lines] (C) -- node [above left]  {a} (B)
                 -- node [below left]  {a} (D1)
                 -- node [below right] {a} (D2)
                 -- node [above right] {a} (C);
\end{tikzpicture}
\end{document}

无标签

相关内容