我需要编写包含在 tikzpicture 节点中的大字体。当我更改比例时,所有内容都会更改,但字体不会更改。这是我的代码:
\documentclass[10pt,a4paper]{book}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=2.5]
\path [fill=red] (0cm,1.5576cm)--(0cm,.6227cm).. controls (.05cm,.28cm) and (.25cm,.17cm) ..(.6512cm,0cm)--(.6512cm,.9076cm) .. controls (.4cm,1cm)and(.1cm,1.1cm)..(0cm,1.5576cm)--cycle;
\path [fill=red](0cm,1.5576cm).. controls (.12cm,1.2cm)and(.45cm,1.1cm)..(.8118cm,.9918cm)--(.8118cm,.0931cm)--(.9764cm,.2014cm)--(.9764cm,1.0681cm) .. controls (.45cm,1.12cm)and(.15cm,1.31cm)..(0cm,1.5576cm)--cycle;
\path [fill=red](0cm,1.5576cm).. controls (.2cm,1.32cm)and(.7cm,1.21cm)..(1.141cm,1.1644cm)--(1.141cm,.3418cm) .. controls (1.2781cm,.4793cm).. (1.3016cm,.6227cm)--(1.3016cm,1.2727cm) .. controls (.7cm,1.3cm)and(.2cm,1.4cm)..(0cm,1.5576cm)--cycle;
\path [fill=red] (0cm,1.5576cm).. controls (.2cm,1.47cm)and(.7cm,1.3cm)..(1.3016cm,1.4212cm)--(1.3016cm,1.5576cm) .. controls (.7cm,1.42cm)and(.2cm,1.49cm)..(0cm,1.5576cm)--cycle;
\draw (2,1.5) node {\fontsize{52}{58}\sffamily\bfseries TEXT};
\end{tikzpicture}
\end{document}
答案1
如果您加载了可以正确缩放的字体,那么您的示例无需缩放即可工作。如果您想使用标准 Computer Modern,请加载包fix-cm
。否则,请加载lmodern
包。图片上的缩放默认不适用于 TikZ 中的节点文本。
正如评论中所述,将字体参数作为font
节点键的一部分而不是直接放在节点本身内是更好的做法。
看如何在 LaTeX 中指定任意(可能非整数)字体大小有关字体大小的更多信息。
\documentclass[10pt,a4paper]{book}
\usepackage{tikz}
%\usepackage{fix-cm}
\usepackage{lmodern}
\begin{document}
\begin{tikzpicture}
\path [fill=red] (0cm,1.5576cm)--(0cm,.6227cm).. controls (.05cm,.28cm) and
(.25cm,.17cm) ..(.6512cm,0cm)--(.6512cm,.9076cm) .. controls
(.4cm,1cm)and(.1cm,1.1cm)..(0cm,1.5576cm)--cycle;
\path [fill=red](0cm,1.5576cm).. controls (.12cm,1.2cm)and(.45cm,1.1cm)..
(.8118cm,.9918cm)--(.8118cm,.0931cm)--(.9764cm,.2014cm)--(.9764cm,1.0681cm) ..
controls (.45cm,1.12cm)and(.15cm,1.31cm)..(0cm,1.5576cm)--cycle;
\path [fill=red](0cm,1.5576cm).. controls (.2cm,1.32cm)and(.7cm,1.21cm)..
(1.141cm,1.1644cm)--(1.141cm,.3418cm) .. controls (1.2781cm,.4793cm)..
(1.3016cm,.6227cm)--(1.3016cm,1.2727cm) .. controls (.7cm,1.3cm)and(.2cm,1.4cm)..
(0cm,1.5576cm)--cycle;
\path [fill=red] (0cm,1.5576cm).. controls (.2cm,1.47cm)and(.7cm,1.3cm)..
(1.3016cm,1.4212cm)--(1.3016cm,1.5576cm) .. controls
(.7cm,1.42cm)and(.2cm,1.49cm)..(0cm,1.5576cm)--cycle;
\draw (2,1.5) node[font=\fontsize{52}{58}\sffamily\bfseries]{TEXT};
\end{tikzpicture}
\end{document}