考虑以下 beamer/tikz 代码:
\documentclass{beamer}
\usepackage{fontspec}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{decorations.text,calc,shapes,matrix,backgrounds,arrows,shadows,
positioning,fit,automata,decorations.pathreplacing,arrows.meta,bending,quotes,shadows.blur}
\begin{document}
\begin{frame}
\frametitle{Server Operating Systems}
\begin{tikzpicture}[overlay,remember picture]
\node[draw=none,shade,align=center,
minimum height=3cm,
minimum width=4cm,
top color=blue!40,
bottom color=blue!5,
rounded corners=3pt,
blur shadow={shadow blur steps=2}
] at (3,1) (a) {\sffamily\bfseries\huge Windows\\
\sffamily\bfseries\huge \vspace*{3mm} Server};
\end{tikzpicture}
\end{frame}
\end{document}
如何更改文本的行距,即 Windows 和 Server 之间的间距(在本例中)?
答案1
您可以在 后添加任意测量值\\
,例如\\[1ex]
或\\[1mm]
。如果您在多个节点中需要这样做,则替代解决方案(更自动化)可能会更好。但对于一个实例,这是一个快速修复。
输出
代码
\documentclass{beamer}
\usepackage{fontspec}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{decorations.text,calc,shapes,matrix,backgrounds,arrows,shadows,
positioning,fit,automata,decorations.pathreplacing,arrows.meta,bending,quotes,shadows.blur}
\begin{document}
\begin{frame}
\frametitle{Server Operating Systems}
\begin{tikzpicture}[overlay,remember picture]
\node[draw=none,shade,align=center,
minimum height=3cm,
minimum width=4cm,
top color=blue!40,
bottom color=blue!5,
rounded corners=3pt,
font=\sffamily\bfseries\huge,
blur shadow={shadow blur steps=2}
] at (3,1) (a) {Windows\\[1mm] Server};
\end{tikzpicture}
\end{frame}
\end{document}
答案2
您在节点中定义文本字体的方式是错误的,因此间距考虑的是正常文本大小而不是您所期望的巨大。请尝试以下操作:
\documentclass{beamer}
%\usepackage{fontspec}% commented that I can use pdftex, it also should work with xelatex
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{arrows, arrows.meta, automata, backgrounds, bending,
calc, decorations.text, decorations.pathreplacing,
fit, matrix, positioning, quotes,
shadows, shapes,shadows.blur}
\begin{document}
\begin{frame}
\frametitle{Server Operating Systems}
\begin{tikzpicture}[overlay,remember picture]
\node[draw=none,shade,align=center,
minimum height=3cm,
minimum width=4cm,
top color=blue!40,
bottom color=blue!5,
rounded corners=3pt,
blur shadow={shadow blur steps=2,
font=\sffamily\bfseries\huge} % <---
] at (3,1) (a) {Windows\\ Server}; % <---
\end{tikzpicture}
\end{frame}
\end{document}
编辑:如果线与线之间的正常距离不是您想要的,那么您可以更改它,例如通过
\node[draw=none,shade,align=center,
minimum height=3cm,
minimum width=4cm,
top color=blue!40,
bottom color=blue!5,
rounded corners=3pt,
blur shadow={shadow blur steps=2,
font=\sffamily\bfseries\huge} % <---
] at (3,1) (a) {Windows\\[5ex] Server}; % <---
并得到
你不太清楚自己想要得到什么。阅读 TikZ 手册第节可能会有所帮助文本参数:多行文本的对齐方式和宽度在第 223 页(最新版本)