如何为“全局”思维导图中的节点设置任意字体大小

如何为“全局”思维导图中的节点设置任意字体大小

我在 tex.stackexchange.com 上没有找到尝试定义字体大小(包括任何字体大小)设置的问题。我发布的问题可能会成为“重复”,但我还是会发布。我的问题是如何以“全局”方式为思维导图的节点设置任何字体大小。虽然这是一件简单的事情,但我认为其中有一些微妙之处。

这是我的例子

这是我的 MWE:

\documentclass{article}
\usepackage{anyfontsize}
\usepackage{tikz}
\usepackage[paperwidth=5cm,paperheight=5cm]{geometry}
\usetikzlibrary{mindmap}
\begin{document}
\centering\begin{tikzpicture}[mindmap]
    \tikzstyle{every node}=[text width=1cm,align=flush center,minimum size=1cm]
         \node [concept, text=white] at (0,0) 
      {any other text}
    child [concept color=blue!50, grow=0,level distance=80]
    {node [concept] (text) {Text}}; 
\end{tikzpicture}
\end{document}

答案1

这是我自己的答案,使用\fontselect{X-size-unitdimen}{X-size-unitdimen}\selectfont。我认为要产生效果,必须使用\selectfont

\documentclass{article}
\usepackage{anyfontsize}
\usepackage{tikz}
\usepackage[paperwidth=5cm,paperheight=5cm]{geometry}
\usetikzlibrary{mindmap}
\begin{document}
\centering\begin{tikzpicture}[mindmap]
    \tikzstyle{every node}=[font=\fontsize{2mm}{3mm}\selectfont,text width=1cm,align=flush center,minimum size=1cm]
         \node [concept, text=white] at (0,0) 
      {any other text}
    child [concept color=blue!50, grow=0,level distance=80]
    {node [concept] (text) {Text}}; 
\end{tikzpicture}
\end{document}

我的身影与自己的答案

答案2

如果您愿意编译lualatex并使用 OpenType 字体(而不是旧的 TeX Type 1 字体),您可以获得任何您喜欢的大小和间距,甚至是非整数值。使用诸如 这样的包,textpos您可以将文本放置在任何地方,但我不会在这里编写代码。MWE:

\documentclass{article} % Default font size. Process with lualatex.
\usepackage{fontspec}
\makeatletter
\renewcommand\normalsize{\@setfontsize\normalsize{11.43pt}{15.824pt}}
\normalsize
\makeatother
\begin{document}
\setlength\parindent{0pt}
Hello World.\\
Hello World\\
Hello World\par
\makeatletter
\renewcommand\normalsize{\@setfontsize\normalsize{13.723bp}{17.448bp}}
\normalsize
\makeatother
Hello Again\\
Hello Again\\
Hello Again\par
\end{document}
\\\
Compile that with `lualatex` and look at the resulting PDF.

相关内容